# TCF API

In order to have a full spec of the TCF API, you can read more at this link: <https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework/blob/master/TCFv2/IAB%20Tech%20Lab%20-%20CMP%20API%20v2.md>

### Get Consent Data

The TCF framework have a helper function that will fetch the consents given by a user. you can use it by this code snippet below:

```javascript
__tcfapi('getTCData', 2, function (tcData, success) {
    if (success) {
        console.log(tcData)
    } else {
        console.log('bummer dude')
    }
});
```

The `tcData` variable will return an object that contains this data:

```javascript
{
	cmpId: 1000,
	cmpVersion: 2,
	gdprApplies: true,
	purpose: {
		consents: {	1: true, 2: true, 3: true, 4: true ... }
		legitimateInterests: { 1: true, 2: true, 3: true ...}
	}
	specialFeatureOptins:{ 1: true, 2: true ... }
	tcString: "CO7N7b-O7N7b-DrACAENAtCAAP_AA...",
	tcfPolicyVersion: 2,
	useNonStandardStacks: false,
	vendor: {
		consents: {1: true, 2: true, 4: true, 6: true ... }
		legitimateInterests: {1: true ... }
	}
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.adnuntius.com/adnuntius-connect/integration-guide/tcf-api.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
