I can report this was super easy to use and I've now incorporated it into
https://pushipedia.wmflabs.org/ - now I can keep up with what all the cool
kids are reading!

Sadly right now it just sends me the star wars episode 7 link every
morning... but I'm looking forward to the day the star wars buzz dies down
:)


On Tue, Dec 15, 2015 at 5:21 PM, Adam Baso <ab...@wikimedia.org> wrote:

> Interesting! Also, so is this:
>
> http://top.hatnote.com
>
>
> ---------- Forwarded message ----------
> From: *Thomas Steiner* <to...@google.com>
> Date: Tuesday, December 15, 2015
> Subject: [Wiki-research-l] pageviews.js—A JavaScript Client Library for
> the Wikimedia Pageviews API for Node.js and the browser
> To: Research into Wikimedia content and communities <
> wiki-researc...@lists.wikimedia.org>
> Cc: Analytics List <analyt...@lists.wikimedia.org>
>
>
> Dear all,
>
> First and foremost, thanks for making the Wikimedia Pageviews API
> available; your work is highly appreciated and super useful! As a
> modest "thank you", I am happy to release the JavaScript client
> library pageviews.js for Node.js and the browser to make working with
> this API easy for JavaScript developers. Please find the code and all
> instructions at [1]. The library adds some convenience functions
> (getting batch pageviews and limiting the number of results) that were
> inspired by Dan Andreescu's Python library [2] and is Promise-based:
>
> ===
> var pageviews = require('pageviews');
>
> // Getting pageviews for a single article
> pageviews.getPerArticlePageviews({
>   article: 'Berlin',
>   project: 'en.wikipedia',
>   start: '20151201',
>   end: '20151202'
> }).then(function(result) {
>   console.log(JSON.stringify(result, null, 2));
> }).catch(function(error) {
>   console.log(error);
> });
>
> // Getting top-n items ranked by pageviews for multiple projects
> pageviews.getTopPageviews({
>   projects: ['en.wikipedia', 'de.wikipedia'], // Plural
>   year: '2015',
>   month: '12',
>   day: '01',
>   limit: 2 // Limit to the first n results
> }).then(function(result) {
>   console.log(JSON.stringify(result, null, 2));
> }).catch(function(error) {
>   console.log(error);
> });
> ===
>
> On a more technical note—trying to be a good citizen [3]—the client
> library sets an identifying User-Agent header in Node.js mode.
> However, trying to set the corresponding X-User-Agent (note the "X-")
> header from a browser context (XMLHttpRequest cannot override the
> browser's intrinsic User-Agent for security reasons), this fails with
> an error message "Request header field X-User-Agent is not allowed by
> Access-Control-Allow-Headers in preflight response". Maybe you could
> change your CORS settings and include X-User-Agent in your
> Access-Control-Allow-Headers?!
>
> Hope this is useful.
>
> Thanks,
> Tom
>
> --
> [1] pageviews.js: https://github.com/tomayac/pageviews.js
> [2] python-mwviews: https://github.com/mediawiki-utilities/python-mwviews
> [3] User-Agent requirement: https://wikimedia.org/api/rest_v1/?doc
>
> --
> Dr. Thomas Steiner, Employee (blog.tomayac.com, twitter.com/tomayac)
>
> Google Germany GmbH, ABC-Str. 19, 20354 Hamburg
> Geschäftsführer: Matthew Scott Sucherman, Paul Terence Manicle
> Registergericht und -nummer: Hamburg, HRB 86891
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.29 (GNU/Linux)
>
>
> iFy0uwAntT0bE3xtRa5AfeCheCkthAtTh3reSabiGbl0ck0fjumBl3DCharaCTersAttH3b0ttom.hTtP5://xKcd.c0m/1181/
> -----END PGP SIGNATURE-----
>
> _______________________________________________
> Wiki-research-l mailing list
> wiki-researc...@lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/wiki-research-l
>
>
> _______________________________________________
> Mobile-l mailing list
> Mobile-l@lists.wikimedia.org
> https://lists.wikimedia.org/mailman/listinfo/mobile-l
>
>
_______________________________________________
Mobile-l mailing list
Mobile-l@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mobile-l

Reply via email to