Tutorial

From BlackberryTracker

Jump to: navigation, search

[edit] Get your API key

Go to http://dev.tech9computers.com and login with your Blackberry Tracker login information. Go to Manage API Key to get your key.

To get an idea of how the API works try the following using curl on the command line replacing the 000's with your api key.

Get devices:

$ curl -d "api_key=00000000000000000000000000000000" http://dev.tech9computers.com/api/get_devices

Output looks like (but all in one long line):

<?xml version="1.0" encoding="utf-8"?>
<get_devices_response>
     <devices list="true">
          <device>
               <name>12345678</name>
               <id>9999</id>
          </device>
     </devices>
</get_devices_response>

Get location: (replace 9999 with the device ID returned above):

$ curl -d "api_key=00000000000000000000000000000000&device_id=9999" http://dev.tech9computers.com/api/get_location

Output looks like (but all in one long line):

<?xml version="1.0" encoding="utf-8"?>
<get_location_response>
     <location>
          <latitude>43.0123456789</latitude>
          <longitude>-71.0123456789</longitude>
          <elevation>-6.0</elevation>
          <date>2008-02-2210:39:03</date>
     </location>
</get_location_response>

[edit] Download the Python Library

Download and install the python BBTracker library.


[edit] Try out the following example

from bbtracker import BBTracker

bb = BBTracker('YOUR_API_KEY')
resp = bb.get_devices()
print '-------------------------'
for device in resp.devices:
    
    print "Device Name: " + device.name
    print 'Device ID: ' + str(device.id)
    
    try:
        resp = bb.get_location(device.id)
        print 'Latitude: ' + resp.location.latitude
        print 'Longitude: ' + resp.location.longitude
        print 'Elevation: ' + resp.location.elevation
    except Exception, msg:
        print 'Location Error: ' + str(msg)
    
    print '-------------------------'
Personal tools