How to use Wikipedia API to get the page view statistics of a particular page in wikipedia?

lipid picture lipid · Mar 16, 2011 · Viewed 11.5k times · Source

The stats.grok.se tool provides the pageview statistics of a particular page in wikipedia. Is there a method to use the wikipedia api to get the same information? What does the page views counter property actually mean?

Answer

Tgr picture Tgr · Nov 18, 2015

The Pageview API was released a few days ago: https://wikimedia.org/api/rest_v1/metrics/pageviews/per-article/{project}/{access}/{agent}/{article}/{granularity}/{start}/{end}

For example https://wikimedia.org/api/rest_v1/metrics/pageviews/per-article/en.wikipedia/all-access/all-agents/Foo/daily/20151010/20151012 will give you

{
  "items": [
    {
      "project": "en.wikipedia",
      "article": "Foo",
      "granularity": "daily",
      "timestamp": "2015101000",
      "access": "all-access",
      "agent": "all-agents",
      "views": 79
    },
    {
      "project": "en.wikipedia",
      "article": "Foo",
      "granularity": "daily",
      "timestamp": "2015101100",
      "access": "all-access",
      "agent": "all-agents",
      "views": 81
    }
  ]
}