Skip to main content
Version: v2

Reference Classes

The SDK can generate some convenience reference classes which map Fount resource IDs with a more readable name, both for ease of use and for autocompletion in IDEs.

These classes are automatically generated by a console command that becomes available once bavapi is installed.

Protected Access

A Fount API token is required to generate reference files. See the Authentication section for more information and instructions for using .env files within your Python project.

As of v1.1 the following reference classes will be generated in a folder named bavapi_refs:

  • Audiences: encodes audience IDs
  • Countries: encodes country IDs

A sample reference class would look like this:

class Audiences(Enum):
ALL_ADULTS = 27 # Random ID
...

And could be used to have better visibility when filtering API responses:

Explicit audience filter
bavapi.brandscape_data(country_code="US", year=2022, audiences=Audiences.ALL_ADULTS)
Ignore reference classes on public repositories

Please take care not to commit reference classes to public repositories. Add bavapi_refs/ to your .gitignore file.

To generate these reference classes, there are two options for authenticating your requests:

  • Specify the Fount API token via the -t/--token argument
  • Use a .env file to store your Fount API token and install python-dotenv to read the file into your environment. See the Authentication section for more info.

Run the following command:

bavapi-gen-refs --all

Alternatively, you can specify the name of the reference class to generate:

bavapi-gen-refs --name audiences

To update existing reference classes with the latest data, re-run bavapi-gen-refs --all on your terminal.

Keep the reference classes up to date

The audiences and markets change over time. It is recommended to update your reference classes regularly. Typically audiences and markets are never deleted, however we can't guarantee that it will never happen.