How to use the Intravert API for new Integrations

Integrations

Integrations are key to our mission at Intravert. Today we're introducting the Intravert API, which gives you a read-only access to a users ad spaces and entities.

how-to-use-the-intravert-api-for-new-integrations

Last Update: 5/25/2019. Version 1.0 of the Intravert API.

Each user is assigned an API key. To claim your API key, navigate to the Integrations Dashboard and claim it.

Authentication

Under the hood, we are using the Django Rest Framework TokenAuthentication to authenticate a user at the API level. Once you've claimed your API key, you can add the following as an HTTP Header to authenticate yourself

Authorization: Token <YOUR-API-TOKEN>

A simple curl request would look as follows. 

curl -X GET http://intravert.co/api/-H 'Authorization: Token <YOUR-API-TOKEN>'

Reading all Entities

An "Entity" is considered to be a unique site on someones account. If somebody is running ad spaces on their webapp, podcast and personal blog, these are considered three different entities (given that they run under three different domains).

To read a user's entities, you can send a GET request with the authentication added to https://intravert.co/api/.

The response may looks something like this:

[{"url": "https://intravert.carrd.co", "hash_1": "b339a783ac"}]

Reading all Spaces

An entity can have one or multiple spaces. To read all entity spaces, you can take the hash_1 value and simply append it to the URL, sending a new GET request to https://intravert.co/api/b339a783ac/.

The result looks something like this:

[{"id": 97, "description": "Demo Banner Ad"}]

Getting a Space Code

To actually integrate the ad space on your own site, we ask users to integrate a unique code snippet wherever their ad space is supposed to appear.

In the last step, you need to claim the entity hash and the space ID to receive the code for a single ad space. In this case, we have the entity hash b339a783ac and the space ID 97 and can use this information to send a GET request to our final endpoint at https://intravert.co/api/b339a783ac/97/.

We're receiving the following code, which we can embed on our own site (e.g. through a plugin) and have the corresponding ad space appear there.

<div class="intravert-space" id="space-b339a783ac97"></div>
<script defer src="https://intravert.co/serve/b339a783ac.97.js"></script>