About Map My Tracks

About the API

How does it work

Map My Tracks provides a simple interface that allows developers to access and update their activity data. You can use this API to make your own widgets or applications that seamlessly integrate Map My Tracks with other services.

If you have any questions or suggestions about our API don't hesitate to contact us at support@mapmytracks.com.

Overview

The API consists of a number of services which are accessed by sending a HTTP POST to the Map My Tracks API URL at http://www.mapmytracks.com/api/. All requests require basic HTTP authentication using a valid Map My Tracks username and password. All API requests will be assigned to the user's account. The API responds with an XML formatted message. The content of this message will be dependent on the type of request that was made.

Services

Data retrieval
Data input
Get activities

Get a list of a user's activities.

Parameters
request
The request identifier. To perform this API request, set this to 'get_activities'.
author
The user's username.
Returns

A list of activities, ordered by the time at which they were performed. If requesting your own activities, the list will contain both your public and private tracks.

Example POST
request = get_activities
author = rsmith
Returns a complete list of user's activities.
<?xml version="1.0" encoding="UTF-8"?>
<message>
	<author>Rob</author>
	<activities>
		<activity1>
			<id>54</id>
			<title>Wednesday run</title>
			<date>1198053480</date>
		</activity1>
		<activity2>
			<id>500</id>
			<title>Bike ride home</title>
			<date>1223050320</date>
		</activity2>
		<activity3>
			<id>569</id>
			<title>Westgate to herne</title>
			<date>1223126383</date>
		</activity3>
	</activities>
</message>
Get activity

Get a specific activity's location data.

Parameters
request
The request identifier. To perform this API request, set this to 'get_activity'.
activity_id
The id of an activity, as returned by the activities API service.
from_time
A UNIX timestamp from which location data will be returned.
Returns

A list of positional data for the given activity, limited to 100 points, and a flag identifiying if the activity is live. Points are formatted in space delimeted blocks. Each block consists of the unixtime at which the location was recorded, followed by the location's latitude, longitude and altitude.

To get all location data within an activity with more than 100 points, call the API multiple times and modify the start_from parameter to suit.

Example POST
request = get_activity
activity_id = 54
from_time = 0
Returns the first 100 points for an activity.
<?xml version="1.0" encoding="UTF-8"?>
<message>
	<complete>Yes</complete>
	<points>
	1198052842,51.3704583333333,1.15737333333333,1.345 1198052846,51.370465,...
	</points>
</message>

In the event that the activity contains more than 100 points or the track is live, further requests are made to retrieve subsequent data in batches of 100 points.

Start activity

Initiate the tracking of an activity.

Parameters
request
The request identifier. To perform this API request, set this to 'start_activity'.
title
The title of the new activity. The title must be no longer that 100 characters.
privacy
Indicates if this activity is to be public or privately visible. Possible values are "public" and "private".
activity
The activity type. Possible values are "running", "cycling", "mountain biking", "sailing", "walking", "hiking", "driving", "motor racing", "off road driving", "motorcycling", "enduro", "skiing", "cross country skiing", "canoeing", "kayaking", "sea kayaking", "stand up paddle boarding", "rowing", "windsurfing", "kiteboarding", "orienteering", "mountaineering", "skating", "skateboarding", "longboarding", "horse riding", "hang gliding", "gliding", "flying", "snowboarding", "paragliding", "hiking", "hot air ballooning" and "nordic walking".
points
A list of points indicating the location(s) that this track is to be initiated with. The list of points should be space delimited in blocks containing latitude, longitude, altitude, and time data. These blocks are themselves space delimited.
source
An identifier representing the source application from which this API call is being made.
version
The version of the source application.
Optional parameters
tags
A comma separated list of tags. Each tag must be no longer that 50 characters.
hr
Heart rate data (bpm) containing heartrate and time data delimited by a space
cad
Cadence data (rpm) containing heartrate and time data delimited by a space
pwr
Power data (watts) containing heartrate and time data delimited by a space
unique_token
A unique string (containing a concatenated representation of the calling device's serial number and current time, for example) that can be used to identify calls to start_activity in poor network areas where no reply (and therefore no activity_id) is received. This can be used to aviod the creation of multiple activities.
version
An identifier representing the version of the source application from which this API call is being made.
Returns

If the request was successful, the XML response will contain a unique activity id relating to the newly created activity. If the point data supplied was in an incorrect format, the XML response will indicate an error.

Example POST
request = start_activity
title = My activity
tags = training, whitstable
privacy = public
activity = running
source = My app
points = 51.3704583333333 1.15737333333333 1.345 1198052842 51.3704586 
1.1573741 1.345 1198052844
Returns a message containing the newly created activity id.
<?xml version="1.0" encoding="UTF-8"?>
<message>
	<type>activity_started</type>
	<activity_id>9346</activity_id>
</message>
Update activity

Add new data to an activity.

Parameters
request
The request identifier. To perform this API request, set this to 'update_activity'.
activity_id
The unique id of the activity to which this update relates.
points
A list of points indicating new location(s) to append to this activity. The list of points should be space delimited in blocks containing latitude, longitude, altitude, and time data. These blocks are themselves space delimited.
Optional parameters NEW!
hr
Heart rate data (bpm) containing heartrate and time data delimited by a space
cad
Cadence data (rpm) containing heartrate and time data delimited by a space
pwr
Power data (watts) containing heartrate and time data delimited by a space
Returns

If the request was successful, the XML response will contain a message indicating that the activity has been updated. If the point data supplied was in an incorrect format, the XML response will indicate an error.

Example POST
request = update_activity
activity_id = 9346
points = 51.3704583333333 1.15737333333333 1.345 1198052842 51.3704586 
1.1573741 1.345 1198052844
hr = 80 1198052842 90 1198052848
cad = 33 1198052842 44 1198052848
pwr = 110 1198052842 125 1198052848

Returns a message indicating that the activity has been updated.

<?xml version="1.0" encoding="UTF-8"?>
<message>
	<type>activity_updated</type>
</message>
Stop activity

Stop the tracking of an activity.

Parameters
request
The request identifier. To perform this API request, set this to 'stop_activity'.
Returns

The XML reponse will contain a message indicating that the activity has been stopped.

Example POST
request = stop_activity

Returns a message indicating that the activity has been stopped.

<?xml version="1.0" encoding="UTF-8"?>
<message>
	<type>activity_stopped</type>
</message>
Get time

Get the Map My Tracks server's current system time.

Parameters
request
The request identifier. To perform this API request, set this to 'get_time'.
Returns

The XML response contains the current system time.

Example POST
request = get_time

Returns the current system time.

<?xml version="1.0" encoding="UTF-8"?>
<message>
	<type>time</type>
	<server_time>1242988693</server_time>
</message>
Upload activity

Upload an activity in it's entirety, in GPX format

Parameters
request
The request identifier. To perform this API request, set this to 'upload_activity'.
gpx_file
A GPX file formatted representation of the activity
status
Indicates if this activity is to be public or privately visible. Possible values are "public" and "private".
description
The request identifier. To perform this API request, set this to 'get_time'.
activity
The activity type. Possible values are "running", "cycling", "mountain biking", "sailing", "walking", "hiking", "driving", "motor racing", "off road driving", "motorcycling", "enduro", "skiing", "cross country skiing", "canoeing", "kayaking", "sea kayaking", "stand up paddle boarding", "rowing", "windsurfing", "kiteboarding", "orienteering", "mountaineering", "skating", "skateboarding", "longboarding", "horse riding", "hang gliding", "gliding", "flying", "snowboarding", "paragliding", "hiking", "hot air ballooning", "stand up paddle boarding" and "nordic walking".
Returns

An XML formatted replay indicating success or failure

Example POST

(gpx_file has been truncated for clarity)

request=upload_activity
gpx_file= <?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
             <?xml-stylesheet type="text/xsl" href="details.xsl"?>
                <gpx version="1.0" creator=...
status = public
description = My weekend run
activity = running

Returns, if successful.

<?xml version="1.0" encoding="UTF-8"?>
<message>
	<type>success</type>
</message>

Real-time GPS tracking for all sports

Motor racing, Sailing, Cycling, Running, Canoeing, Skiing, Walking, Windsurfing, Orienteering, Mountaineering, Horse riding, Hang gliding, Gliding, Snowboarding, Paragliding, Hot air ballooning, or just for fun.