
NewsData.io uses API key authentication to access the platform's features and data. An API key is a unique string of characters that is generated for each account, and it is required in all requests to the API.
What is API Key Authentication
Every request to the NewsData.io API must be authenticated. Your unique API key acts as a secret token that identifies your account and manages your access levels and rate limits. Keep this key secure and never share it in public repositories or client-side code that can be inspected by users.
How to Pass API Key in the Request
When making requests to the API, you need to include the API key in the request URL. The API key can be passed using one of the two methods below:
Method 1: HTTP Header
Pass your key using the X-ACCESS-KEY header. This is the recommended secure method.
# Request Header
X-ACCESS-KEY: YOUR_API_KEY
Method 2: Query Parameter
Pass your key using the ?apikey= query parameter. This is the alternative method.
# URL Parameter
?apikey= YOUR_API_KEY
Error Handling
If the API key is not included in the request headers or it is invalid, the API will return a 403 Unauthorized error and the request will be denied.
403 Unauthorized Error
This error occurs when the server understands the request but refuses to authorize it. Common reasons include:
Missing X-ACCESS-KEY or apikey
Typos in your API Key
Using an expired or revoked key
Was this page helpful?