API Quickstart

Example search for Tesla stock outlook

Making your first request with the Athena API is straightforward with this script.

There are two examples provided below. The first, and recommended method, is using our /api/v2/query-async endpoint. The second method uses our /api/v2/query endpoint, which is geared towards small searches.

Using Async Query Endpoint

First define your ATHENA_API_KEY. The payload dictionary specifies the query parameters, including a search term ("donald trump"), your api_key, other configuration details to filter the results (for the sake of simplicity we are choosing to omit extra parameters — see API Reference for other options).

The initial request is sent via a POST call to Athena’s query-async API endpoint. The response contains your query_id, which is how you will retrieve results from your search with the /api/v2/get-results endpoint.

Using Synchronous Endpoint

This example makes use of the /api/v2/auery endpoint, which is best geared for smaller searches. It's simpler to use, but is not meant to handle queries generating large results. See API Reference for more details.

It begins by defining the necessary ATHENA_API_KEY. The payload dictionary specifies the query parameters, including a search term ("donald trump"), your api key, and other configuration details used to filter the results (for the sake of simplicity we are choosing to omit extra parameters).

The initial request is sent via a POST call to Athena’s API endpoint, with the response stored in data. This response includes metadata such as totalResults, allowing for efficient pagination. The loop then iterates over pages, adjusting the payload to request the next set of articles and appending each batch to all_articles. By the end, all_articles contains all retrieved articles matching the query, providing an easy way to gather a complete dataset in only a few lines of code.

This example makes use of the /api/v2/auery endpoint, which is best geared for smaller searches. Our /api/v2/query-async endpoint is suited for larger queries - see API Reference for more details.

Last updated