Getting started overview

Integrating with the News API involves a sequence of steps designed to enable developers to retrieve news data efficiently. The core process encompasses account creation, API key acquisition, and executing initial requests. News API provides access to real-time and historical news articles globally, categorizing content through endpoints like the Top Headlines API and the Everything API.

Authentication is managed via an API key, which must be included with every request. This key grants access permissions based on the user's subscription tier. The API uses standard HTTP GET requests and returns data in JSON format, making it compatible with most programming languages and platforms. Successful integration allows applications to query news articles by keywords, sources, language, and other parameters.

Here's a quick reference for the initial setup:

Step What to Do Where
1. Sign Up Create a News API account. News API registration page
2. Get API Key Locate your unique API key in the developer dashboard. News API account dashboard
3. Construct Request Formulate an HTTP GET request with your API key. Any HTTP client (e.g., curl, Python requests, JavaScript fetch)
4. Parse Response Process the JSON data returned by the API. Your application code

Create an account and get keys

To begin interacting with News API, you must first register for an account. This step is mandatory to obtain the necessary credentials for authenticating your API calls. News API offers a Developer Plan that includes a free tier, allowing up to 100 requests per day, suitable for testing and development.

Registration process

  1. Navigate to the News API registration page.
  2. Provide a valid email address, a strong password, and your full name.
  3. Agree to the terms of service.
  4. Complete any CAPTCHA verification if prompted.
  5. Click the "Register" button to create your account.

Upon successful registration, you will typically receive an email to verify your account. It's important to complete this verification to activate full account functionality.

Retrieving your API key

After registering and verifying your account, your unique API key will be available in your developer dashboard:

  1. Log in to your News API account.
  2. On your account dashboard, your API key will be prominently displayed.
  3. Copy this key. It is a sensitive credential and should be treated like a password.

The API key is a unique string of alphanumeric characters. It serves as the primary method for authenticating your requests to News API. Without a valid API key, all API calls will be rejected with an authentication error.

Your first request

Once you have your API key, you can make your first request to News API. This example will use the "Everything" endpoint, which allows searching for articles from various sources. The API key can be passed either as a query parameter named apiKey or as an HTTP header X-Api-Key. Using an HTTP header is generally recommended for security best practices to avoid exposing the key in server logs or browser history, though for a quick start, the query parameter is simpler.

Request structure

A basic request to the Everything endpoint might look like this:

GET https://newsapi.org/v2/everything?q=tesla&apiKey=YOUR_API_KEY

Replace YOUR_API_KEY with the key you obtained from your dashboard. The q=tesla parameter specifies that you are searching for articles containing the word "tesla".

Using curl

curl is a command-line tool for making HTTP requests and is widely available on most operating systems. This is a common method for testing API endpoints:

curl -X GET "https://newsapi.org/v2/everything?q=tesla&language=en&sortBy=publishedAt&apiKey=YOUR_API_KEY"

This command requests English articles about "tesla", sorted by publication date.

Using Python

Python's requests library simplifies making HTTP requests:

import requests
import json

api_key = "YOUR_API_KEY"
query = "openai"
url = f"https://newsapi.org/v2/everything?q={query}&language=en&apiKey={api_key}"

response = requests.get(url)

if response.status_code == 200:
    data = response.json()
    print(json.dumps(data, indent=2))
else:
    print(f"Error: {response.status_code} - {response.text}")

This Python script fetches articles containing "openai" and prints the JSON response in a readable format.

Expected response

A successful response (HTTP status 200 OK) will be a JSON object containing metadata and an array of articles. Each article object will typically include fields such as source, author, title, description, url, urlToImage, publishedAt, and content. An example of a partial response structure:

{
  "status": "ok",
  "totalResults": 12345,
  "articles": [
    {
      "source": {
        "id": "bbc-news",
        "name": "BBC News"
      },
      "author": "BBC News",
      "title": "Example News Article Title",
      "description": "A brief summary of the article content.",
      "url": "https://www.bbc.co.uk/news/articles/example",
      "urlToImage": "https://ichef.bbci.co.uk/news/image.jpg",
      "publishedAt": "2026-05-29T12:00:00Z",
      "content": "Full article content snippet..."
    }
  ]
}

Common next steps

After successfully making your first call, several common next steps can enhance your use of News API:

  1. Explore other endpoints: News API offers additional endpoints beyond "Everything." The Top Headlines API focuses on current top news stories, while the Sources API allows you to retrieve a list of all available news sources.

  2. Add more query parameters: Refine your searches by utilizing parameters such as sources, domains, from, to, language, and pageSize. These allow for more targeted data retrieval. For a complete list of parameters, consult the official News API documentation.

  3. Implement error handling: Integrate robust error handling into your application. Common status codes to handle include 400 Bad Request (invalid parameters), 401 Unauthorized (invalid API key), and 429 Too Many Requests (rate limit exceeded). Proper error handling ensures your application gracefully manages unexpected responses.

  4. Upgrade your plan: If your daily request volume exceeds the Developer Plan's 100 requests, consider upgrading to a paid subscription tier. News API offers plans starting at $49/month for 5,000 requests/day, with options for higher volumes.

  5. Utilize SDKs (if available): While News API does not officially provide SDKs, community-contributed libraries in various programming languages may exist to simplify integration. Always verify the reliability and security of third-party SDKs before incorporating them into production systems.

  6. Monitor API usage: Keep track of your API consumption through your account dashboard to avoid hitting rate limits unexpectedly. Monitoring usage helps in planning for potential plan upgrades or optimizing query frequency.

Troubleshooting the first call

Encountering issues during your first API call is common. Here are some frequent problems and their solutions:

  • Invalid API Key (401 Unauthorized):

    • Issue: You receive an HTTP 401 status code or a message indicating an invalid API key.
    • Solution: Double-check that you have copied the API key correctly from your News API dashboard. Ensure there are no leading or trailing spaces. Verify it is included correctly in the request, either as the apiKey query parameter or an X-Api-Key HTTP header.
  • Missing Required Parameters (400 Bad Request):

    • Issue: The API returns 400 Bad Request with a message about missing parameters. For instance, the "Everything" endpoint generally requires a q (query) or sources parameter.
    • Solution: Review the News API endpoint documentation to ensure all mandatory parameters for the specific endpoint you are calling are present in your request. For example, if using the Top Headlines endpoint without q, you need to specify country or category.
  • Rate Limit Exceeded (429 Too Many Requests):

    • Issue: You receive an HTTP 429 status code. This means you have exceeded the number of requests allowed by your current plan within a specific time frame (e.g., 100 requests/day for the Developer Plan).
    • Solution: Wait for the rate limit to reset (typically 24 hours for daily limits). For production applications, implement proper rate limiting and retry logic with exponential backoff. Consider upgrading your plan if you consistently hit limits.
  • Network Connectivity Issues:

    • Issue: Your request times out or fails with a network-related error.
    • Solution: Verify your internet connection. If making requests from a server, check firewall rules or proxy settings that might be blocking outbound HTTP requests to newsapi.org.
  • Incorrect URL Path:

    • Issue: You receive an HTTP 404 Not Found error.
    • Solution: Confirm that the base URL and endpoint path (e.g., /v2/everything, /v2/top-headlines) are spelled correctly according to the News API documentation.