{
  "openapi": "3.1.0",
  "info": {
    "title": "NewsData.io API",
    "version": "1.0.0",
    "summary": "JSON REST API for newsdata.io — latest news, archive, crypto news, financial-market news, source directory, article counts, and a real-time WebSocket news stream.",
    "description": "REST API returning JSON. Every read endpoint is `GET`; the two state-changing WebSocket management endpoints use `POST` (`/1/websocket/register`) and `DELETE` (`/1/websocket/delete`). All parameters — including for `POST`/`DELETE` — are sent in the query string, never in a request body.\n\n**Authentication.** Send your API key either as the `apikey` query-string parameter or as the `X-ACCESS-KEY` HTTP header. One of the two is required. Parameter names are case-insensitive, except on `/1/websocket/fetch`, `/1/websocket/delete` and the WebSocket stream, which expect them in lowercase.\n\n**Credits & rate limits.** Each call costs a fixed number of API credits (`/latest`, `/crypto`, `/market`, `/sources` = 1 credit; `/archive` = 5 credits; `/count`, `/crypto/count`, `/market/count` = 50 credits; the `/websocket/*` management endpoints are free — instead, each article delivered over the WebSocket stream costs 1 credit per connected device). The response headers `X-RateLimit-Remaining` and `X-API-Limit-Remaining` report your remaining request budget and remaining API credits. If a credit limit is set on an API key, calls made with that key are also refused with `ApiKeyLimitExceeded` once it is used up, and `X-APIKEY-Limit-Remaining` reports the credits left under it.\n\n**Plan-based limits.** Some limits depend on your plan: the number of values allowed per filter (default 5), the maximum search-query length (default 100 characters), and the page size (default 50 on paid plans, 10 on the free plan).\n\n**Filter compatibility.** Some filters cannot be combined: use at most one of `q`, `qInTitle`, `qInMeta`; at most one of `domainurl`, `excludedomainurl`; `country` or `excludecountry`; `category` or `excludecategory`; `language` or `excludelanguage`; `timeframe` or `from_date`/`to_date`. The `id` and `url` filters must be used alone.\n\n**Pagination.** With the default sort (`pubdatedesc` / `pubdateasc`), pass the `nextPage` value from the previous response as the `page` parameter. With `sort=relevancy|source|fetched_at`, pass a page number instead (up to 10,000 results in total).\n\n**Real-time WebSocket stream.** Plans with WebSocket access can register standing queries with `/1/websocket/register` and receive matching articles the moment they are collected by connecting to `wss://ws.newsdata.io/ws/event`. See the *Websocket* endpoints.",
    "termsOfService": "https://newsdata.io/terms",
    "contact": {
      "name": "NewsData.io support",
      "url": "https://newsdata.io/contact",
      "email": "support@newsdata.io"
    },
    "license": {
      "name": "Proprietary",
      "url": "https://newsdata.io/terms"
    }
  },
  "externalDocs": {
    "description": "Official documentation",
    "url": "https://newsdata.io/documentation"
  },
  "servers": [
    {
      "url": "https://newsdata.io/api",
      "description": "Production"
    }
  ],
  "tags": [
    { "name": "News",    "description": "Latest news (`/1/latest`) and historical archive (`/1/archive`)." },
    { "name": "Crypto",  "description": "Cryptocurrency news." },
    { "name": "Market",  "description": "Financial-market news annotated with stock tickers." },
    { "name": "Sources", "description": "Directory of available news sources." },
    { "name": "Count",   "description": "Article counts and time-bucketed histograms." },
    { "name": "Websocket", "description": "Real-time news stream: register standing queries, then receive matching articles over a WebSocket connection the moment they are collected." }
  ],
  "security": [
    { "ApiKeyQuery": [] },
    { "ApiKeyHeader": [] }
  ],
  "paths": {
    "/1/latest": {
      "get": {
        "tags": ["News"],
        "operationId": "getLatest",
        "summary": "Latest news articles",
        "description": "Returns the most recent news articles from the past 48 hours. On the free plan, articles are available with a 12-hour delay. Paid plans can narrow the window with the `timeframe` parameter. This endpoint does not accept `from_date` / `to_date`.\n\nConsumes **1** API credit per call.",
        "parameters": [
          { "$ref": "#/components/parameters/ApiKey" },
          { "$ref": "#/components/parameters/Q" },
          { "$ref": "#/components/parameters/QInTitle" },
          { "$ref": "#/components/parameters/QInMeta" },
          { "$ref": "#/components/parameters/Country" },
          { "$ref": "#/components/parameters/ExcludeCountry" },
          { "$ref": "#/components/parameters/Category" },
          { "$ref": "#/components/parameters/ExcludeCategory" },
          { "$ref": "#/components/parameters/Language" },
          { "$ref": "#/components/parameters/ExcludeLanguage" },
          { "$ref": "#/components/parameters/DomainUrl" },
          { "$ref": "#/components/parameters/ExcludeDomainUrl" },
          { "$ref": "#/components/parameters/PriorityDomain" },
          { "$ref": "#/components/parameters/Id" },
          { "$ref": "#/components/parameters/Url" },
          { "$ref": "#/components/parameters/Timeframe" },
          { "$ref": "#/components/parameters/Timezone" },
          { "$ref": "#/components/parameters/Image" },
          { "$ref": "#/components/parameters/Video" },
          { "$ref": "#/components/parameters/FullContent" },
          { "$ref": "#/components/parameters/RemoveDuplicate" },
          { "$ref": "#/components/parameters/Sentiment" },
          { "$ref": "#/components/parameters/SentimentScore" },
          { "$ref": "#/components/parameters/Tag" },
          { "$ref": "#/components/parameters/Region" },
          { "$ref": "#/components/parameters/Organization" },
          { "$ref": "#/components/parameters/Creator" },
          { "$ref": "#/components/parameters/Datatype" },
          { "$ref": "#/components/parameters/Size" },
          { "$ref": "#/components/parameters/Page" },
          { "$ref": "#/components/parameters/Sort" },
          { "$ref": "#/components/parameters/ExcludeField" }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "headers": {
              "X-API-Limit-Remaining":  { "$ref": "#/components/headers/XApiLimitRemaining" },
              "X-APIKEY-Limit-Remaining": { "$ref": "#/components/headers/XApiKeyLimitRemaining" },
              "X-RateLimit-Remaining":  { "$ref": "#/components/headers/XRateLimitRemaining" }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ArticleListEnvelope" },
                "examples": { "responseShape": { "$ref": "#/components/examples/ArticleListExample" } }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "422": { "$ref": "#/components/responses/UnprocessableEntity" },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/ServerError" },
          "503": { "$ref": "#/components/responses/ServiceUnavailable" }
        }
      }
    },

    "/1/archive": {
      "get": {
        "tags": ["News"],
        "operationId": "getArchive",
        "summary": "Historical news archive",
        "description": "Search past news articles by date range. Available on plans with archive access; how far back you can search depends on your plan. Without `from_date`/`to_date`, your plan's whole history up to now is searched. At least one of the following parameters is required: `q`, `qInTitle`, `qInMeta`, `country`, `category`, `language`, `domainurl`, `prioritydomain`, `id`, `url`, `image`, `video`, `full_content`.\n\nConsumes **5** API credits per call.",
        "parameters": [
          { "$ref": "#/components/parameters/ApiKey" },
          { "$ref": "#/components/parameters/Q" },
          { "$ref": "#/components/parameters/QInTitle" },
          { "$ref": "#/components/parameters/QInMeta" },
          { "$ref": "#/components/parameters/Country" },
          { "$ref": "#/components/parameters/ExcludeCountry" },
          { "$ref": "#/components/parameters/Category" },
          { "$ref": "#/components/parameters/ExcludeCategory" },
          { "$ref": "#/components/parameters/Language" },
          { "$ref": "#/components/parameters/ExcludeLanguage" },
          { "$ref": "#/components/parameters/DomainUrl" },
          { "$ref": "#/components/parameters/ExcludeDomainUrl" },
          { "$ref": "#/components/parameters/PriorityDomain" },
          { "$ref": "#/components/parameters/Id" },
          { "$ref": "#/components/parameters/Url" },
          { "$ref": "#/components/parameters/FromDate" },
          { "$ref": "#/components/parameters/ToDate" },
          { "$ref": "#/components/parameters/Timezone" },
          { "$ref": "#/components/parameters/Image" },
          { "$ref": "#/components/parameters/Video" },
          { "$ref": "#/components/parameters/FullContent" },
          { "$ref": "#/components/parameters/RemoveDuplicate" },
          { "$ref": "#/components/parameters/Sentiment" },
          { "$ref": "#/components/parameters/SentimentScore" },
          { "$ref": "#/components/parameters/Tag" },
          { "$ref": "#/components/parameters/Region" },
          { "$ref": "#/components/parameters/Organization" },
          { "$ref": "#/components/parameters/Creator" },
          { "$ref": "#/components/parameters/Datatype" },
          { "$ref": "#/components/parameters/Size" },
          { "$ref": "#/components/parameters/Page" },
          { "$ref": "#/components/parameters/Sort" },
          { "$ref": "#/components/parameters/ExcludeField" }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "headers": {
              "X-API-Limit-Remaining":  { "$ref": "#/components/headers/XApiLimitRemaining" },
              "X-APIKEY-Limit-Remaining": { "$ref": "#/components/headers/XApiKeyLimitRemaining" },
              "X-RateLimit-Remaining":  { "$ref": "#/components/headers/XRateLimitRemaining" }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/ArticleListEnvelope" },
                "examples": { "responseShape": { "$ref": "#/components/examples/ArticleListExample" } }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "422": { "$ref": "#/components/responses/UnprocessableEntity" },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/ServerError" },
          "503": { "$ref": "#/components/responses/ServiceUnavailable" }
        }
      }
    },

    "/1/crypto": {
      "get": {
        "tags": ["Crypto"],
        "operationId": "getCrypto",
        "summary": "Cryptocurrency news articles",
        "description": "Returns cryptocurrency news articles. Available on plans with crypto access. On the free plan, articles cover the last 7 days with a 12-hour delay, and `from_date`, `to_date`, and `timeframe` cannot be used. On paid plans, use either `from_date`/`to_date` or `timeframe` (not both); without them, your plan's whole history up to now is searched.\n\nConsumes **1** API credit per call.",
        "parameters": [
          { "$ref": "#/components/parameters/ApiKey" },
          { "$ref": "#/components/parameters/Q" },
          { "$ref": "#/components/parameters/QInTitle" },
          { "$ref": "#/components/parameters/QInMeta" },
          { "$ref": "#/components/parameters/Coin" },
          { "$ref": "#/components/parameters/Language" },
          { "$ref": "#/components/parameters/ExcludeLanguage" },
          { "$ref": "#/components/parameters/DomainUrl" },
          { "$ref": "#/components/parameters/ExcludeDomainUrl" },
          { "$ref": "#/components/parameters/PriorityDomain" },
          { "$ref": "#/components/parameters/Id" },
          { "$ref": "#/components/parameters/Url" },
          { "$ref": "#/components/parameters/FromDate" },
          { "$ref": "#/components/parameters/ToDate" },
          { "$ref": "#/components/parameters/Timeframe" },
          { "$ref": "#/components/parameters/Timezone" },
          { "$ref": "#/components/parameters/Image" },
          { "$ref": "#/components/parameters/Video" },
          { "$ref": "#/components/parameters/FullContent" },
          { "$ref": "#/components/parameters/RemoveDuplicate" },
          { "$ref": "#/components/parameters/Sentiment" },
          { "$ref": "#/components/parameters/Tag" },
          { "$ref": "#/components/parameters/Size" },
          { "$ref": "#/components/parameters/Page" },
          { "$ref": "#/components/parameters/SortCrypto" },
          { "$ref": "#/components/parameters/ExcludeField" }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "headers": {
              "X-API-Limit-Remaining":  { "$ref": "#/components/headers/XApiLimitRemaining" },
              "X-APIKEY-Limit-Remaining": { "$ref": "#/components/headers/XApiKeyLimitRemaining" },
              "X-RateLimit-Remaining":  { "$ref": "#/components/headers/XRateLimitRemaining" }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/CryptoArticleListEnvelope" },
                "examples": { "responseShape": { "$ref": "#/components/examples/CryptoArticleListExample" } }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "422": { "$ref": "#/components/responses/UnprocessableEntity" },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/ServerError" },
          "503": { "$ref": "#/components/responses/ServiceUnavailable" }
        }
      }
    },

    "/1/market": {
      "get": {
        "tags": ["Market"],
        "operationId": "getMarket",
        "summary": "Financial-market news articles",
        "description": "Returns financial-market news articles tagged with stock ticker symbols. Available on plans with market access. On the free plan, articles cover the last 7 days with a 12-hour delay, and `from_date`, `to_date`, and `timeframe` cannot be used. On paid plans, use either `from_date`/`to_date` or `timeframe` (not both); when no dates are given, articles from the last 48 hours are returned.\n\nConsumes **1** API credit per call.",
        "parameters": [
          { "$ref": "#/components/parameters/ApiKey" },
          { "$ref": "#/components/parameters/Q" },
          { "$ref": "#/components/parameters/QInTitle" },
          { "$ref": "#/components/parameters/QInMeta" },
          { "$ref": "#/components/parameters/MarketId" },
          { "$ref": "#/components/parameters/Country" },
          { "$ref": "#/components/parameters/ExcludeCountry" },
          { "$ref": "#/components/parameters/Language" },
          { "$ref": "#/components/parameters/ExcludeLanguage" },
          { "$ref": "#/components/parameters/DomainUrl" },
          { "$ref": "#/components/parameters/ExcludeDomainUrl" },
          { "$ref": "#/components/parameters/PriorityDomain" },
          { "$ref": "#/components/parameters/Id" },
          { "$ref": "#/components/parameters/Url" },
          { "$ref": "#/components/parameters/FromDate" },
          { "$ref": "#/components/parameters/ToDate" },
          { "$ref": "#/components/parameters/Timeframe" },
          { "$ref": "#/components/parameters/Timezone" },
          { "$ref": "#/components/parameters/Image" },
          { "$ref": "#/components/parameters/Video" },
          { "$ref": "#/components/parameters/FullContent" },
          { "$ref": "#/components/parameters/RemoveDuplicate" },
          { "$ref": "#/components/parameters/Sentiment" },
          { "$ref": "#/components/parameters/SentimentScore" },
          { "$ref": "#/components/parameters/Tag" },
          { "$ref": "#/components/parameters/Organization" },
          { "$ref": "#/components/parameters/Creator" },
          { "$ref": "#/components/parameters/Datatype" },
          { "$ref": "#/components/parameters/Size" },
          { "$ref": "#/components/parameters/Page" },
          { "$ref": "#/components/parameters/Sort" },
          { "$ref": "#/components/parameters/ExcludeField" }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "headers": {
              "X-API-Limit-Remaining":  { "$ref": "#/components/headers/XApiLimitRemaining" },
              "X-APIKEY-Limit-Remaining": { "$ref": "#/components/headers/XApiKeyLimitRemaining" },
              "X-RateLimit-Remaining":  { "$ref": "#/components/headers/XRateLimitRemaining" }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/MarketArticleListEnvelope" },
                "examples": { "responseShape": { "$ref": "#/components/examples/MarketArticleListExample" } }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "422": { "$ref": "#/components/responses/UnprocessableEntity" },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/ServerError" },
          "503": { "$ref": "#/components/responses/ServiceUnavailable" }
        }
      }
    },

    "/1/sources": {
      "get": {
        "tags": ["Sources"],
        "operationId": "getSources",
        "summary": "News sources",
        "description": "Returns up to 100 news sources matching the filters, chosen and ordered at random.\n\nConsumes **1** API credit per call.",
        "parameters": [
          { "$ref": "#/components/parameters/ApiKey" },
          { "$ref": "#/components/parameters/Country" },
          { "$ref": "#/components/parameters/Category" },
          { "$ref": "#/components/parameters/Language" },
          { "$ref": "#/components/parameters/DomainUrl" },
          { "$ref": "#/components/parameters/PriorityDomain" }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "headers": {
              "X-API-Limit-Remaining":  { "$ref": "#/components/headers/XApiLimitRemaining" },
              "X-APIKEY-Limit-Remaining": { "$ref": "#/components/headers/XApiKeyLimitRemaining" },
              "X-RateLimit-Remaining":  { "$ref": "#/components/headers/XRateLimitRemaining" }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/SourceListEnvelope" },
                "examples": { "responseShape": { "$ref": "#/components/examples/SourceListExample" } }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "422": { "$ref": "#/components/responses/UnprocessableEntity" },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/ServerError" },
          "503": { "$ref": "#/components/responses/ServiceUnavailable" }
        }
      }
    },

    "/1/count": {
      "get": {
        "tags": ["Count"],
        "operationId": "getCount",
        "summary": "News article count",
        "description": "Returns the number of news articles matching the filters. With `interval=all` (default) a single total is returned; with `interval=hour` or `interval=day` a count-per-hour/day breakdown is returned. `from_date` and `to_date` are required, and at least one of the following parameters as well: `q`, `qInTitle`, `qInMeta`, `country`, `category`, `language`, `domainurl`, `prioritydomain`, `image`, `video`, `full_content`. Available on plans with count access.\n\nConsumes **50** API credits per call.",
        "parameters": [
          { "$ref": "#/components/parameters/ApiKey" },
          { "$ref": "#/components/parameters/Q" },
          { "$ref": "#/components/parameters/QInTitle" },
          { "$ref": "#/components/parameters/QInMeta" },
          { "$ref": "#/components/parameters/Country" },
          { "$ref": "#/components/parameters/ExcludeCountry" },
          { "$ref": "#/components/parameters/Category" },
          { "$ref": "#/components/parameters/ExcludeCategory" },
          { "$ref": "#/components/parameters/Language" },
          { "$ref": "#/components/parameters/ExcludeLanguage" },
          { "$ref": "#/components/parameters/DomainUrl" },
          { "$ref": "#/components/parameters/ExcludeDomainUrl" },
          { "$ref": "#/components/parameters/PriorityDomain" },
          { "$ref": "#/components/parameters/FromDateCount" },
          { "$ref": "#/components/parameters/ToDateCount" },
          { "$ref": "#/components/parameters/Image" },
          { "$ref": "#/components/parameters/Video" },
          { "$ref": "#/components/parameters/FullContent" },
          { "$ref": "#/components/parameters/RemoveDuplicate" },
          { "$ref": "#/components/parameters/Sentiment" },
          { "$ref": "#/components/parameters/SentimentScore" },
          { "$ref": "#/components/parameters/Tag" },
          { "$ref": "#/components/parameters/Region" },
          { "$ref": "#/components/parameters/Organization" },
          { "$ref": "#/components/parameters/Creator" },
          { "$ref": "#/components/parameters/Datatype" },
          { "$ref": "#/components/parameters/Interval" },
          { "$ref": "#/components/parameters/SizeCount" },
          { "$ref": "#/components/parameters/PageCount" },
          { "$ref": "#/components/parameters/SortCount" }
        ],
        "responses": {
          "200": {
            "description": "Success. The shape depends on the `interval` parameter.",
            "headers": {
              "X-API-Limit-Remaining":  { "$ref": "#/components/headers/XApiLimitRemaining" },
              "X-APIKEY-Limit-Remaining": { "$ref": "#/components/headers/XApiKeyLimitRemaining" },
              "X-RateLimit-Remaining":  { "$ref": "#/components/headers/XRateLimitRemaining" }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    { "$ref": "#/components/schemas/CountSummaryEnvelope" },
                    { "$ref": "#/components/schemas/CountHistogramEnvelope" }
                  ]
                },
                "examples": {
                  "intervalAll": { "$ref": "#/components/examples/CountSummaryExample" },
                  "intervalHourOrDay": { "$ref": "#/components/examples/CountHistogramExample" }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "422": { "$ref": "#/components/responses/UnprocessableEntity" },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/ServerError" },
          "503": { "$ref": "#/components/responses/ServiceUnavailable" }
        }
      }
    },

    "/1/crypto/count": {
      "get": {
        "tags": ["Count"],
        "operationId": "getCryptoCount",
        "summary": "Cryptocurrency article count",
        "description": "Returns the number of cryptocurrency news articles matching the filters. With `interval=all` (default) a single total is returned; with `interval=hour` or `interval=day` a count-per-hour/day breakdown is returned. `from_date` and `to_date` are required. Available on plans with count access.\n\nConsumes **50** API credits per call.",
        "parameters": [
          { "$ref": "#/components/parameters/ApiKey" },
          { "$ref": "#/components/parameters/Q" },
          { "$ref": "#/components/parameters/QInTitle" },
          { "$ref": "#/components/parameters/QInMeta" },
          { "$ref": "#/components/parameters/Coin" },
          { "$ref": "#/components/parameters/Language" },
          { "$ref": "#/components/parameters/ExcludeLanguage" },
          { "$ref": "#/components/parameters/DomainUrl" },
          { "$ref": "#/components/parameters/ExcludeDomainUrl" },
          { "$ref": "#/components/parameters/PriorityDomain" },
          { "$ref": "#/components/parameters/FromDateCount" },
          { "$ref": "#/components/parameters/ToDateCount" },
          { "$ref": "#/components/parameters/Image" },
          { "$ref": "#/components/parameters/Video" },
          { "$ref": "#/components/parameters/FullContent" },
          { "$ref": "#/components/parameters/RemoveDuplicate" },
          { "$ref": "#/components/parameters/Sentiment" },
          { "$ref": "#/components/parameters/Tag" },
          { "$ref": "#/components/parameters/Interval" },
          { "$ref": "#/components/parameters/SizeCount" },
          { "$ref": "#/components/parameters/PageCount" },
          { "$ref": "#/components/parameters/SortCount" }
        ],
        "responses": {
          "200": {
            "description": "Success. The shape depends on the `interval` parameter.",
            "headers": {
              "X-API-Limit-Remaining":  { "$ref": "#/components/headers/XApiLimitRemaining" },
              "X-APIKEY-Limit-Remaining": { "$ref": "#/components/headers/XApiKeyLimitRemaining" },
              "X-RateLimit-Remaining":  { "$ref": "#/components/headers/XRateLimitRemaining" }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    { "$ref": "#/components/schemas/CountSummaryEnvelope" },
                    { "$ref": "#/components/schemas/CountHistogramEnvelope" }
                  ]
                },
                "examples": {
                  "intervalAll": { "$ref": "#/components/examples/CountSummaryExample" },
                  "intervalHourOrDay": { "$ref": "#/components/examples/CountHistogramExample" }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "422": { "$ref": "#/components/responses/UnprocessableEntity" },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/ServerError" },
          "503": { "$ref": "#/components/responses/ServiceUnavailable" }
        }
      }
    },

    "/1/market/count": {
      "get": {
        "tags": ["Count"],
        "operationId": "getMarketCount",
        "summary": "Financial-market article count",
        "description": "Returns the number of financial-market news articles matching the filters. With `interval=all` (default) a single total is returned; with `interval=hour` or `interval=day` a count-per-hour/day breakdown is returned. `from_date` and `to_date` are required. Available on plans with count access.\n\nConsumes **50** API credits per call.",
        "parameters": [
          { "$ref": "#/components/parameters/ApiKey" },
          { "$ref": "#/components/parameters/Q" },
          { "$ref": "#/components/parameters/QInTitle" },
          { "$ref": "#/components/parameters/QInMeta" },
          { "$ref": "#/components/parameters/MarketId" },
          { "$ref": "#/components/parameters/Country" },
          { "$ref": "#/components/parameters/ExcludeCountry" },
          { "$ref": "#/components/parameters/Language" },
          { "$ref": "#/components/parameters/ExcludeLanguage" },
          { "$ref": "#/components/parameters/DomainUrl" },
          { "$ref": "#/components/parameters/ExcludeDomainUrl" },
          { "$ref": "#/components/parameters/PriorityDomain" },
          { "$ref": "#/components/parameters/FromDateCount" },
          { "$ref": "#/components/parameters/ToDateCount" },
          { "$ref": "#/components/parameters/Image" },
          { "$ref": "#/components/parameters/Video" },
          { "$ref": "#/components/parameters/FullContent" },
          { "$ref": "#/components/parameters/RemoveDuplicate" },
          { "$ref": "#/components/parameters/Sentiment" },
          { "$ref": "#/components/parameters/SentimentScore" },
          { "$ref": "#/components/parameters/Tag" },
          { "$ref": "#/components/parameters/Organization" },
          { "$ref": "#/components/parameters/Creator" },
          { "$ref": "#/components/parameters/Datatype" },
          { "$ref": "#/components/parameters/Interval" },
          { "$ref": "#/components/parameters/SizeCount" },
          { "$ref": "#/components/parameters/PageCount" },
          { "$ref": "#/components/parameters/SortCount" }
        ],
        "responses": {
          "200": {
            "description": "Success. The shape depends on the `interval` parameter.",
            "headers": {
              "X-API-Limit-Remaining":  { "$ref": "#/components/headers/XApiLimitRemaining" },
              "X-APIKEY-Limit-Remaining": { "$ref": "#/components/headers/XApiKeyLimitRemaining" },
              "X-RateLimit-Remaining":  { "$ref": "#/components/headers/XRateLimitRemaining" }
            },
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    { "$ref": "#/components/schemas/CountSummaryEnvelope" },
                    { "$ref": "#/components/schemas/CountHistogramEnvelope" }
                  ]
                },
                "examples": {
                  "intervalAll": { "$ref": "#/components/examples/CountSummaryExample" },
                  "intervalHourOrDay": { "$ref": "#/components/examples/CountHistogramExample" }
                }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "422": { "$ref": "#/components/responses/UnprocessableEntity" },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/ServerError" },
          "503": { "$ref": "#/components/responses/ServiceUnavailable" }
        }
      }
    },

    "/1/websocket/register": {
      "post": {
        "tags": ["Websocket"],
        "operationId": "registerWebsocketQuery",
        "summary": "Register a real-time query",
        "description": "Registers a standing query for the real-time WebSocket stream and returns its `registration_id`. Use that id to connect to the stream at `wss://ws.newsdata.io/ws/event` and to manage the registration with `/1/websocket/fetch` and `/1/websocket/delete`. Available on plans with WebSocket access.\n\nAt least one of the following parameters is required: `q`, `qInTitle`, `qInMeta`, `country`, `category`, `language`, `domainurl`, `prioritydomain`, `image`, `video`, `full_content`. Registering the exact same set of parameters again returns **409** with the existing `registration_id`. Each account can keep a limited number of active registrations at a time (set by your plan); requests beyond the limit return **429**. Registrations that no client has connected to for 30 days are deleted automatically, as are all registrations of an account that loses WebSocket access.\n\nRegistering consumes no API credits, but requires at least 1 API credit remaining. Each article later delivered over the WebSocket stream consumes **1** API credit per connected device.",
        "parameters": [
          { "$ref": "#/components/parameters/ApiKey" },
          { "$ref": "#/components/parameters/Q" },
          { "$ref": "#/components/parameters/QInTitle" },
          { "$ref": "#/components/parameters/QInMeta" },
          { "$ref": "#/components/parameters/Country" },
          { "$ref": "#/components/parameters/ExcludeCountry" },
          { "$ref": "#/components/parameters/Category" },
          { "$ref": "#/components/parameters/ExcludeCategory" },
          { "$ref": "#/components/parameters/Language" },
          { "$ref": "#/components/parameters/ExcludeLanguage" },
          { "$ref": "#/components/parameters/DomainUrl" },
          { "$ref": "#/components/parameters/ExcludeDomainUrl" },
          { "$ref": "#/components/parameters/PriorityDomain" },
          { "$ref": "#/components/parameters/Timezone" },
          { "$ref": "#/components/parameters/Image" },
          { "$ref": "#/components/parameters/Video" },
          { "$ref": "#/components/parameters/FullContent" },
          { "$ref": "#/components/parameters/RemoveDuplicate" },
          { "$ref": "#/components/parameters/Sentiment" },
          { "$ref": "#/components/parameters/SentimentScore" },
          { "$ref": "#/components/parameters/Tag" },
          { "$ref": "#/components/parameters/Region" },
          { "$ref": "#/components/parameters/Organization" },
          { "$ref": "#/components/parameters/Creator" },
          { "$ref": "#/components/parameters/Datatype" },
          { "$ref": "#/components/parameters/ExcludeField" }
        ],
        "responses": {
          "200": {
            "description": "Query registered.",
            "headers": {
              "X-API-Limit-Remaining":  { "$ref": "#/components/headers/XApiLimitRemaining" },
              "X-APIKEY-Limit-Remaining": { "$ref": "#/components/headers/XApiKeyLimitRemaining" }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/WebsocketRegisterEnvelope" },
                "examples": { "responseShape": { "$ref": "#/components/examples/WebsocketRegisterExample" } }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "409": { "$ref": "#/components/responses/Conflict" },
          "422": { "$ref": "#/components/responses/UnprocessableEntity" },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/ServerError" },
          "503": { "$ref": "#/components/responses/ServiceUnavailable" }
        }
      }
    },

    "/1/websocket/fetch": {
      "get": {
        "tags": ["Websocket"],
        "operationId": "getWebsocketQueries",
        "summary": "List registered real-time queries",
        "description": "Returns every active WebSocket query registration of your account (`totalQueries` carries the count), each with its `registration_id`, `active_clients` — the number of devices currently connected to the stream for it, `last_used` — when a client last connected to it, its `news_type`, and `query` — the parameters it was registered with (parameter names in lowercase). Available on plans with WebSocket access.\n\nThe API key must be sent as the `apikey` query parameter — the `X-ACCESS-KEY` header is not supported on this endpoint. Consumes no API credits.",
        "security": [ { "ApiKeyQuery": [] } ],
        "parameters": [
          { "$ref": "#/components/parameters/ApiKeyQueryOnly" }
        ],
        "responses": {
          "200": {
            "description": "Success.",
            "headers": {
              "X-API-Limit-Remaining":  { "$ref": "#/components/headers/XApiLimitRemaining" },
              "X-APIKEY-Limit-Remaining": { "$ref": "#/components/headers/XApiKeyLimitRemaining" }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/WebsocketQueryListEnvelope" },
                "examples": { "responseShape": { "$ref": "#/components/examples/WebsocketQueryListExample" } }
              }
            }
          },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/ServerError" }
        }
      }
    },

    "/1/websocket/delete": {
      "delete": {
        "tags": ["Websocket"],
        "operationId": "deleteWebsocketQuery",
        "summary": "Delete a registered real-time query",
        "description": "Deletes one WebSocket query registration by its `registration_id`; articles stop being delivered for it. Available on plans with WebSocket access.\n\nThe API key must be sent as the `apikey` query parameter — the `X-ACCESS-KEY` header is not supported on this endpoint. Consumes no API credits.",
        "security": [ { "ApiKeyQuery": [] } ],
        "parameters": [
          { "$ref": "#/components/parameters/ApiKeyQueryOnly" },
          { "$ref": "#/components/parameters/RegistrationId" }
        ],
        "responses": {
          "200": {
            "description": "Registration deleted.",
            "headers": {
              "X-API-Limit-Remaining":  { "$ref": "#/components/headers/XApiLimitRemaining" },
              "X-APIKEY-Limit-Remaining": { "$ref": "#/components/headers/XApiKeyLimitRemaining" }
            },
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/WebsocketDeleteEnvelope" },
                "examples": { "responseShape": { "$ref": "#/components/examples/WebsocketDeleteExample" } }
              }
            }
          },
          "400": { "$ref": "#/components/responses/BadRequest" },
          "401": { "$ref": "#/components/responses/Unauthorized" },
          "403": { "$ref": "#/components/responses/Forbidden" },
          "404": { "$ref": "#/components/responses/NotFound" },
          "429": { "$ref": "#/components/responses/TooManyRequests" },
          "500": { "$ref": "#/components/responses/ServerError" }
        }
      }
    },

    "/ws/event": {
      "servers": [
        { "url": "wss://ws.newsdata.io", "description": "Production WebSocket server" }
      ],
      "get": {
        "tags": ["Websocket"],
        "operationId": "connectWebsocketStream",
        "summary": "Real-time news stream (WebSocket)",
        "description": "WebSocket endpoint — described here as its HTTP handshake because OpenAPI cannot model WebSocket traffic. Connect with a WebSocket client:\n\n`wss://ws.newsdata.io/ws/event?apikey=YOUR_API_KEY&registration_id=YOUR_REGISTRATION_ID`\n\nWhenever newly collected articles match the registered query, the server pushes one JSON message per batch: `{\"status\": \"success\", \"totalResults\": N, \"results\": [ ... ]}`, where each result is an article in the same shape as `/1/latest` results. Fields listed in the registration's `excludefield` are left out, and `pubDate`/`fetched_at` are rendered in the registration's `timezone` (UTC otherwise; `pubDateTZ` names the zone). Client-to-server messages are ignored — the socket is receive-only.\n\nThe handshake is rejected with HTTP **403** when `apikey` or `registration_id` is missing or not 30–40 characters long, when they don't match an active registration of an account with WebSocket access, or when the account has no API credits left. A connection beyond the allowed simultaneous devices per `registration_id` (default 5) is accepted and then closed with WebSocket close code `1008` (`device limit reached`). Each delivered article consumes **1** API credit per connected device; when the credits run out, open connections are closed with code `1008` (`api limit reached`). Open connections whose API key, registration or WebSocket access is removed are closed with code `1008` (`invalid credentials or registration not found`). A client that reads too slowly is disconnected with code `1013` (`send timeout`).",
        "security": [ { "ApiKeyQuery": [] } ],
        "parameters": [
          { "$ref": "#/components/parameters/ApiKeyQueryOnly" },
          { "$ref": "#/components/parameters/RegistrationId" }
        ],
        "responses": {
          "101": {
            "description": "WebSocket connection established. The schema below describes the JSON messages subsequently pushed over the socket (a `101` response itself has no body).",
            "content": {
              "application/json": {
                "schema": { "$ref": "#/components/schemas/WebsocketNewsMessage" },
                "examples": { "messageShape": { "$ref": "#/components/examples/WebsocketNewsMessageExample" } }
              }
            }
          },
          "403": {
            "description": "Handshake rejected: `apikey` or `registration_id` is missing or malformed, they don't match an active registration of an account with WebSocket access, or the account has no API credits left. The response has no body."
          }
        }
      }
    }
  },

  "components": {
    "securitySchemes": {
      "ApiKeyQuery": {
        "type": "apiKey",
        "in": "query",
        "name": "apikey",
        "description": "API key passed as a query-string parameter."
      },
      "ApiKeyHeader": {
        "type": "apiKey",
        "in": "header",
        "name": "X-ACCESS-KEY",
        "description": "API key passed as an HTTP header. Used when `apikey` is not supplied in the query string."
      }
    },

    "parameters": {
      "ApiKey": {
        "name": "apikey",
        "in": "query",
        "required": false,
        "description": "Your API key. Alternatively send it in the `X-ACCESS-KEY` HTTP header. One of the two MUST be present.",
        "schema": { "type": "string" },
        "examples": { "default": { "value": "pub_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" } }
      },
      "Q": {
        "name": "q",
        "in": "query",
        "required": false,
        "description": "Search articles by keywords or phrases (matches title, description, content, keywords, and URL). All words must match unless joined with `OR`; supports the `AND`, `OR` and `NOT` operators, quoted phrases and parentheses. Characters such as `*`, `?`, `+`, `-`, `:` and `/` have no special meaning (no wildcards). A query with invalid syntax, e.g. unbalanced quotes or parentheses, returns 400 `MalformedQuery`. Maximum length depends on your plan (default 100 characters). Use only one of `q`, `qInTitle`, `qInMeta`.",
        "schema": { "type": "string", "maxLength": 100 },
        "examples": {
          "keyword": { "value": "elections" },
          "operator": { "value": "elections AND results" }
        }
      },
      "QInTitle": {
        "name": "qInTitle",
        "in": "query",
        "required": false,
        "description": "Search articles by keywords in the title only, with the same syntax as `q`. Maximum length depends on your plan (default 100 characters). Use only one of `q`, `qInTitle`, `qInMeta`.",
        "schema": { "type": "string", "maxLength": 100 }
      },
      "QInMeta": {
        "name": "qInMeta",
        "in": "query",
        "required": false,
        "description": "Search articles by keywords in the title, description, keywords, and URL, with the same syntax as `q`. Maximum length depends on your plan (default 100 characters). Use only one of `q`, `qInTitle`, `qInMeta`.",
        "schema": { "type": "string", "maxLength": 100 }
      },
      "Country": {
        "name": "country",
        "in": "query",
        "required": false,
        "description": "Filter by country. Comma-separated ISO 3166-1 alpha-2 country codes or country names (e.g. `in` or `india`), up to your plan's filter limit (default 5). Cannot be combined with `excludecountry`.",
        "explode": false,
        "style": "form",
        "schema": { "type": "array", "items": { "type": "string" }, "maxItems": 5 },
        "examples": {
          "single": { "value": "us" },
          "multiple": { "value": "us,gb,in" }
        }
      },
      "ExcludeCountry": {
        "name": "excludecountry",
        "in": "query",
        "required": false,
        "description": "Exclude countries. Comma-separated ISO country codes or country names (e.g. `in` or `india`), up to your plan's filter limit (default 5). Cannot be combined with `country`.",
        "explode": false,
        "style": "form",
        "schema": { "type": "array", "items": { "type": "string" }, "maxItems": 5 }
      },
      "Category": {
        "name": "category",
        "in": "query",
        "required": false,
        "description": "Filter by category. Comma-separated category names, up to your plan's filter limit (default 5). Cannot be combined with `excludecategory`.",
        "explode": false,
        "style": "form",
        "schema": { "type": "array", "items": { "type": "string" }, "maxItems": 5 },
        "examples": { "default": { "value": "business,technology" } }
      },
      "ExcludeCategory": {
        "name": "excludecategory",
        "in": "query",
        "required": false,
        "description": "Exclude categories. Comma-separated category names, up to your plan's filter limit (default 5). Cannot be combined with `category`.",
        "explode": false,
        "style": "form",
        "schema": { "type": "array", "items": { "type": "string" }, "maxItems": 5 }
      },
      "Language": {
        "name": "language",
        "in": "query",
        "required": false,
        "description": "Filter by language. Comma-separated ISO 639-1 language codes or language names (e.g. `en` or `english`), up to your plan's filter limit (default 5). Cannot be combined with `excludelanguage`.",
        "explode": false,
        "style": "form",
        "schema": { "type": "array", "items": { "type": "string" }, "maxItems": 5 },
        "examples": { "default": { "value": "en,hi" } }
      },
      "ExcludeLanguage": {
        "name": "excludelanguage",
        "in": "query",
        "required": false,
        "description": "Exclude languages. Comma-separated language codes or language names (e.g. `en` or `english`), up to your plan's filter limit (default 5). Cannot be combined with `language`.",
        "explode": false,
        "style": "form",
        "schema": { "type": "array", "items": { "type": "string" }, "maxItems": 5 }
      },
      "DomainUrl": {
        "name": "domainurl",
        "in": "query",
        "required": false,
        "description": "Filter by news source URL. Use the source's exact URL: host plus path, e.g. `bbc.com`, `vice.com/de`, `fr.investing.com` (scheme, `www.` and a trailing `/` are optional). A value that doesn't match a source exactly returns 422 with the matching source URLs under `recommendations`. Comma-separated, up to your plan's filter limit (default 5). Cannot be combined with `excludedomainurl`.",
        "explode": false,
        "style": "form",
        "schema": { "type": "array", "items": { "type": "string" }, "maxItems": 5 },
        "examples": { "default": { "value": "bbc.com,cnn.com" } }
      },
      "ExcludeDomainUrl": {
        "name": "excludedomainurl",
        "in": "query",
        "required": false,
        "description": "Exclude news sources by URL. Use the source's exact URL: host plus path, e.g. `bbc.com`, `vice.com/de`, `fr.investing.com` (scheme, `www.` and a trailing `/` are optional). A value that doesn't match a source exactly returns 422 with the matching source URLs under `recommendations`. Comma-separated, up to your plan's filter limit (default 5). Cannot be combined with `domainurl`.",
        "explode": false,
        "style": "form",
        "schema": { "type": "array", "items": { "type": "string" }, "maxItems": 5 }
      },
      "PriorityDomain": {
        "name": "prioritydomain",
        "in": "query",
        "required": false,
        "description": "Restrict results to news sources by rank (quality and popularity): `top` keeps only the highest-ranked sources, `medium` adds mid-ranked sources, and `low` adds lower-ranked sources as well.",
        "schema": { "type": "string", "enum": ["top", "medium", "low"] }
      },
      "Id": {
        "name": "id",
        "in": "query",
        "required": false,
        "description": "Fetch specific articles by their `article_id`. Comma-separated, up to your plan's page-size limit (default 50 paid, 10 free). Must be used alone — cannot be combined with any other filter.",
        "explode": false,
        "style": "form",
        "schema": { "type": "array", "items": { "type": "string", "minLength": 32, "maxLength": 32 }, "maxItems": 50 }
      },
      "Url": {
        "name": "url",
        "in": "query",
        "required": false,
        "description": "Fetch a single article by its URL. Send the full URL, including `http://` or `https://` (otherwise 422 `MalformedUrl`); tracking parameters such as `utm_*` are ignored. Maximum length 512. Must be used alone — cannot be combined with any other filter.",
        "schema": { "type": "string", "format": "uri", "maxLength": 512 }
      },
      "FromDate": {
        "name": "from_date",
        "in": "query",
        "required": false,
        "description": "Get articles published on or after this date. Format `YYYY-MM-DD` (from 00:00:00) or `YYYY-MM-DD HH:MM:SS`, in UTC. Cannot be a future date or later than `to_date`. How far back you can search depends on your plan; an older date returns 403. Cannot be combined with `timeframe`.",
        "schema": { "type": "string" },
        "examples": {
          "date": { "value": "2026-05-01" },
          "dateTime": { "value": "2026-05-01 06:00:00" }
        }
      },
      "ToDate": {
        "name": "to_date",
        "in": "query",
        "required": false,
        "description": "Get articles published on or before this date. Format `YYYY-MM-DD` (up to 23:59:59 of that day, or up to now for today) or `YYYY-MM-DD HH:MM:SS`, in UTC. Cannot be a future date. Cannot be combined with `timeframe`.",
        "schema": { "type": "string" },
        "examples": {
          "date": { "value": "2026-05-31" },
          "dateTime": { "value": "2026-05-31 18:00:00" }
        }
      },
      "Timeframe": {
        "name": "timeframe",
        "in": "query",
        "required": false,
        "description": "Get articles from the last N hours or minutes. A plain number means hours (1-48); add an `m` suffix for minutes (1-2880), e.g. `15m`. Paid plans only. Cannot be combined with `from_date`/`to_date`.",
        "schema": { "type": "string", "pattern": "^[0-9]+[mM]?$" },
        "examples": {
          "hours": { "value": "24" },
          "minutes": { "value": "15m" }
        }
      },
      "Timezone": {
        "name": "timezone",
        "in": "query",
        "required": false,
        "description": "Show `pubDate` and `fetched_at` in this timezone (IANA name, e.g. `Asia/Kolkata`). Defaults to `UTC`. It does not change how `from_date`/`to_date` are read; those are always UTC.",
        "schema": { "type": "string", "default": "UTC" },
        "examples": { "default": { "value": "Asia/Kolkata" } }
      },
      "Image": {
        "name": "image",
        "in": "query",
        "required": false,
        "description": "Set to `1` to return only articles that include an image, or `0` to return the `image_url` field as `null`.",
        "schema": { "type": "string", "enum": ["0", "1"] }
      },
      "Video": {
        "name": "video",
        "in": "query",
        "required": false,
        "description": "Set to `1` to return only articles that include a video, or `0` to return the `video_url` field as `null`.",
        "schema": { "type": "string", "enum": ["0", "1"] }
      },
      "FullContent": {
        "name": "full_content",
        "in": "query",
        "required": false,
        "description": "Set to `1` to return only articles that include full content, or `0` to return the `content` field as `null`. Available on plans with full-content access, where `content` is included by default.",
        "schema": { "type": "string", "enum": ["0", "1"] }
      },
      "RemoveDuplicate": {
        "name": "removeduplicate",
        "in": "query",
        "required": false,
        "description": "Set to `1` to exclude duplicate articles.",
        "schema": { "type": "string", "enum": ["0", "1"] }
      },
      "Sentiment": {
        "name": "sentiment",
        "in": "query",
        "required": false,
        "description": "Filter articles by sentiment.",
        "schema": { "type": "string", "enum": ["positive", "neutral", "negative"] }
      },
      "SentimentScore": {
        "name": "sentiment_score",
        "in": "query",
        "required": false,
        "description": "Minimum sentiment confidence (1-100) for the chosen `sentiment`. Requires the `sentiment` parameter.",
        "schema": { "type": "number", "minimum": 1, "maximum": 100 }
      },
      "Tag": {
        "name": "tag",
        "in": "query",
        "required": false,
        "description": "Filter by AI-classified topic tags (e.g. `politics,technology`; the crypto endpoints use the crypto tag set, e.g. `blockchain,mining`). Comma-separated, up to your plan's filter limit (default 5).",
        "explode": false,
        "style": "form",
        "schema": { "type": "array", "items": { "type": "string" }, "maxItems": 5 }
      },
      "Region": {
        "name": "region",
        "in": "query",
        "required": false,
        "description": "Filter by AI-extracted geographic region. Join sub-regions with `-` to require them together (e.g. `paris-france`). Comma-separated, up to your plan's filter limit (default 5). Available on Corporate plans.",
        "explode": false,
        "style": "form",
        "schema": { "type": "array", "items": { "type": "string" }, "maxItems": 5 }
      },
      "Organization": {
        "name": "organization",
        "in": "query",
        "required": false,
        "description": "Filter by AI-extracted organization names. Comma-separated, up to your plan's filter limit (default 5). Available on Corporate plans.",
        "explode": false,
        "style": "form",
        "schema": { "type": "array", "items": { "type": "string" }, "maxItems": 5 }
      },
      "Creator": {
        "name": "creator",
        "in": "query",
        "required": false,
        "description": "Filter by article author / byline. Comma-separated, up to your plan's filter limit (default 5); all values together can be at most your plan's maximum query length (default 100 characters).",
        "explode": false,
        "style": "form",
        "schema": { "type": "array", "items": { "type": "string" }, "maxItems": 5 }
      },
      "Datatype": {
        "name": "datatype",
        "in": "query",
        "required": false,
        "description": "Filter by content type, e.g. `news`, `blog`, `podcast`. Comma-separated, up to your plan's filter limit (default 5).",
        "explode": false,
        "style": "form",
        "schema": { "type": "array", "items": { "type": "string" }, "maxItems": 5 }
      },
      "Size": {
        "name": "size",
        "in": "query",
        "required": false,
        "description": "Number of articles per page: 1 to 50 on paid plans, 1 to 10 on the free plan. Defaults to your plan's maximum.",
        "schema": { "type": "integer", "minimum": 1, "maximum": 50 }
      },
      "Page": {
        "name": "page",
        "in": "query",
        "required": false,
        "description": "Pagination. With the default sort, pass the `nextPage` value from the previous response. With `sort=relevancy|source|fetched_at`, pass a page number instead.",
        "schema": { "type": "string" },
        "examples": {
          "cursor": { "value": "1749547200000000000" },
          "pageNumber": { "value": "2" }
        }
      },
      "Sort": {
        "name": "sort",
        "in": "query",
        "required": false,
        "description": "Result ordering: `pubdatedesc` (default, newest first), `pubdateasc`, `relevancy` (requires `q`/`qInTitle`/`qInMeta`), `source` (highest-ranked sources first), or `fetched_at` (most recently collected first). `relevancy`, `source`, and `fetched_at` are limited to the first 10,000 results. `fetched_at` is available on `/latest`, `/archive`, and `/market` only.",
        "schema": {
          "type": "string",
          "enum": ["pubdatedesc", "pubdateasc", "relevancy", "source", "fetched_at"],
          "default": "pubdatedesc"
        }
      },
      "ExcludeField": {
        "name": "excludefield",
        "in": "query",
        "required": false,
        "description": "Comma-separated list of response fields to leave out of each article. `article_id` cannot be excluded.",
        "explode": false,
        "style": "form",
        "schema": { "type": "array", "items": { "type": "string" } },
        "examples": { "default": { "value": "content,keywords" } }
      },
      "Coin": {
        "name": "coin",
        "in": "query",
        "required": false,
        "description": "Filter by cryptocurrency. Comma-separated coin ticker symbols, up to your plan's filter limit (default 5).",
        "explode": false,
        "style": "form",
        "schema": { "type": "array", "items": { "type": "string" }, "maxItems": 5 },
        "examples": { "default": { "value": "btc,eth" } }
      },
      "SortCrypto": {
        "name": "sort",
        "in": "query",
        "required": false,
        "description": "Result ordering: `pubdatedesc` (default, newest first), `pubdateasc`, `relevancy` (requires `q`/`qInTitle`/`qInMeta`), or `source` (highest-ranked sources first). `relevancy` and `source` are limited to the first 10,000 results.",
        "schema": {
          "type": "string",
          "enum": ["pubdatedesc", "pubdateasc", "relevancy", "source"],
          "default": "pubdatedesc"
        }
      },
      "MarketId": {
        "name": "market_id",
        "in": "query",
        "required": false,
        "description": "Filter by market identifier (`market_id`, the unique symbol id). Comma-separated, up to your plan's filter limit (default 5).",
        "explode": false,
        "style": "form",
        "schema": { "type": "array", "items": { "type": "string" }, "maxItems": 5 },
        "examples": { "default": { "value": "aapl-us-vy,msft-us-vy" } }
      },
      "FromDateCount": {
        "name": "from_date",
        "in": "query",
        "required": true,
        "description": "Count articles published on or after this date. Format `YYYY-MM-DD` (from 00:00:00) or `YYYY-MM-DD HH:MM:SS`, in UTC. Cannot be a future date or later than `to_date`. How far back you can go depends on your plan; an older date returns 403.",
        "schema": { "type": "string" },
        "examples": {
          "date": { "value": "2026-05-01" },
          "dateTime": { "value": "2026-05-01 06:00:00" }
        }
      },
      "ToDateCount": {
        "name": "to_date",
        "in": "query",
        "required": true,
        "description": "Count articles published on or before this date. Format `YYYY-MM-DD` (up to 23:59:59 of that day, or up to now for today) or `YYYY-MM-DD HH:MM:SS`, in UTC. Cannot be a future date.",
        "schema": { "type": "string" },
        "examples": {
          "date": { "value": "2026-05-31" },
          "dateTime": { "value": "2026-05-31 18:00:00" }
        }
      },
      "Interval": {
        "name": "interval",
        "in": "query",
        "required": false,
        "description": "How to count: `all` (default) returns a single total; `hour` or `day` returns a count-per-hour or count-per-day breakdown.",
        "schema": { "type": "string", "enum": ["all", "hour", "day"], "default": "all" }
      },
      "SizeCount": {
        "name": "size",
        "in": "query",
        "required": false,
        "description": "Number of histogram entries per page when `interval=hour` or `day`: 1 to 50 on paid plans, 1 to 10 on the free plan.",
        "schema": { "type": "integer", "minimum": 1, "maximum": 50 }
      },
      "PageCount": {
        "name": "page",
        "in": "query",
        "required": false,
        "description": "Pagination for the histogram. Pass the `nextPage` value from the previous response.",
        "schema": { "type": "string" }
      },
      "SortCount": {
        "name": "sort",
        "in": "query",
        "required": false,
        "description": "Ordering of the histogram: `pubdatedesc` (default, newest first) or `pubdateasc`.",
        "schema": { "type": "string", "enum": ["pubdatedesc", "pubdateasc"], "default": "pubdatedesc" }
      },
      "ApiKeyQueryOnly": {
        "name": "apikey",
        "in": "query",
        "required": true,
        "description": "Your API key, passed as a query-string parameter. This endpoint does not accept the `X-ACCESS-KEY` header.",
        "schema": { "type": "string" },
        "examples": { "default": { "value": "pub_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" } }
      },
      "RegistrationId": {
        "name": "registration_id",
        "in": "query",
        "required": true,
        "description": "The `registration_id` returned by `/1/websocket/register` (32-character identifier).",
        "schema": { "type": "string", "minLength": 32, "maxLength": 32 },
        "examples": { "default": { "value": "9b2d1e8a7c4f4b6e9d3a5c7e1f2a4b6c" } }
      }
    },

    "headers": {
      "XApiLimitRemaining": {
        "description": "API credits remaining on your plan.",
        "schema": { "type": "integer", "minimum": 0 }
      },
      "XApiKeyLimitRemaining": {
        "description": "API credits remaining under the credit limit set on this API key. Only sent when a credit limit is set on the API key used; your plan's credits (`X-API-Limit-Remaining`) still apply, whichever runs out first.",
        "schema": { "type": "integer", "minimum": 0 }
      },
      "XRateLimitRemaining": {
        "description": "Requests remaining in the current 15-minute rate-limit window.",
        "schema": { "type": "integer", "minimum": 0 }
      }
    },

    "schemas": {
      "ErrorCode": {
        "type": "string",
        "description": "Error code. Like `message`, it is translated when the request's `Accept-Language` header selects a supported language (hi, es, ur, de, ru, zh, ja, ar, fr, id, pt, bn); the values below are the English codes, returned by default.",
        "enum": [
          "Unauthorized",
          "ServerError",
          "TooManyRequests",
          "InvalidRequest",
          "AccessDenied",
          "ServiceUnavailable",
          "NotFound",
          "UnsupportedFilter",
          "FilterLimitExceed",
          "UnsupportedParameter",
          "TooManyQueryFilter",
          "UnsupportedDateFormat",
          "UnsupportedQueryLength",
          "RateLimitExceeded",
          "ApiLimitExceeded",
          "ApiKeyLimitExceeded",
          "RegistrationLimitExceeded",
          "MalformedUrl",
          "MaxPageLimitExceeded",
          "MalformedQuery",
          "Conflict"
        ]
      },

      "ErrorDetail": {
        "type": "object",
        "description": "Error details.",
        "required": ["message", "code"],
        "properties": {
          "message": { "type": "string", "description": "Human-readable error description." },
          "code": { "$ref": "#/components/schemas/ErrorCode" }
        }
      },

      "InvalidFilterDetail": {
        "type": "object",
        "description": "Error details returned when a filter value is not supported. The rejected value(s) are listed, comma-separated, under `invalid_<parameter>`, named after the parameter you sent (e.g. `invalid_excludecountry`); `recommendations` may offer close matches.",
        "properties": {
          "message": { "type": "string" },
          "code": { "$ref": "#/components/schemas/ErrorCode" },
          "invalid_domainurl": { "type": "string" },
          "invalid_excludedomainurl": { "type": "string" },
          "invalid_country": { "type": "string" },
          "invalid_excludecountry": { "type": "string" },
          "invalid_category": { "type": "string" },
          "invalid_excludecategory": { "type": "string" },
          "invalid_language": { "type": "string" },
          "invalid_excludelanguage": { "type": "string" },
          "invalid_datatype": { "type": "string" },
          "invalid_excludefield": { "type": "string" },
          "invalid_id": { "type": "string" },
          "invalid_tag": { "type": "string" },
          "invalid_region": { "type": "string" },
          "invalid_coin": { "type": "string" },
          "invalid_market_id": { "type": "string" },
          "recommendations": {
            "type": "object",
            "description": "Close matches keyed by the rejected value (an empty list when there are none). For `market_id` each match is a ticker object; for `country`, `excludecountry`, `language`, `excludelanguage` and `coin` each match is a `{code, name}` object (e.g. `usa` → `us`, `eng` → `en`, `bitcoin` → `btc`); for `tag` each match is an `{id, name}` object (e.g. `ai` → `artificial_intelligence`); for `category` and `excludecategory` each match is a valid category (e.g. `sprots` → `sports`, `movie` → `entertainment`); for `domainurl` and `excludedomainurl` each match is a source URL (host plus path, e.g. `vice.com/de`).",
            "additionalProperties": {
              "type": "array",
              "items": {
                "oneOf": [
                  {
                    "type": "object",
                    "required": ["ticker", "id"],
                    "properties": {
                      "ticker": { "type": "string" },
                      "country": { "type": "string" },
                      "exchangeName": { "type": "string" },
                      "id": { "type": "string", "description": "The unique identifier to use as `market_id`." }
                    }
                  },
                  {
                    "type": "object",
                    "required": ["code", "name"],
                    "properties": {
                      "code": { "type": "string", "description": "The country, language or coin code to send." },
                      "name": { "type": "string" }
                    }
                  },
                  {
                    "type": "object",
                    "required": ["id", "name"],
                    "properties": {
                      "id": { "type": "string", "description": "The tag to send." },
                      "name": { "type": "string" }
                    }
                  },
                  { "type": "string" }
                ]
              }
            }
          }
        }
      },

      "ErrorEnvelope": {
        "type": "object",
        "description": "Standard error response. `results` contains the error message and code; for unsupported filter values it also lists the rejected value(s).",
        "required": ["status", "results"],
        "properties": {
          "status": { "type": "string", "const": "error" },
          "results": {
            "oneOf": [
              { "$ref": "#/components/schemas/ErrorDetail" },
              { "$ref": "#/components/schemas/InvalidFilterDetail" }
            ]
          }
        }
      },

      "SentimentStats": {
        "type": "object",
        "description": "Sentiment percentage breakdown. The three values sum to 100.",
        "required": ["negative", "neutral", "positive"],
        "properties": {
          "negative": { "type": "number", "minimum": 0, "maximum": 100 },
          "neutral": { "type": "number", "minimum": 0, "maximum": 100 },
          "positive": { "type": "number", "minimum": 0, "maximum": 100 }
        }
      },

      "Article": {
        "type": "object",
        "description": "A news article. Fields marked as plan-specific return a short notice string instead of their value on plans that do not include them. Any field except `article_id` may be `null`.",
        "required": ["article_id"],
        "properties": {
          "article_id": { "type": "string", "description": "Unique article identifier (32 characters)." },
          "link": { "type": ["string", "null"], "format": "uri", "description": "Article URL." },
          "title": { "type": ["string", "null"], "description": "Article title." },
          "description": { "type": ["string", "null"], "description": "Short article description." },
          "content": {
            "type": ["string", "null"],
            "description": "Full article text. Plan-specific (full-content access). Returned as `null` when `full_content=0`."
          },
          "keywords": { "type": ["array", "null"], "items": { "type": "string" }, "description": "Article keywords." },
          "creator": { "type": ["array", "null"], "items": { "type": "string" }, "description": "Article author(s)." },
          "language": { "type": ["string", "null"], "description": "Language name, e.g. 'english'." },
          "country": { "type": ["array", "null"], "items": { "type": "string" }, "description": "Country names, e.g. 'india'." },
          "category": { "type": ["array", "null"], "items": { "type": "string" }, "description": "Article categories." },
          "datatype": { "type": "string", "description": "Content type, e.g. 'news', 'blog', 'podcast'." },
          "pubDate": { "type": ["string", "null"], "description": "Publish date, `YYYY-MM-DD HH:MM:SS`, in the requested `timezone`." },
          "pubDateTZ": { "type": "string", "description": "Timezone of the dates in this article. 'UTC' unless `timezone` was supplied." },
          "fetched_at": { "type": ["string", "null"], "description": "When the article was collected, `YYYY-MM-DD HH:MM:SS`, in the requested `timezone`." },
          "image_url": { "type": ["string", "null"], "format": "uri", "description": "Article image URL." },
          "video_url": { "type": ["string", "null"], "format": "uri", "description": "Article video URL." },
          "source_id": { "type": ["string", "null"], "description": "Source id." },
          "source_name": { "type": ["string", "null"], "description": "Source display name." },
          "source_priority": { "type": ["integer", "null"], "description": "Source ranking (lower = higher-ranked)." },
          "source_url": { "type": ["string", "null"], "format": "uri", "description": "Source website URL." },
          "source_icon": { "type": ["string", "null"], "format": "uri", "description": "Source icon URL." },
          "sentiment": {
            "description": "Overall sentiment: positive, neutral, or negative.",
            "anyOf": [
              { "type": "string", "enum": ["positive", "neutral", "negative"] },
              { "type": "string" },
              { "type": "null" }
            ]
          },
          "sentiment_stats": {
            "description": "Sentiment percentage breakdown.",
            "anyOf": [
              { "$ref": "#/components/schemas/SentimentStats" },
              { "type": "string" },
              { "type": "null" }
            ]
          },
          "ai_tag": {
            "description": "AI-classified topic tags.",
            "anyOf": [
              { "type": "array", "items": { "type": "string" } },
              { "type": "string" },
              { "type": "null" }
            ]
          },
          "ai_region": {
            "description": "AI-extracted regions, e.g. 'paris,france'. Plan-specific (Corporate).",
            "anyOf": [
              { "type": "array", "items": { "type": "string" } },
              { "type": "string" },
              { "type": "null" }
            ]
          },
          "ai_org": {
            "description": "AI-extracted organization names. Plan-specific (Corporate).",
            "anyOf": [
              { "type": "array", "items": { "type": "string" } },
              { "type": "string" },
              { "type": "null" }
            ]
          },
          "ai_summary": {
            "type": ["string", "null"],
            "description": "AI-generated article summary. Plan-specific."
          },
          "duplicate": { "type": "boolean", "description": "Whether the article is a duplicate of another article." }
        }
      },

      "ArticleListEnvelope": {
        "type": "object",
        "description": "Successful article list response.",
        "required": ["status", "totalResults", "results"],
        "properties": {
          "status": { "type": "string", "const": "success" },
          "totalResults": { "type": "integer", "description": "Total number of articles matching the query (not just this page)." },
          "results": { "type": "array", "items": { "$ref": "#/components/schemas/Article" } },
          "nextPage": {
            "type": ["string", "null"],
            "description": "Pass this value as the `page` parameter to get the next page. `null` when there are no more results."
          }
        }
      },

      "CryptoArticle": {
        "type": "object",
        "description": "A cryptocurrency news article. Fields marked as plan-specific return a short notice string instead of their value on plans that do not include them. Any field except `article_id` may be `null`.",
        "required": ["article_id"],
        "properties": {
          "article_id": { "type": "string", "description": "Unique article identifier (32 characters)." },
          "link": { "type": ["string", "null"], "format": "uri", "description": "Article URL." },
          "title": { "type": ["string", "null"], "description": "Article title." },
          "description": { "type": ["string", "null"], "description": "Short article description." },
          "content": {
            "type": ["string", "null"],
            "description": "Full article text. Plan-specific (full-content access). Returned as `null` when `full_content=0`."
          },
          "keywords": { "type": ["array", "null"], "items": { "type": "string" }, "description": "Article keywords." },
          "creator": { "type": ["array", "null"], "items": { "type": "string" }, "description": "Article author(s)." },
          "coin": { "type": ["array", "null"], "items": { "type": "string" }, "description": "Cryptocurrencies the article mentions, by ticker symbol." },
          "language": { "type": ["string", "null"], "description": "Language name, e.g. 'english'." },
          "pubDate": { "type": ["string", "null"], "description": "Publish date, `YYYY-MM-DD HH:MM:SS`, in the requested `timezone`." },
          "pubDateTZ": { "type": "string", "description": "Timezone of the dates in this article. 'UTC' unless `timezone` was supplied." },
          "fetched_at": { "type": ["string", "null"], "description": "When the article was collected, `YYYY-MM-DD HH:MM:SS`, in the requested `timezone`." },
          "image_url": { "type": ["string", "null"], "format": "uri", "description": "Article image URL." },
          "video_url": { "type": ["string", "null"], "format": "uri", "description": "Article video URL." },
          "source_id": { "type": ["string", "null"], "description": "Source id." },
          "source_name": { "type": ["string", "null"], "description": "Source display name." },
          "source_priority": { "type": ["integer", "null"], "description": "Source ranking (lower = higher-ranked)." },
          "source_url": { "type": ["string", "null"], "format": "uri", "description": "Source website URL." },
          "source_icon": { "type": ["string", "null"], "format": "uri", "description": "Source icon URL." },
          "sentiment": {
            "description": "Overall sentiment: positive, neutral, or negative.",
            "anyOf": [
              { "type": "string", "enum": ["positive", "neutral", "negative"] },
              { "type": "string" },
              { "type": "null" }
            ]
          },
          "sentiment_stats": {
            "description": "Sentiment percentage breakdown.",
            "anyOf": [
              { "$ref": "#/components/schemas/SentimentStats" },
              { "type": "string" },
              { "type": "null" }
            ]
          },
          "ai_tag": {
            "description": "AI-classified topic tags (crypto-specific tag set).",
            "anyOf": [
              { "type": "array", "items": { "type": "string" } },
              { "type": "string" },
              { "type": "null" }
            ]
          },
          "duplicate": { "type": "boolean", "description": "Whether the article is a duplicate of another article." }
        }
      },

      "CryptoArticleListEnvelope": {
        "type": "object",
        "description": "Successful crypto article list response.",
        "required": ["status", "totalResults", "results"],
        "properties": {
          "status": { "type": "string", "const": "success" },
          "totalResults": { "type": "integer", "description": "Total number of articles matching the query (not just this page)." },
          "results": { "type": "array", "items": { "$ref": "#/components/schemas/CryptoArticle" } },
          "nextPage": {
            "type": ["string", "null"],
            "description": "Pass this value as the `page` parameter to get the next page. `null` when there are no more results."
          }
        }
      },

      "MarketArticle": {
        "type": "object",
        "description": "A financial-market news article. Fields marked as plan-specific return a short notice string instead of their value on plans that do not include them. Any field except `article_id` may be `null`.",
        "required": ["article_id"],
        "properties": {
          "article_id": { "type": "string", "description": "Unique article identifier (32 characters)." },
          "link": { "type": ["string", "null"], "format": "uri", "description": "Article URL." },
          "title": { "type": ["string", "null"], "description": "Article title." },
          "description": { "type": ["string", "null"], "description": "Short article description." },
          "content": {
            "type": ["string", "null"],
            "description": "Full article text. Plan-specific (full-content access). Returned as `null` when `full_content=0`."
          },
          "keywords": { "type": ["array", "null"], "items": { "type": "string" }, "description": "Article keywords." },
          "creator": { "type": ["array", "null"], "items": { "type": "string" }, "description": "Article author(s)." },
          "symbol": { "type": ["array", "null"], "items": { "type": "string" }, "description": "Stock ticker symbols the article mentions." },
          "market_id": { "type": ["array", "null"], "items": { "type": "string" }, "description": "Unique market identifiers for the tickers in `symbol` — the values accepted by the `market_id` filter." },
          "language": { "type": ["string", "null"], "description": "Language name, e.g. 'english'." },
          "country": { "type": ["array", "null"], "items": { "type": "string" }, "description": "Country names, e.g. 'india'." },
          "datatype": { "type": "string", "description": "Content type, e.g. 'news', 'blog', 'podcast'." },
          "pubDate": { "type": ["string", "null"], "description": "Publish date, `YYYY-MM-DD HH:MM:SS`, in the requested `timezone`." },
          "pubDateTZ": { "type": "string", "description": "Timezone of the dates in this article. 'UTC' unless `timezone` was supplied." },
          "fetched_at": { "type": ["string", "null"], "description": "When the article was collected, `YYYY-MM-DD HH:MM:SS`, in the requested `timezone`." },
          "image_url": { "type": ["string", "null"], "format": "uri", "description": "Article image URL." },
          "video_url": { "type": ["string", "null"], "format": "uri", "description": "Article video URL." },
          "source_id": { "type": ["string", "null"], "description": "Source id." },
          "source_name": { "type": ["string", "null"], "description": "Source display name." },
          "source_priority": { "type": ["integer", "null"], "description": "Source ranking (lower = higher-ranked)." },
          "source_url": { "type": ["string", "null"], "format": "uri", "description": "Source website URL." },
          "source_icon": { "type": ["string", "null"], "format": "uri", "description": "Source icon URL." },
          "sentiment": {
            "description": "Overall sentiment: positive, neutral, or negative.",
            "anyOf": [
              { "type": "string", "enum": ["positive", "neutral", "negative"] },
              { "type": "string" },
              { "type": "null" }
            ]
          },
          "sentiment_stats": {
            "description": "Sentiment percentage breakdown.",
            "anyOf": [
              { "$ref": "#/components/schemas/SentimentStats" },
              { "type": "string" },
              { "type": "null" }
            ]
          },
          "ai_tag": {
            "description": "AI-classified topic tags.",
            "anyOf": [
              { "type": "array", "items": { "type": "string" } },
              { "type": "string" },
              { "type": "null" }
            ]
          },
          "ai_org": {
            "description": "AI-extracted organization names. Plan-specific (Corporate).",
            "anyOf": [
              { "type": "array", "items": { "type": "string" } },
              { "type": "string" },
              { "type": "null" }
            ]
          },
          "ai_summary": {
            "type": ["string", "null"],
            "description": "AI-generated article summary. Plan-specific."
          },
          "duplicate": { "type": "boolean", "description": "Whether the article is a duplicate of another article." }
        }
      },

      "MarketArticleListEnvelope": {
        "type": "object",
        "description": "Successful market article list response.",
        "required": ["status", "totalResults", "results"],
        "properties": {
          "status": { "type": "string", "const": "success" },
          "totalResults": { "type": "integer", "description": "Total number of articles matching the query (not just this page)." },
          "results": { "type": "array", "items": { "$ref": "#/components/schemas/MarketArticle" } },
          "nextPage": {
            "type": ["string", "null"],
            "description": "Pass this value as the `page` parameter to get the next page. `null` when there are no more results."
          }
        }
      },

      "Source": {
        "type": "object",
        "description": "A news source.",
        "required": ["id"],
        "properties": {
          "id": { "type": "string", "description": "Source id." },
          "name": { "type": ["string", "null"], "description": "Source display name." },
          "url": { "type": ["string", "null"], "format": "uri", "description": "Source website URL." },
          "icon": { "type": ["string", "null"], "format": "uri", "description": "Source icon URL." },
          "priority": { "type": ["integer", "null"], "description": "Source ranking (lower = higher-ranked)." },
          "description": { "type": ["string", "null"], "description": "Short description of the source." },
          "category": { "type": ["array", "null"], "items": { "type": "string" }, "description": "Categories the source covers." },
          "language": { "type": ["array", "null"], "items": { "type": "string" }, "description": "Languages the source publishes in." },
          "country": { "type": ["array", "null"], "items": { "type": "string" }, "description": "Countries the source covers." },
          "total_article": { "type": ["integer", "null"], "description": "Number of articles collected from this source." },
          "last_fetch": { "type": ["string", "null"], "description": "When the source was last fetched, `YYYY-MM-DD HH:MM:SS`." }
        }
      },

      "SourceListEnvelope": {
        "type": "object",
        "description": "Successful source list response.",
        "required": ["status", "totalResults", "results"],
        "properties": {
          "status": { "type": "string", "const": "success" },
          "totalResults": { "type": "integer", "description": "Number of sources returned (maximum 100)." },
          "results": { "type": "array", "items": { "$ref": "#/components/schemas/Source" } },
          "nextPage": { "type": "null", "description": "Always `null` for this endpoint." }
        }
      },

      "CountSummaryEnvelope": {
        "type": "object",
        "description": "Count response when `interval=all` (default).",
        "required": ["status", "results"],
        "properties": {
          "status": { "type": "string", "const": "success" },
          "results": {
            "type": "object",
            "required": ["count"],
            "properties": {
              "count": { "type": "integer", "description": "Total number of articles matching the filters." }
            }
          }
        }
      },

      "CountHistogramEnvelope": {
        "type": "object",
        "description": "Count response when `interval=hour` or `interval=day`.",
        "required": ["status", "results"],
        "properties": {
          "status": { "type": "string", "const": "success" },
          "results": {
            "type": "array",
            "items": {
              "type": "object",
              "required": ["dateTime", "count"],
              "properties": {
                "dateTime": { "type": "string", "description": "Start of the hour/day, `YYYY-MM-DD HH:MM:SS` (UTC)." },
                "count": { "type": "integer", "description": "Number of articles in that hour/day." }
              }
            }
          },
          "nextPage": {
            "type": ["string", "null"],
            "description": "Pass this value as the `page` parameter to get the next page. `null` when there are no more results."
          }
        }
      },

      "WebsocketRegisterEnvelope": {
        "type": "object",
        "description": "Successful WebSocket query registration.",
        "required": ["status", "results"],
        "properties": {
          "status": { "type": "string", "const": "success" },
          "results": {
            "type": "object",
            "required": ["message", "registration_id"],
            "properties": {
              "message": { "type": "string", "description": "Human-readable confirmation." },
              "registration_id": { "type": "string", "description": "Identifier of the registered query (32 characters). Use it to connect to the WebSocket stream and to delete the registration." }
            }
          }
        }
      },

      "WebsocketQueryListEnvelope": {
        "type": "object",
        "description": "Your account's active WebSocket query registrations.",
        "required": ["status", "totalQueries", "results"],
        "properties": {
          "status": { "type": "string", "const": "success" },
          "totalQueries": { "type": "integer", "description": "Number of active registrations on your account." },
          "results": {
            "type": "object",
            "required": ["queries"],
            "properties": {
              "queries": {
                "type": "array",
                "items": {
                  "type": "object",
                  "required": ["registration_id", "active_clients", "last_used", "news_type", "query"],
                  "properties": {
                    "registration_id": { "type": "string", "description": "Identifier of the registered query (32 characters)." },
                    "active_clients": { "type": "integer", "description": "Number of devices currently connected to the stream for this registration." },
                    "last_used": { "type": ["string", "null"], "description": "When a client last connected to the stream for this registration, `YYYY-MM-DD HH:MM:SS`; `null` if none has yet." },
                    "news_type": { "type": "string", "description": "Type of news the registration streams (`latest`)." },
                    "query": {
                      "type": "object",
                      "description": "The query parameters the registration was created with, as name/value pairs (parameter names in lowercase; comma-separated filters appear as arrays).",
                      "additionalProperties": true
                    }
                  }
                }
              }
            }
          }
        }
      },

      "WebsocketDeleteEnvelope": {
        "type": "object",
        "description": "Successful WebSocket registration deletion.",
        "required": ["status", "results"],
        "properties": {
          "status": { "type": "string", "const": "success" },
          "results": {
            "type": "object",
            "required": ["message", "registration_id"],
            "properties": {
              "message": { "type": "string", "description": "Human-readable confirmation." },
              "registration_id": { "type": "string", "description": "Identifier of the deleted registration." }
            }
          }
        }
      },

      "WebsocketConflictEnvelope": {
        "type": "object",
        "description": "Returned when an identical query is already registered on your account. `registration_id` is the id of the existing registration.",
        "required": ["status", "results"],
        "properties": {
          "status": { "type": "string", "const": "error" },
          "results": {
            "type": "object",
            "required": ["message", "code", "registration_id"],
            "properties": {
              "message": { "type": "string" },
              "code": { "$ref": "#/components/schemas/ErrorCode" },
              "registration_id": { "type": "string" }
            }
          }
        }
      },

      "WebsocketNewsMessage": {
        "type": "object",
        "description": "A message pushed over the WebSocket connection when newly collected articles match the registered query. `results` uses the same article shape as `/1/latest` results, minus any fields in the registration's `excludefield`; `pubDate`/`fetched_at` follow the registration's `timezone` (UTC otherwise).",
        "required": ["status", "totalResults", "results"],
        "properties": {
          "status": { "type": "string", "const": "success" },
          "totalResults": { "type": "integer", "description": "Number of articles in this message." },
          "results": { "type": "array", "items": { "$ref": "#/components/schemas/Article" } }
        }
      }
    },

    "examples": {
      "ArticleListExample": {
        "summary": "Response shape (field names and data types)",
        "value": {
          "status": "success",
          "totalResults": "integer",
          "results": [
            {
              "article_id": "string",
              "link": "string (URL)",
              "title": "string",
              "description": "string",
              "content": "string",
              "keywords": ["string"],
              "creator": ["string"],
              "language": "string",
              "country": ["string"],
              "category": ["string"],
              "datatype": "string",
              "pubDate": "string (YYYY-MM-DD HH:MM:SS)",
              "pubDateTZ": "string (timezone name)",
              "fetched_at": "string (YYYY-MM-DD HH:MM:SS)",
              "image_url": "string (URL)",
              "video_url": "string (URL)",
              "source_id": "string",
              "source_name": "string",
              "source_priority": "integer",
              "source_url": "string (URL)",
              "source_icon": "string (URL)",
              "sentiment": "string (positive | neutral | negative)",
              "sentiment_stats": { "negative": "number", "neutral": "number", "positive": "number" },
              "ai_tag": ["string"],
              "ai_region": ["string"],
              "ai_org": ["string"],
              "ai_summary": "string",
              "duplicate": "boolean"
            }
          ],
          "nextPage": "string | null"
        }
      },
      "CryptoArticleListExample": {
        "summary": "Response shape (field names and data types)",
        "value": {
          "status": "success",
          "totalResults": "integer",
          "results": [
            {
              "article_id": "string",
              "link": "string (URL)",
              "title": "string",
              "description": "string",
              "content": "string",
              "keywords": ["string"],
              "creator": ["string"],
              "coin": ["string"],
              "language": "string",
              "pubDate": "string (YYYY-MM-DD HH:MM:SS)",
              "pubDateTZ": "string (timezone name)",
              "fetched_at": "string (YYYY-MM-DD HH:MM:SS)",
              "image_url": "string (URL)",
              "video_url": "string (URL)",
              "source_id": "string",
              "source_name": "string",
              "source_priority": "integer",
              "source_url": "string (URL)",
              "source_icon": "string (URL)",
              "sentiment": "string (positive | neutral | negative)",
              "sentiment_stats": { "negative": "number", "neutral": "number", "positive": "number" },
              "ai_tag": ["string"],
              "duplicate": "boolean"
            }
          ],
          "nextPage": "string | null"
        }
      },
      "MarketArticleListExample": {
        "summary": "Response shape (field names and data types)",
        "value": {
          "status": "success",
          "totalResults": "integer",
          "results": [
            {
              "article_id": "string",
              "link": "string (URL)",
              "title": "string",
              "description": "string",
              "content": "string",
              "keywords": ["string"],
              "creator": ["string"],
              "symbol": ["string"],
              "market_id": ["string"],
              "language": "string",
              "country": ["string"],
              "datatype": "string",
              "pubDate": "string (YYYY-MM-DD HH:MM:SS)",
              "pubDateTZ": "string (timezone name)",
              "fetched_at": "string (YYYY-MM-DD HH:MM:SS)",
              "image_url": "string (URL)",
              "video_url": "string (URL)",
              "source_id": "string",
              "source_name": "string",
              "source_priority": "integer",
              "source_url": "string (URL)",
              "source_icon": "string (URL)",
              "sentiment": "string (positive | neutral | negative)",
              "sentiment_stats": { "negative": "number", "neutral": "number", "positive": "number" },
              "ai_tag": ["string"],
              "ai_org": ["string"],
              "ai_summary": "string",
              "duplicate": "boolean"
            }
          ],
          "nextPage": "string | null"
        }
      },
      "SourceListExample": {
        "summary": "Response shape (field names and data types)",
        "value": {
          "status": "success",
          "totalResults": "integer",
          "results": [
            {
              "id": "string",
              "name": "string",
              "url": "string (URL)",
              "icon": "string (URL)",
              "priority": "integer",
              "description": "string",
              "category": ["string"],
              "language": ["string"],
              "country": ["string"],
              "total_article": "integer",
              "last_fetch": "string (YYYY-MM-DD HH:MM:SS)"
            }
          ],
          "nextPage": null
        }
      },
      "CountSummaryExample": {
        "summary": "Response shape with interval=all (field names and data types)",
        "value": {
          "status": "success",
          "results": { "count": "integer" }
        }
      },
      "CountHistogramExample": {
        "summary": "Response shape with interval=hour or day (field names and data types)",
        "value": {
          "status": "success",
          "results": [
            { "dateTime": "string (YYYY-MM-DD HH:MM:SS)", "count": "integer" }
          ],
          "nextPage": "string | null"
        }
      },
      "WebsocketRegisterExample": {
        "summary": "Response shape (field names and data types)",
        "value": {
          "status": "success",
          "results": {
            "message": "string",
            "registration_id": "string (32 characters)"
          }
        }
      },
      "WebsocketQueryListExample": {
        "summary": "Response shape (field names and data types)",
        "value": {
          "status": "success",
          "totalQueries": "integer",
          "results": {
            "queries": [
              {
                "registration_id": "string (32 characters)",
                "active_clients": "integer",
                "last_used": "string (YYYY-MM-DD HH:MM:SS) | null",
                "news_type": "string",
                "query": { "q": "string", "country": ["string"] }
              }
            ]
          }
        }
      },
      "WebsocketDeleteExample": {
        "summary": "Response shape (field names and data types)",
        "value": {
          "status": "success",
          "results": {
            "message": "string",
            "registration_id": "string (32 characters)"
          }
        }
      },
      "WebsocketNewsMessageExample": {
        "summary": "Pushed message shape (field names and data types)",
        "value": {
          "status": "success",
          "totalResults": "integer",
          "results": [
            {
              "article_id": "string",
              "link": "string (URL)",
              "title": "string",
              "description": "string",
              "content": "string",
              "keywords": ["string"],
              "creator": ["string"],
              "language": "string",
              "country": ["string"],
              "category": ["string"],
              "datatype": "string",
              "pubDate": "string (YYYY-MM-DD HH:MM:SS)",
              "pubDateTZ": "UTC",
              "fetched_at": "string (YYYY-MM-DD HH:MM:SS)",
              "image_url": "string (URL)",
              "video_url": "string (URL)",
              "source_id": "string",
              "source_name": "string",
              "source_priority": "integer",
              "source_url": "string (URL)",
              "source_icon": "string (URL)",
              "sentiment": "string (positive | neutral | negative)",
              "sentiment_stats": { "negative": "number", "neutral": "number", "positive": "number" },
              "ai_tag": ["string"],
              "ai_region": ["string"],
              "ai_org": ["string"],
              "ai_summary": "string",
              "duplicate": "boolean"
            }
          ]
        }
      }
    },

    "responses": {
      "BadRequest": {
        "description": "Invalid request — e.g. a required parameter is missing or the search query is malformed.",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorEnvelope" } } }
      },
      "Unauthorized": {
        "description": "Missing or invalid API key.",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorEnvelope" } } }
      },
      "Forbidden": {
        "description": "Your plan does not include access to this endpoint, parameter or date range, or the request's IP address or origin domain is not allowed for this API key.",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorEnvelope" } } }
      },
      "UnprocessableEntity": {
        "description": "A parameter or its value is not supported — e.g. a parameter the endpoint does not accept, an unknown value, too many values, an invalid date, or two parameters that cannot be used together.",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorEnvelope" } } }
      },
      "TooManyRequests": {
        "description": "Too many requests in a short period, rate limit exceeded, API credits exhausted, the API key's own credit limit reached, or the maximum number of WebSocket registrations reached.",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorEnvelope" } } }
      },
      "ServerError": {
        "description": "Unexpected server error. Please try again later.",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorEnvelope" } } }
      },
      "ServiceUnavailable": {
        "description": "The endpoint is temporarily unavailable due to maintenance.",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorEnvelope" } } }
      },
      "Conflict": {
        "description": "An identical query is already registered on your account. `results.registration_id` carries the id of the existing registration.",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/WebsocketConflictEnvelope" } } }
      },
      "NotFound": {
        "description": "The requested resource does not exist — e.g. the `registration_id` is not registered on your account.",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/ErrorEnvelope" } } }
      }
    }
  }
}
