# Custom API connections

{% hint style="info" %}
For most customers looking to download data, we recommend [<mark style="color:blue;">Downloading Consolidated Data</mark>](/the-platform/exporting-data/downloading-and-scheduling-data-reports.md) in the reporting section, and for user-level data to [<mark style="color:blue;">request bulk report outputs</mark>](https://www.adlibertas.com/ltvs-made-easy-bulk-campaign-pltv-outputs/) from your account manager.
{% endhint %}

This document outlines how to connect to the AdLibertas dashboard via API. The connection is through our [<mark style="color:blue;">business analytics tool</mark> ](/the-platform/business-analytics.md)Metabase. Data exports from both [<mark style="color:blue;">user-level reporting</mark>](/the-platform/user-level-audience-reporting.md) and [<mark style="color:blue;">consolidated revenue reporting</mark>](/the-platform/consolidated-revenue-reporting.md) are available to export via API.

For simplicity's sake, we recommend using an authenticated post request to download saved questions. If you want/need the ability to create dynamic questions for API export, this is significantly more difficult and will require you to contruct the queries with each post. If you'd like assistance, please let us know.

Note for Consolidated Revenue Reporting: AdLibertas is constantly re-pulling network data to ensure we capture any changes or problems as reported by your data sources. Additionally, there are frequently data delays and outages that may lead to data being unavailable at the time of your request. For this reason we recommend you pull the trailing 7-15 days of data to account for any corrections we find.

### **Authentication:**

1\.      Login to the Adlibertas dashboard with your username/password

```
curl'https://publicapi.adlibertas.com/v1/users/login
' -H 'content-type: application/json;charset=UTF-8' --data-binary '{"username":"______@adlibertas.com","password":"_______"}' --compressed

# response will look like this
{"token":"XXXXX","session_id":"XXXXXX"}
```

2\.  For a request to be authenticated, set your `cookie` header to `metabase.SESSION_ID=your-session-id-here`&#x20;

Note: the session ID, will be used in the next request. Session IDs are set to expire after 30 days.

&#x20;

### **Create your Question:**

1\.    [  <mark style="color:blue;">Create</mark> <mark style="color:blue;"></mark><mark style="color:blue;">**a new question:**</mark>](/the-platform/business-analytics/asking-a-question.md)

2\.      [<mark style="color:blue;">**Save your question**</mark>](/the-platform/business-analytics/saving-a-question.md)

&#x20;Example Question: <https://metabase.adlibertas.com/question/1646>

Note: the 1646 at the end of the request URL, is your report ID **\<reportID>**.

&#x20;

**Download the saved question as a CSV:**

For CSV: Send an authenticated POST request to `https://metabase.adlibertas.com/api/card/`**`<reportID>/`**`query/csv` updating the report ID to the desired question.

To download as JSON: Send an authenticated POST request to `https://metabase.adlibertas.com/api/card`**`/<reportID>`**`/query/json` updating the ID to the desired question.

&#x20;


---

# 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.adlibertas.com/the-platform/exporting-data/custom-api-connections.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.
