How to hit the Wikipedia API

Wikipedia has two APIs: the REST API (/api/rest_v1/) for clean JSON about a page, and the older Action API (/w/api.php) for search and everything else. Every example below runs as-is.

Authentication

None for reading. Wikimedia asks automated clients to send a descriptive User-Agent with contact info; from a browser, use the Api-User-Agent header instead. The Action API needs origin=* to answer cross-site requests from a browser.

Full reference: https://www.mediawiki.org/wiki/API:REST_API

Get a page summary

Title, one-line description, and the lead paragraph as plain text — what Wikipedia uses for link previews.

curl https://en.wikipedia.org/api/rest_v1/page/summary/HTTP
Run in PostTaco
Example response (trimmed)
{
  "type": "standard",
  "title": "HTTP",
  "description": "Application layer protocol",
  "extract": "HTTP is an application layer protocol in the Internet protocol suite for distributed, collaborative, hypermedia information systems. HTTP is the foundation of data communication for the World Wide Web, where hypertext documents include hyperlinks to other resources that the user can easily access, for example by a mouse click or by tapping the screen in a web browser.",
  "content_urls": {
    "desktop": {
      "page": "https://en.wikipedia.org/wiki/HTTP"
    }
  }
}

On this day

Historical events for a month and day (here, July 20 — 69 events). Also births, deaths, holidays.

curl https://en.wikipedia.org/api/rest_v1/feed/onthisday/events/07/20
Run in PostTaco
Example response (trimmed)
{
  "events": [
    {
      "text": "American businessman Jeff Bezos flies to space aboard New Shepard NS-16 operated by his private spaceflight company Blue Origin.",
      "year": 2021,
      "pages": [
        {
          "title": "Jeff_Bezos"
        }
      ]
    },
    {
      "text": "Soyuz MS-13 is launched to the International Space Station on the 50th anniversary of the Apollo 11 moon landing.",
      "year": 2019,
      "pages": [
        {
          "title": "Soyuz_MS-13"
        }
      ]
    }
  ]
}

Article pageviews

Daily human views of an article from the Wikimedia metrics API. Dates are YYYYMMDD.

curl https://wikimedia.org/api/rest_v1/metrics/pageviews/per-article/en.wikipedia/all-access/user/HTTP/daily/20250701/20250703
Run in PostTaco
Example response (trimmed)
{
  "items": [
    {
      "project": "en.wikipedia",
      "article": "HTTP",
      "granularity": "daily",
      "timestamp": "2025070100",
      "access": "all-access",
      "agent": "user",
      "views": 945
    },
    {
      "project": "en.wikipedia",
      "article": "HTTP",
      "granularity": "daily",
      "timestamp": "2025070200",
      "access": "all-access",
      "agent": "user",
      "views": 1077
    },
    {
      "project": "en.wikipedia",
      "article": "HTTP",
      "granularity": "daily",
      "timestamp": "2025070300",
      "access": "all-access",
      "agent": "user",
      "views": 950
    }
  ]
}