# API Docs

## List Projects

<mark style="color:green;">`GET`</mark> <https://app.athenic.com/api/projects>

The API uses an API key to authenticate requests. You can view your API key in your team settings.\
\
Projects must be created in the application. This API request will retrieve IDs and names for all projects owned by your team. You can then use any project\_id to query that project.

<br>

**Headers**

| Name          | Value                       |
| ------------- | --------------------------- |
| Content-Type  | `application/json`          |
| Authorization | `Bearer` **{Your API Key}** |

**Response**

{% tabs %}
{% tab title="200" %}

<pre class="language-json"><code class="lang-json"><strong>{
</strong>    "projects": [{
        "project_id": project_id,
        "project_name": project_name,
        "created_at_date": created_at_date,
    }]
<strong>}
</strong></code></pre>

{% endtab %}
{% endtabs %}

## Query Projects

<mark style="color:green;">`POST`</mark>  <https://app.athenic.com/api/projects/\\>\<project\_id>/generate-query

**Query an existing project**

The API uses an API key to authenticate requests. You can view your API key in your team settings.\
\
Projects must be created in the application before querying. This API request will generate a SQL query given an input question.

**Headers**

| Name          | Value                       |
| ------------- | --------------------------- |
| Content-Type  | `application/json`          |
| Authorization | `Bearer` **{Your API Key}** |

**Body**

| Name         | Type   | Description                               |
| ------------ | ------ | ----------------------------------------- |
| **question** | string | **Your input question you want answered** |

**Response**

{% tabs %}
{% tab title="200" %}

```json

{
        "query_id": "c5d5a134-eebc-4224-90fa-0dbe7bc35cc5",
        "question": "Show me the monthly sales for x, y, z",
        "sql_query": "SELECT ... FROM ..."
        "full_sql_query": "WITH dataset1 AS (...), dataset2 AS (...) SELECT ... FROM ..." -- The full SQL query including the project datasets' SQL
        "explanation": -- An plain text explanation of what your query is doing
        "run_status": -- One of ["success", "error", "empty"]
        "df": A dictionary containing the query results
        "truncated": -- A boolean indicating whether the df was truncated to 10000 rows
        "query_error": -- A string containing the error if running the SQL query failed  
}
```

{% endtab %}
{% endtabs %}
