How do I make my first API request?
The easiest start is the sandbox: https://newsapi.ai/documentation/sandbox. Build a search with the form (keywords, concepts, sources, categories, dates...), run it, and copy the generated request or code (REST, Python, Node.js).
A request is a POST with a JSON body to the endpoint, for example for article search:
POST https://eventregistry.org/api/v1/article/getArticles
Content-Type: application/json
{
"query": {
"$query": { "keyword": "Tesla", "lang": "eng" },
"$filter": { "forceMaxDataTimeWindow": "31" }
},
"resultType": "articles",
"articlesSortBy": "date",
"apiKey": "YOUR_API_KEY"
}- The official API host is eventregistry.org (the company behind NewsAPI.ai), as used in all examples in the documentation.
- Put the API key in the JSON body as
apiKey. POST with JSON is recommended over GET with URL parameters. - Documentation of all endpoints and parameters: https://newsapi.ai/documentation. The complete API specification as a single file (useful for code assistants and LLMs): https://eventregistry.org/static/api.yaml.
- Python: the official SDK is
eventregistryon PyPI (GitHub, with examples). It offers the same functionality as the REST API. There is also a Node.js SDK. - The sandbox shows only a shortened article body; direct API requests return the full body.