Skip to content

A Python implementation of the IAB consent strings (v1.1 and v2)

License

Notifications You must be signed in to change notification settings

gguridi/iab-tcf

Folders and files

NameName
Last commit message
Last commit date
Oct 31, 2022
Nov 30, 2021
Nov 30, 2021
Nov 30, 2021
Sep 7, 2020
Nov 30, 2021
Sep 6, 2020
Sep 6, 2020
Sep 7, 2020
Nov 30, 2021
Nov 30, 2021
Oct 31, 2022
Sep 7, 2020

Repository files navigation

iab-tcf

Build Status codecov Codacy Badge Releasing Documentation Status

A Python implementation of the IAB consent strings (v1.1 and v2)

Installing

Install and update using pip:

pip install -U iab-tcf

Documentation

Documentation of this package can be found at readthedocs.io.

To generate the documentation locally:

pip install sphinx sphinx_rtd_theme
cd docs/
sphinx-apidoc -f -o . ../iab_tcf/
make html

A Simple Example

In order to decode a v1.1 or v2 consent string automatically we can do:

from iab_tcf import decode

consent = decode("CO5VTlWO5VTlWH1AAAENAwCwAIAAAAAAAIAAAAoAAAAA.YAAAAAAAAAA")

print(consent.version) # prints 2

If we want to improve performance and we already know it's going to be a v2 consent string we can do:

from iab_tcf import decode_v2

consent = decode_v2("CO5VTlWO5VTlWH1AAAENAwCwAIAAAAAAAIAAAAoAAAAA.YAAAAAAAAAA")

print(consent.version) # prints 2

Tests

In order to run the tests locally we can do:

pip install -r requirements-test.txt
pytest -v .

Thanks

Many thanks to LiveRamp/iabconsent which greatly inspired this project, and forms the basis and internal logic.

About

A Python implementation of the IAB consent strings (v1.1 and v2)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages