# Collections

> Documentation index: https://ridewithgps.com/api/v1/doc/llms.txt

OpenAPI specification for these endpoints: https://ridewithgps.com/api/v1/openapi/openapi_collections.yaml

## Returns a list of collections

`GET /api/v1/collections.json`

Returns a paginated list of collections for the authenticated user.

Supports filtering by `name` and `visibility`.

### Headers

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `x-rwgps-api-key` | string | yes | API key for identifying the client application |
| `x-rwgps-auth-token` | string | yes | Authentication token for the user |

### Parameters

| Name | Type | In | Required | Description |
| --- | --- | --- | --- | --- |
| `page` | integer | query | no | Page number for pagination |
| `page_size` | integer | query | no | Number of items per page (20-200) |
| `name` | string | query | no | Filter by name (partial match) |
| `visibility` | string | query | no | Filter by visibility. One of: `public`, `followers_only`, `mutual_followers_only`, `private`. |

### Response `200`

| Name | Type | Description |
| --- | --- | --- |
| `collections` | array of objects |  |
| `collections[].id` | integer |  |
| `collections[].user_id` | integer |  |
| `collections[].url` | string |  |
| `collections[].html_url` | string |  |
| `collections[].visibility` | string |  |
| `collections[].name` | string or null |  |
| `collections[].description` | string or null |  |
| `collections[].cover` | string or null |  |
| `collections[].created_at` | date-time |  |
| `collections[].updated_at` | date-time |  |

### Errors

- `401` Unauthorized

### Example request

```bash
curl \
  -H "x-rwgps-api-key: $API_KEY" \
  -H "x-rwgps-auth-token: $AUTH_TOKEN" \
  https://ridewithgps.com/api/v1/collections.json
```

### Example response

```json
{
  "collections": [
    {
      "id": 123,
      "user_id": 123,
      "url": "https://ridewithgps.com/api/v1/collections/123.json",
      "html_url": "https://ridewithgps.com/collections/123",
      "visibility": "public",
      "name": "Portland favorites",
      "description": "Our best rides around Portland",
      "cover": null,
      "created_at": "2000-01-01T12:00:00Z",
      "updated_at": "2000-01-01T12:00:00Z"
    }
  ]
}
```

## Returns the specified collection

`GET /api/v1/collections/{id}.json`

Returns detailed information about a specific collection

### Headers

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `x-rwgps-api-key` | string | yes | API key for identifying the client application |
| `x-rwgps-auth-token` | string | yes | Authentication token for the user |

### Parameters

| Name | Type | In | Required | Description |
| --- | --- | --- | --- | --- |
| `id` | integer | path | yes | Collection ID |
| `privacy_code` | string | query | no | Privacy code for the non public asset |

### Response `200`

| Name | Type | Description |
| --- | --- | --- |
| `collection` | object |  |
| `collection.id` | integer |  |
| `collection.user_id` | integer |  |
| `collection.url` | string |  |
| `collection.html_url` | string |  |
| `collection.visibility` | string |  |
| `collection.name` | string or null |  |
| `collection.description` | string or null |  |
| `collection.cover` | string or null |  |
| `collection.created_at` | date-time |  |
| `collection.updated_at` | date-time |  |
| `collection.routes` | array of objects |  |
| `collection.routes[].id` | integer |  |
| `collection.routes[].user_id` | integer |  |
| `collection.routes[].url` | string |  |
| `collection.routes[].html_url` | string |  |
| `collection.routes[].visibility` | string |  |
| `collection.routes[].name` | string |  |
| `collection.routes[].description` | string or null |  |
| `collection.routes[].locality` | string or null |  |
| `collection.routes[].administrative_area` | string or null |  |
| `collection.routes[].country_code` | string or null |  |
| `collection.routes[].distance` | number | Distance in meters |
| `collection.routes[].elevation_gain` | number | Elevation gain in meters |
| `collection.routes[].elevation_loss` | number | Elevation loss in meters |
| `collection.routes[].first_lat` | number |  |
| `collection.routes[].first_lng` | number |  |
| `collection.routes[].last_lat` | number |  |
| `collection.routes[].last_lng` | number |  |
| `collection.routes[].sw_lat` | number | Southwest bounding box latitude |
| `collection.routes[].sw_lng` | number | Southwest bounding box longitude |
| `collection.routes[].ne_lat` | number | Northeast bounding box latitude |
| `collection.routes[].ne_lng` | number | Northeast bounding box longitude |
| `collection.routes[].track_type` | string or null |  |
| `collection.routes[].terrain` | string or null |  |
| `collection.routes[].difficulty` | string or null |  |
| `collection.routes[].unpaved_pct` | number or null |  |
| `collection.routes[].surface` | string or null |  |
| `collection.routes[].archived` | boolean or null | null for non owned routes |
| `collection.routes[].created_at` | date-time |  |
| `collection.routes[].updated_at` | date-time |  |
| `collection.trips` | array of objects |  |
| `collection.trips[].id` | integer |  |
| `collection.trips[].user_id` | integer |  |
| `collection.trips[].url` | string |  |
| `collection.trips[].html_url` | string |  |
| `collection.trips[].visibility` | string |  |
| `collection.trips[].name` | string |  |
| `collection.trips[].description` | string or null |  |
| `collection.trips[].departed_at` | date-time or null |  |
| `collection.trips[].time_zone` | string or null |  |
| `collection.trips[].locality` | string or null |  |
| `collection.trips[].administrative_area` | string or null |  |
| `collection.trips[].country_code` | string or null |  |
| `collection.trips[].activity_type` | string or null |  |
| `collection.trips[].fit_sport` | integer or null |  |
| `collection.trips[].fit_sub_sport` | integer or null |  |
| `collection.trips[].stationary` | boolean |  |
| `collection.trips[].distance` | number | Distance in meters |
| `collection.trips[].duration` | number | Duration in seconds |
| `collection.trips[].moving_time` | number | Moving time in seconds |
| `collection.trips[].elevation_gain` | number | Elevation gain in meters |
| `collection.trips[].elevation_loss` | number | Elevation loss in meters |
| `collection.trips[].first_lat` | number or null |  |
| `collection.trips[].first_lng` | number or null |  |
| `collection.trips[].last_lat` | number or null |  |
| `collection.trips[].last_lng` | number or null |  |
| `collection.trips[].sw_lat` | number or null |  |
| `collection.trips[].sw_lng` | number or null |  |
| `collection.trips[].ne_lat` | number or null |  |
| `collection.trips[].ne_lng` | number or null |  |
| `collection.trips[].track_type` | string or null |  |
| `collection.trips[].terrain` | string or null |  |
| `collection.trips[].difficulty` | string or null |  |
| `collection.trips[].avg_speed` | number or null | Average speed in kilometers per hour |
| `collection.trips[].max_speed` | number or null | Maximum speed in kilometers per hour |
| `collection.trips[].avg_cad` | number or null | Average cadence in rounds per minute |
| `collection.trips[].min_cad` | number or null | Minimum cadence in rounds per minute |
| `collection.trips[].max_cad` | number or null | Maximum cadence in rounds per minute |
| `collection.trips[].avg_hr` | number or null | Average heart rate in beats per minute |
| `collection.trips[].min_hr` | number or null | Minimum heart rate in beats per minute |
| `collection.trips[].max_hr` | number or null | Maximum heart rate in beats per minute |
| `collection.trips[].avg_watts` | number or null | Average power in watts |
| `collection.trips[].min_watts` | number or null | Minimum power in watts |
| `collection.trips[].max_watts` | number or null | Maximum power in watts |
| `collection.trips[].calories` | number or null | Calories burned |
| `collection.trips[].device` | string or null |  |
| `collection.trips[].created_at` | date-time |  |
| `collection.trips[].updated_at` | date-time |  |

### Errors

- `401` Unauthorized
- `403` Forbidden - Collection not visible to user
- `404` Not Found - Collection not found

### Example request

```bash
curl \
  -H "x-rwgps-api-key: $API_KEY" \
  -H "x-rwgps-auth-token: $AUTH_TOKEN" \
  https://ridewithgps.com/api/v1/collections/123.json
```

### Example response

```json
{
  "collection": {
    "id": 123,
    "user_id": 123,
    "url": "https://ridewithgps.com/api/v1/collections/123.json",
    "html_url": "https://ridewithgps.com/collections/123",
    "visibility": "public",
    "name": "Portland favorites",
    "description": "Our best rides around Portland",
    "cover": null,
    "created_at": "2000-01-01T12:00:00Z",
    "updated_at": "2000-01-01T12:00:00Z",
    "routes": [
      {
        "id": 123,
        "user_id": 123,
        "url": "https://ridewithgps.com/api/v1/routes/123.json",
        "html_url": "https://ridewithgps.com/routes/123",
        "visibility": "public",
        "name": "Forest Park loop",
        "description": "Morning ride through Forest Park",
        "locality": "Portland",
        "administrative_area": "OR",
        "country_code": "US",
        "distance": 40237,
        "elevation_gain": 457,
        "elevation_loss": 461,
        "first_lat": 45.521529,
        "first_lng": -122.691804,
        "last_lat": 45.521529,
        "last_lng": -122.691804,
        "sw_lat": 45.432536,
        "sw_lng": -122.836749,
        "ne_lat": 45.652881,
        "ne_lng": -122.471777,
        "track_type": "loop",
        "terrain": "rolling",
        "difficulty": "moderate",
        "unpaved_pct": 12,
        "surface": "mostly_paved",
        "archived": false,
        "created_at": "2000-01-01T12:00:00Z",
        "updated_at": "2000-01-01T12:00:00Z"
      }
    ],
    "trips": [
      {
        "id": 123,
        "user_id": 123,
        "url": "https://ridewithgps.com/api/v1/trips/123.json",
        "html_url": "https://ridewithgps.com/trips/123",
        "visibility": "public",
        "name": "Forest Park loop",
        "description": "Morning ride through Forest Park",
        "departed_at": "2000-01-01T08:00:00-08:00",
        "time_zone": "America/Los_Angeles",
        "locality": "Portland",
        "administrative_area": "OR",
        "country_code": "US",
        "activity_type": "cycling:road",
        "fit_sport": 2,
        "fit_sub_sport": 7,
        "stationary": false,
        "distance": 40237,
        "duration": 7856,
        "moving_time": 7204,
        "elevation_gain": 457,
        "elevation_loss": 461,
        "first_lat": 45.521529,
        "first_lng": -122.691804,
        "last_lat": 45.521529,
        "last_lng": -122.691804,
        "sw_lat": 45.432536,
        "sw_lng": -122.836749,
        "ne_lat": 45.652881,
        "ne_lng": -122.471777,
        "track_type": "loop",
        "terrain": "rolling",
        "difficulty": "moderate",
        "avg_speed": 20.1,
        "max_speed": 52.3,
        "avg_cad": 87,
        "min_cad": 0,
        "max_cad": 119,
        "avg_hr": 143,
        "min_hr": 87,
        "max_hr": 177,
        "avg_watts": 183,
        "min_watts": 0,
        "max_watts": 627,
        "calories": 1318,
        "device": "Garmin Edge 840",
        "created_at": "2000-01-01T12:00:00Z",
        "updated_at": "2000-01-01T12:00:00Z"
      }
    ]
  }
}
```

## Returns the user's pinned collection

`GET /api/v1/collections/pinned.json`

Returns the authenticated user's pinned collection

### Headers

| Name | Type | Required | Description |
| --- | --- | --- | --- |
| `x-rwgps-api-key` | string | yes | API key for identifying the client application |
| `x-rwgps-auth-token` | string | yes | Authentication token for the user |

### Response `200`

| Name | Type | Description |
| --- | --- | --- |
| `collection` | object |  |
| `collection.id` | integer |  |
| `collection.user_id` | integer |  |
| `collection.url` | string |  |
| `collection.html_url` | string |  |
| `collection.visibility` | string |  |
| `collection.name` | string or null |  |
| `collection.description` | string or null |  |
| `collection.cover` | string or null |  |
| `collection.created_at` | date-time |  |
| `collection.updated_at` | date-time |  |
| `collection.routes` | array of objects |  |
| `collection.routes[].id` | integer |  |
| `collection.routes[].user_id` | integer |  |
| `collection.routes[].url` | string |  |
| `collection.routes[].html_url` | string |  |
| `collection.routes[].visibility` | string |  |
| `collection.routes[].name` | string |  |
| `collection.routes[].description` | string or null |  |
| `collection.routes[].locality` | string or null |  |
| `collection.routes[].administrative_area` | string or null |  |
| `collection.routes[].country_code` | string or null |  |
| `collection.routes[].distance` | number | Distance in meters |
| `collection.routes[].elevation_gain` | number | Elevation gain in meters |
| `collection.routes[].elevation_loss` | number | Elevation loss in meters |
| `collection.routes[].first_lat` | number |  |
| `collection.routes[].first_lng` | number |  |
| `collection.routes[].last_lat` | number |  |
| `collection.routes[].last_lng` | number |  |
| `collection.routes[].sw_lat` | number | Southwest bounding box latitude |
| `collection.routes[].sw_lng` | number | Southwest bounding box longitude |
| `collection.routes[].ne_lat` | number | Northeast bounding box latitude |
| `collection.routes[].ne_lng` | number | Northeast bounding box longitude |
| `collection.routes[].track_type` | string or null |  |
| `collection.routes[].terrain` | string or null |  |
| `collection.routes[].difficulty` | string or null |  |
| `collection.routes[].unpaved_pct` | number or null |  |
| `collection.routes[].surface` | string or null |  |
| `collection.routes[].archived` | boolean or null | null for non owned routes |
| `collection.routes[].created_at` | date-time |  |
| `collection.routes[].updated_at` | date-time |  |
| `collection.trips` | array of objects |  |
| `collection.trips[].id` | integer |  |
| `collection.trips[].user_id` | integer |  |
| `collection.trips[].url` | string |  |
| `collection.trips[].html_url` | string |  |
| `collection.trips[].visibility` | string |  |
| `collection.trips[].name` | string |  |
| `collection.trips[].description` | string or null |  |
| `collection.trips[].departed_at` | date-time or null |  |
| `collection.trips[].time_zone` | string or null |  |
| `collection.trips[].locality` | string or null |  |
| `collection.trips[].administrative_area` | string or null |  |
| `collection.trips[].country_code` | string or null |  |
| `collection.trips[].activity_type` | string or null |  |
| `collection.trips[].fit_sport` | integer or null |  |
| `collection.trips[].fit_sub_sport` | integer or null |  |
| `collection.trips[].stationary` | boolean |  |
| `collection.trips[].distance` | number | Distance in meters |
| `collection.trips[].duration` | number | Duration in seconds |
| `collection.trips[].moving_time` | number | Moving time in seconds |
| `collection.trips[].elevation_gain` | number | Elevation gain in meters |
| `collection.trips[].elevation_loss` | number | Elevation loss in meters |
| `collection.trips[].first_lat` | number or null |  |
| `collection.trips[].first_lng` | number or null |  |
| `collection.trips[].last_lat` | number or null |  |
| `collection.trips[].last_lng` | number or null |  |
| `collection.trips[].sw_lat` | number or null |  |
| `collection.trips[].sw_lng` | number or null |  |
| `collection.trips[].ne_lat` | number or null |  |
| `collection.trips[].ne_lng` | number or null |  |
| `collection.trips[].track_type` | string or null |  |
| `collection.trips[].terrain` | string or null |  |
| `collection.trips[].difficulty` | string or null |  |
| `collection.trips[].avg_speed` | number or null | Average speed in kilometers per hour |
| `collection.trips[].max_speed` | number or null | Maximum speed in kilometers per hour |
| `collection.trips[].avg_cad` | number or null | Average cadence in rounds per minute |
| `collection.trips[].min_cad` | number or null | Minimum cadence in rounds per minute |
| `collection.trips[].max_cad` | number or null | Maximum cadence in rounds per minute |
| `collection.trips[].avg_hr` | number or null | Average heart rate in beats per minute |
| `collection.trips[].min_hr` | number or null | Minimum heart rate in beats per minute |
| `collection.trips[].max_hr` | number or null | Maximum heart rate in beats per minute |
| `collection.trips[].avg_watts` | number or null | Average power in watts |
| `collection.trips[].min_watts` | number or null | Minimum power in watts |
| `collection.trips[].max_watts` | number or null | Maximum power in watts |
| `collection.trips[].calories` | number or null | Calories burned |
| `collection.trips[].device` | string or null |  |
| `collection.trips[].created_at` | date-time |  |
| `collection.trips[].updated_at` | date-time |  |

### Errors

- `404` Pinned collection not found

### Example request

```bash
curl \
  -H "x-rwgps-api-key: $API_KEY" \
  -H "x-rwgps-auth-token: $AUTH_TOKEN" \
  https://ridewithgps.com/api/v1/collections/pinned.json
```

### Example response

```json
{
  "collection": {
    "id": 123,
    "user_id": 123,
    "url": "https://ridewithgps.com/api/v1/collections/123.json",
    "html_url": "https://ridewithgps.com/collections/123",
    "visibility": "public",
    "name": "Portland favorites",
    "description": "Our best rides around Portland",
    "cover": null,
    "created_at": "2000-01-01T12:00:00Z",
    "updated_at": "2000-01-01T12:00:00Z",
    "routes": [
      {
        "id": 123,
        "user_id": 123,
        "url": "https://ridewithgps.com/api/v1/routes/123.json",
        "html_url": "https://ridewithgps.com/routes/123",
        "visibility": "public",
        "name": "Forest Park loop",
        "description": "Morning ride through Forest Park",
        "locality": "Portland",
        "administrative_area": "OR",
        "country_code": "US",
        "distance": 40237,
        "elevation_gain": 457,
        "elevation_loss": 461,
        "first_lat": 45.521529,
        "first_lng": -122.691804,
        "last_lat": 45.521529,
        "last_lng": -122.691804,
        "sw_lat": 45.432536,
        "sw_lng": -122.836749,
        "ne_lat": 45.652881,
        "ne_lng": -122.471777,
        "track_type": "loop",
        "terrain": "rolling",
        "difficulty": "moderate",
        "unpaved_pct": 12,
        "surface": "mostly_paved",
        "archived": false,
        "created_at": "2000-01-01T12:00:00Z",
        "updated_at": "2000-01-01T12:00:00Z"
      }
    ],
    "trips": [
      {
        "id": 123,
        "user_id": 123,
        "url": "https://ridewithgps.com/api/v1/trips/123.json",
        "html_url": "https://ridewithgps.com/trips/123",
        "visibility": "public",
        "name": "Forest Park loop",
        "description": "Morning ride through Forest Park",
        "departed_at": "2000-01-01T08:00:00-08:00",
        "time_zone": "America/Los_Angeles",
        "locality": "Portland",
        "administrative_area": "OR",
        "country_code": "US",
        "activity_type": "cycling:road",
        "fit_sport": 2,
        "fit_sub_sport": 7,
        "stationary": false,
        "distance": 40237,
        "duration": 7856,
        "moving_time": 7204,
        "elevation_gain": 457,
        "elevation_loss": 461,
        "first_lat": 45.521529,
        "first_lng": -122.691804,
        "last_lat": 45.521529,
        "last_lng": -122.691804,
        "sw_lat": 45.432536,
        "sw_lng": -122.836749,
        "ne_lat": 45.652881,
        "ne_lng": -122.471777,
        "track_type": "loop",
        "terrain": "rolling",
        "difficulty": "moderate",
        "avg_speed": 20.1,
        "max_speed": 52.3,
        "avg_cad": 87,
        "min_cad": 0,
        "max_cad": 119,
        "avg_hr": 143,
        "min_hr": 87,
        "max_hr": 177,
        "avg_watts": 183,
        "min_watts": 0,
        "max_watts": 627,
        "calories": 1318,
        "device": "Garmin Edge 840",
        "created_at": "2000-01-01T12:00:00Z",
        "updated_at": "2000-01-01T12:00:00Z"
      }
    ]
  }
}
```
