API

juyrjola edited this page Feb 19, 2013 · 5 revisions
Clone this wiki locally

The snowplow API allows querying the locations of the snowplows in the Helsinki area. Check out the demo application and its CoffeeScript source.

The API is accessible at:

http://dev.stadilumi.fi/api/v1/snowplow/

Example query result:

{
    id: "5407",
    last_loc: {
        timestamp: "2013-02-19T10:37:33",
        coords: [
            24.95477988702919,
            60.1847431874767
        ],
        events: [
            "au"
        ]
    }
},

The field last_loc is the plow's last recorded coordinate with a timestamp. last_loc is updated as new coordinates are received.

events describes what kind of activity the plow was performing at that location. Values include:

kv
Bicycle and pedestrian lanes
au
Snow removal
su
De-icing with salt
hi
Spreading sand

In order to retrieve detailed information for a single plow, the URL is formed like this:

http://dev.stadilumi.fi/api/v1/snowplow/<id>

Query parameters

You can provide parameters to filter the query or add more information to the response. Parameters include:

history=<int>

Response will a include a list of <int> points of historical location data for the plow.

since=<time>

Show only plows that have been active since <time>. <time> can be a timestamp or a relative time.

limit=<int>

Return at most <int> plows.

Examples

http://dev.stadilumi.fi/api/v1/snowplow/5407?history=50

The query above will display information about plow 5407 with 50 previous locations included.

http://dev.stadilumi.fi/api/v1/snowplow/?since=2hours+ago&limit=10

This will return at most 10 plow routes that were active 2 hours ago or more recently.