$ npm install pageviews
Usage in Node.js
The client library requires native or polyfilled Promises support. Below are some samples of how to use it in practice.
var pageviews = ;// Getting pageviews for a single articlepageviews;// Getting pageviews for multiple articlespageviews;// Getting aggregated pageviews for a single projectpageviews;// Getting aggregated pageviews for multiple projectspageviews;// Getting top-n items ranked by pageviews for a single projectpageviews;// Getting top-n items ranked by pageviews for multiple projectspageviews;// Getting top-n items ranked by pageviews for multiple projectspageviews;// Getting unique devicespageviews;// Getting legacy pagecountspageviews;
Usage in the browser
You can build a minified version of
pageviews.js by running the build script.
$ npm run build
You can then use the file in the browser as follows.
/** * This is the root of all pageview data endpoints. The list of paths that * this returns includes ways to query by article, project, top articles, * etc. If browsing the interactive documentation, see the specifics for * each endpoint below. */ getPageviewsDimensions /** * Given a Mediawiki article and a date range, returns a daily timeseries of * its pageview counts. You can also filter by access method and/or agent * type. */ getPerArticlePageviews /** * Given a date range, returns a timeseries of pageview counts. You can * filter by project, access method and/or agent type. You can choose * between daily and hourly granularity as well. */ getAggregatedPageviews /** * Lists the 1000 most viewed articles for a given project and timespan * (year, month or day). You can filter by access method. */ getTopPageviews /** * Given a date range between December 2007 and August 2016, * returns a timeseries of pageview counts. You can filter by * project and access method. You can choose between daily, * hourly and monthly granularity as well. */ getAggregatedLegacyPagecounts /** * Given a project and a date range, returns a timeseries of unique devices * counts. You can filter by access site and choose between daily and * monthly granularity. */ getUniqueDevices
Copyright 2017 Thomas Steiner (@tomayac)
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.