Welcome, guest | Sign In | My Account | Store | Cart

Notice! PyPM is being replaced with the ActiveState Platform, which enhances PyPM’s build and deploy capabilities. Create your free Platform account to download ActivePython or customize Python with the packages you require and get automatic updates.

Download
ActivePython
INSTALL>
pypm install sw.nikeplus

How to install sw.nikeplus

  1. Download and install ActivePython
  2. Open Command Prompt
  3. Type pypm install sw.nikeplus
 Python 2.7Python 3.2Python 3.3
Windows (32-bit)
0.1 Available View build log
Windows (64-bit)
0.1 Available View build log
Mac OS X (10.5+)
0.1 Available View build log
Linux (32-bit)
0.1 Available View build log
Linux (64-bit)
0.1 Available View build log
 
License
ZPL 2.1
Dependencies
Lastest release
version 0.1 on May 24th, 2012

NikePlus API

As a Nike+ user and software engeneer I thought it would be interesting to be able to get the raw data of my runs. This little bit of software enables you to fetch that data either in XML (as provided by Nike) or in JSON.

All you need is you UserID, which you can get by following those steps:

  1. Sign in to NikePlus.
  2. Click My Runs.
  3. Click the Share button on the top right of your runs.
  4. Click Add to a Web page.
  5. Click Grab the Code.

The Code is now copied to your clipboard. Inside that code, you can find your UserID.

How to use

The following tests are live tests with my UserID. They will ensure, that the code works against the live Nike+ API.

>>> import sw.nikeplus
>>> user_id = 279218513
Retrieving data in XML
>>> print sw.nikeplus.get_xml(user_id)
<?xml...<status>success...<run id="1889752785" workoutType="standard"><startTime>2006-10-31T16:50:07+01:00...

The response from Nike+ is cached. If, for any reason, the service is out-of-order on the next try, the old response is returned. You may force a refresh by providing the optional parameter force.

Retrieving data in JSON
>>> print sw.nikeplus.get_json(user_id)
{'status': 'success',...'startTime': '2006-10-31T16:50:07+01:00', 'duration': '1752873', 'id': '1889752785', 'workoutType': 'standard'...

The response from Nike+ is cached here, too. You can provide the optional parameter force as well, if you like to disable caching.

Helper functions

There is a helper function called xml2json. It should work with every XML, not just with the Nike+ one. It is tested inside the package, but may be used from other packages, if you need it:

>>> import sw.nikeplus.utils
>>> print sw.nikeplus.utils.xml2json(
...     """<?xml version="1.0" encoding="UTF-8"?>
...        <note id="1234">
...          <to>Tove</to>
...          <from>Jani</from>
...          <heading>Reminder</heading>
...          <body>Don't forget me this weekend!</body>
...        </note>""")
{'body': "Don't forget me this weekend!", 'to': 'Tove', 'from': 'Jani', 'heading': 'Reminder', 'id': '1234'}

CHANGELOG

0.1 (2012-04-04)
  • initial release

Subscribe to package updates

Last updated May 24th, 2012

Download Stats

Last month:1

What does the lock icon mean?

Builds marked with a lock icon are only available via PyPM to users with a current ActivePython Business Edition subscription.

Need custom builds or support?

ActivePython Enterprise Edition guarantees priority access to technical support, indemnification, expert consulting and quality-assured language builds.

Plan on re-distributing ActivePython?

Get re-distribution rights and eliminate legal risks with ActivePython OEM Edition.