https://github.com/gguridi/iab-tcf
A Python implementation of the IAB consent strings (v1.1 and v2)
https://github.com/gguridi/iab-tcf
gdpr gdpr-consent iab-consent iab-tcf tcfv2
Last synced: 2 months ago
JSON representation
A Python implementation of the IAB consent strings (v1.1 and v2)
- Host: GitHub
- URL: https://github.com/gguridi/iab-tcf
- Owner: gguridi
- License: mit
- Created: 2020-09-06T20:15:07.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-10-31T10:39:30.000Z (over 2 years ago)
- Last Synced: 2025-04-15T20:12:39.036Z (2 months ago)
- Topics: gdpr, gdpr-consent, iab-consent, iab-tcf, tcfv2
- Language: Python
- Homepage:
- Size: 187 KB
- Stars: 6
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# iab-tcf
[](https://travis-ci.org/gguridi/iab-tcf)
[](https://codecov.io/gh/gguridi/iab-tcf)
[](https://www.codacy.com/gh/gguridi/iab-tcf/dashboard)

[](https://iab-tcf.readthedocs.io/en/latest/?badge=latest)A Python implementation of the IAB consent strings (v1.1 and v2)
## Installing
Install and update using pip:
```bash
pip install -U iab-tcf
```## Documentation
[Documentation](https://iab-tcf.readthedocs.io/en/stable/) of this package can be
found at [readthedocs.io](https://iab-tcf.readthedocs.io/en/stable/).To generate the documentation locally:
```bash
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:
```python
from iab_tcf import decodeconsent = 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:```python
from iab_tcf import decode_v2consent = decode_v2("CO5VTlWO5VTlWH1AAAENAwCwAIAAAAAAAIAAAAoAAAAA.YAAAAAAAAAA")
print(consent.version) # prints 2
```## Tests
In order to run the tests locally we can do:
```bash
pip install -r requirements-test.txt
pytest -v .
```## Thanks
Many thanks to [LiveRamp/iabconsent](https://github.com/LiveRamp/iabconsent)
which greatly inspired this project, and forms the basis and internal logic.