The News API Headlines API

Latest headlines organized by category.

OpenAPI Specification

the-news-api-headlines-api-openapi.yml Raw ↑
openapi: 3.0.3
info:
  title: The News All News Headlines API
  description: The News API provides access to worldwide news articles and top stories from over 40,000 sources in 50 countries. Search and filter news by keyword, category, language, country, and date. All endpoints require an API token obtained by registering at thenewsapi.com.
  version: 1.0.0
  contact:
    url: https://www.thenewsapi.com/
  termsOfService: https://www.thenewsapi.com/terms
servers:
- url: https://api.thenewsapi.com/v1
security:
- apiToken: []
tags:
- name: Headlines
  description: Latest headlines organized by category.
paths:
  /news/headlines:
    get:
      operationId: getHeadlines
      summary: Get News Headlines
      description: Retrieve the latest headlines organized by category. Available on Standard plan and above. Returns articles grouped by category with optional similar article suggestions.
      tags:
      - Headlines
      parameters:
      - name: api_token
        in: query
        required: true
        description: Your API authentication token.
        schema:
          type: string
      - name: locale
        in: query
        required: false
        description: Comma-separated list of country codes to filter by (e.g., us,ca,gb).
        schema:
          type: string
      - name: language
        in: query
        required: false
        description: Comma-separated list of language codes to filter by (e.g., en,es,fr).
        schema:
          type: string
      - name: categories
        in: query
        required: false
        description: 'Comma-separated list of categories: general, science, sports, business, health, entertainment, tech, politics, food, travel.'
        schema:
          type: string
      - name: domains
        in: query
        required: false
        description: Comma-separated list of domains to include.
        schema:
          type: string
      - name: exclude_domains
        in: query
        required: false
        description: Comma-separated list of domains to exclude.
        schema:
          type: string
      - name: source_ids
        in: query
        required: false
        description: Comma-separated list of source IDs to include.
        schema:
          type: string
      - name: exclude_source_ids
        in: query
        required: false
        description: Comma-separated list of source IDs to exclude.
        schema:
          type: string
      - name: published_on
        in: query
        required: false
        description: Filter to articles published on a specific date (Y-m-d format).
        schema:
          type: string
          format: date
      - name: headlines_per_category
        in: query
        required: false
        description: Number of articles per category (max 10, default 6).
        schema:
          type: integer
          minimum: 1
          maximum: 10
          default: 6
      - name: include_similar
        in: query
        required: false
        description: Include similar articles in the response (default true).
        schema:
          type: boolean
          default: true
      responses:
        '200':
          description: Headlines organized by category.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HeadlinesResponse'
        '400':
          $ref: '#/components/responses/BadRequest'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '402':
          $ref: '#/components/responses/PaymentRequired'
        '403':
          $ref: '#/components/responses/Forbidden'
        '429':
          $ref: '#/components/responses/RateLimited'
components:
  responses:
    Forbidden:
      description: Forbidden - endpoint access restricted on your plan.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    RateLimited:
      description: Too many requests - rate limit reached (60-second window).
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    Unauthorized:
      description: Unauthorized - invalid API token.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    BadRequest:
      description: Bad request - malformed parameters.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
    PaymentRequired:
      description: Payment required - usage limit reached.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Article:
      type: object
      description: A news article.
      properties:
        uuid:
          type: string
          description: Unique identifier for the article.
        title:
          type: string
          description: Article headline.
        description:
          type: string
          description: Short description of the article.
        keywords:
          type: string
          description: Comma-separated keywords associated with the article.
        snippet:
          type: string
          description: Short excerpt from the article body.
        url:
          type: string
          format: uri
          description: URL to the full article.
        image_url:
          type: string
          format: uri
          description: URL to the article's featured image.
        language:
          type: string
          description: Language code of the article (e.g., en, es, fr).
        published_at:
          type: string
          format: date-time
          description: Publication datetime in UTC.
        source:
          type: string
          description: Domain of the publishing source.
        categories:
          type: array
          items:
            type: string
          description: Categories the article belongs to.
        locale:
          type: string
          description: Country/locale code (e.g., us, gb, ca).
        relevance_score:
          type: number
          nullable: true
          description: Relevance score for search results or similarity matching.
    Error:
      type: object
      properties:
        error:
          type: object
          properties:
            code:
              type: string
              description: Error code.
            message:
              type: string
              description: Human-readable error description.
    ArticleWithSimilar:
      allOf:
      - $ref: '#/components/schemas/Article'
      - type: object
        properties:
          similar:
            type: array
            items:
              $ref: '#/components/schemas/Article'
            description: Similar articles related to this article.
    HeadlinesResponse:
      type: object
      properties:
        data:
          type: object
          description: Articles organized by category.
          properties:
            general:
              type: array
              items:
                $ref: '#/components/schemas/ArticleWithSimilar'
            business:
              type: array
              items:
                $ref: '#/components/schemas/ArticleWithSimilar'
            sports:
              type: array
              items:
                $ref: '#/components/schemas/ArticleWithSimilar'
            tech:
              type: array
              items:
                $ref: '#/components/schemas/ArticleWithSimilar'
            science:
              type: array
              items:
                $ref: '#/components/schemas/ArticleWithSimilar'
            health:
              type: array
              items:
                $ref: '#/components/schemas/ArticleWithSimilar'
            entertainment:
              type: array
              items:
                $ref: '#/components/schemas/ArticleWithSimilar'
            politics:
              type: array
              items:
                $ref: '#/components/schemas/ArticleWithSimilar'
            food:
              type: array
              items:
                $ref: '#/components/schemas/ArticleWithSimilar'
            travel:
              type: array
              items:
                $ref: '#/components/schemas/ArticleWithSimilar'
  securitySchemes:
    apiToken:
      type: apiKey
      name: api_token
      in: query