How to authenticate · OpenAPI spec for these endpoints
/api/v1/sync.json
Returns a list of items (routes and/or trips) that the user has interacted with since the given datetime.
The sync endpoint is convenient to maintain a remote copy of a user's library of trips and/or routes.
Items can have the following actions:
* created - The user created the item
* updated - The user updated the item
* deleted - The user deleted the item
* added - The user added the item to the specified collection (e.g., pinned)
* removed - The user removed the item from the specified collection
For added and removed actions, collection is the target collection where the action was taken. It is currently always the collection of pinned items for the authenticated user, but we might expose other collections in the future.
This endpoint is optimized for performance (we use a similar setup for syncing our own mobile apps), and can return the entire library for the user by using a since value well in the past (for example 1970-01-01).
The following workflow is suitable to maintain your copy of a user's library:
GET https://ridewithgps.com/api/v1/sync.json?since=1970-01-01meta.rwgps_datetime key in the responseGET https://ridewithgps.com/api/v1/sync.json?since=[rwgps_datetime]. Store the new value of meta.rwgps_datetime for the next sync request.Doing a sync request on webhook reception instead of processing the items in the body of the webhook leads to the same result and provides a recovery mechanism for previous webhooks that might have failed because of network or systems availability issues.
x-rwgps-api-key
string
required
x-rwgps-auth-token
string
required
since
string
query
required
assets
string
query
routes, trips, routes,trips
items
array of objects
item_type
string
route, trip
item_id
integer
item_user_id
integer
item_url
string
action
string
created, updated, deleted, added, removed
datetime
string
collection
object
or null
id
integer
type
string
name
string
url
string
meta
object
rwgps_datetime
string
next_sync_url
string
curl \
-H "x-rwgps-api-key: $API_KEY" \
-H "x-rwgps-auth-token: $AUTH_TOKEN" \
https://ridewithgps.com/api/v1/sync.json
{
"items": [
{
"item_type": "route",
"item_id": 123,
"item_user_id": 123,
"item_url": "https://ridewithgps.com/api/v1/routes/123.json",
"action": "created",
"datetime": "2000-01-01T11:45:00+00:00",
"collection": {
"id": 123,
"type": "pinned",
"name": "Pinned",
"url": "https://ridewithgps.com/api/v1/collections/123.json"
}
}
],
"meta": {
"rwgps_datetime": "2000-01-01T12:00:00+00:00",
"next_sync_url": "https://ridewithgps.com/api/v1/sync.json?assets=routes%2Ctrips&since=2000-01-01T12%3A00%3A00%2B00%3A00"
}
}