Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries over the next few weeks. Thanks for all your past and future contributions.

Archived:API and demo application for accessing Wordpress statistics using PySymbian

From Wiki
Jump to: navigation, search

Archived.pngAquivado: Este artigo foi arquivado, pois o conteúdo não é mais considerado relevante para se criar soluções comerciais atuais. Se você achar que este artigo ainda é importante, inclua o template {{ForArchiveReview|escreva a sua justificativa}}.

All PySymbian articles have been archived. PySymbian is no longer maintained by Nokia and is not guaranteed to work on more recent Symbian devices. It is not possible to submit apps to Nokia Store.

Article Metadata
Tested with
Devices(s): E71, XpressMusic 5800
Platform(s): S60 3rd and 5th Editions
Keywords: appuifw, toolbar, canvas, graphics, wordpress, statistics
Created: marcelobarrosalmeida (20 Jun 2009)
Last edited: hamishwillee (31 May 2013)



Blogs using wordpress engine has a special page to display statistical information about your blog. It is possible to see blog views and post views, referees and searched terms, for instance. This information is available as well via HTTP, allowing third part access. It is only required an API key and an appropriated HTTP GET request. Moreover, Wordpress can send responses in CSV (comma separated values) or XML.

For direct access, you need to provide some parameters for GET request like API key, blog URI and blog ID (the complete list of parameters can be found here):

  • api_key: your API key (instructions here)
  • blog_uri: your blog address, like For blogs not hosted by wordpress, please read this page for tips about configuring the required plugin.
  • blog_id: your blog index (0, in general)

A typical request for blog views could be:

In this article will be proposed an API wrapper for Wordpress statistics, written in Python and based on urllib. This API will be used in a PySymbian application called WPStats, suitable for S60 3rd and 5th editions (only PySymbian 1.9.5 or newer).

Wordpress statistics API

Using the proposed API, called, it is simple to retrieve your daily blog views with just few lines:

from wpstatsapi import *
api_key = "012345abcdef" # put your key here
blog_uri = "" # put your blog URI here
wps = WPStats(api_key,blog_uri)
bv_daily = wps.get_blog_views()

An array with tuples in the format ('data',views) will be returned, like below:

[('2009-05-24', 91),
('2009-05-25', 149),
('2009-05-26', 162),
('2009-05-27', 339),
('2009-05-28', 278)]

It is possible to convert from daily to weekly or monthly, just calling conv2monthly() or conv2weekly() functions.

bv_daily = wps.get_blog_views()
bv_weekly = conv2weekly(bv_daily)
bv_monthly = conv2monthly(bv_daily)

Besides blog views, the following methods are implemented (see source code for better explanation about parameters and response format):

  • get_post_views(): Get the number of views for a given post id or number of views for all posts.
  • get_referrers(): Get the list of referrers.
  • get_search_terms(): Get the list o search terms.
  • get_clicks(): Get link clicks.

All parameters can be reconfigured using reconfigure() and proxies are supported as well.

Wordpress statistics application

WPStats is available for touch and non touch S60 devices (Python 1.9.5) and has some nice features, like:

  • Transparent toolbar at left for all functions. I decided not to use menus and save screen space. The same reason for avoiding labels (better to use popups).
  • Three views: daily, weekly and monthly blog views. In weekly mode, the week number is showed after the year.
  • Data persistence and configurable number of days to consider in the statistic.

Zoom and proxy support are missing yet. For proxy, it is just a matter of creating the setup dialog.

You can see this application in action in the following video.

WPStats Screenshot

Source code and sis

Source code is available in the Wordmobi repository: [1].

This page was last modified on 31 May 2013, at 01:06.
76 page views in the last 30 days.

Was this page helpful?

Your feedback about this content is important. Let us know what you think.


Thank you!

We appreciate your feedback.