Skip to content

Installation and Setup

Installation

To install the Pixel API client, you can use pip to install the package from PyPI:

pip install pixel-client

Authentication

To set up correct authentication against the API, you need to provide the following environment variables defined in PixelApiSettings class. These can be passed directly, through env variables or through a .env file.

from pixel_client import get_client, PixelApiSettings

# Get the client with the settings parsed from env variables
client = get_client()
# Get the async client with the settings parsed from env variables
client_async = get_client(async_=True)

# Get the client with the settings passed directly
settings = PixelApiSettings(
        PIXEL_TENANT=...,
        PIXEL_USERNAME=...,
        PIXEL_PASSWORD=...
    )
# Or from a .env file
settings = PixelApiSettings.from_env_file("my_env_file.env")
client = get_client(
    settings=settings
)
# Get the async client with the settings passed directly
client_async = get_client(
    settings=settings,
    async_=True
)

# subsequent calls to the get_client function will return the same client instances if the settings are the same
Reccomended approach is to use environment variables or a .env file to avoid hardcoding sensitive information in your codebase.