All pages
Powered by GitBook
1 of 7

Trips v1 API

Explore Roam's Trips v1 API documentation.

Create Trip API v1Get Trip APIUpdate Trip API v1Delete Trip API v1Trip Summary APIExport Trip Summary as GPX

Create Trip API v1

The Create Trip API helps you to create a new trip with an origin, destination, and user.

Create Trip API

POST https://api.roam.ai/v1/api/trips/

Headers

Name
Type
Description

Api-key

string

Auth-key E.g.- 33223kjhdcscijhb5sdbsdmjsdcbj5f

Request Body

Name
Type
Description

user_id

string

User-id for which the trip needs to be assigned E.g.- 5d9450ace47bae6d70064a9b

origins

array

Single or multiple origin locations in [long, lat] format. E.g.- [[77.677270, 12.914131]]

destinations

array

Single or multiple destination locations in [long, lat] format. E.g.- [[77.700475, 12.957005]]

{
    "status": true,
    "msg": "Success.",
    "code": 201,
    "data": [
        {
            "id": "<ID>",
            "origins": [
                {
                    "id": "<ID>",
                    "trip_id": "<TRIP-ID>",
                    "created_at": "2020-09-22T06:00:34.264",
                    "updated_at": "2020-09-22T06:00:34.269",
                    "coordinates": {
                        "type": "Point",
                        "coordinates": [
                            77.622977,
                            12.917042
                        ]
                    },
                    "loc_type": "origin"
                }
            ],
            "destinations": [
                {
                    "id": "<ID>",
                    "trip_id": "<TRIP-ID>",
                    "created_at": "2020-09-22T06:00:34.272",
                    "updated_at": "2020-09-22T06:00:34.275",
                    "coordinates": {
                        "type": "Point",
                        "coordinates": [
                            77.650239,
                            12.924304
                        ]
                    },
                    "loc_type": "destination"
                },
                {
                    "id": "<ID>",
                    "trip_id": "<TRIP-ID>",
                    "created_at": "2020-09-22T06:00:34.278",
                    "updated_at": "2020-09-22T06:00:34.281",
                    "coordinates": {
                        "type": "Point",
                        "coordinates": [
                            77.697418,
                            12.959172
                        ]
                    },
                    "loc_type": "destination"
                }
            ],
            "events": [],
            "user_id": "<USER-ID>",
            "is_started": false,
            "is_ended": false,
            "is_deleted": false,
            "created_at": "2021-06-22T06:00:34.261",
            "updated_at": "2021-06-22T06:00:34.261",
            "trip_tracking_url": "https://trips.gs/NWY2OTkzMDI5NzI0MjIwNThmY2ZjYTFlfHNmZHNnZHNh"
        }
    ]
}
curl --location --request POST 'https://api.roam.ai/v1/api/trips/' \
--header 'Api-key: <API-KEY>' \
--header 'Content-Type: application/json' \
--data-raw '{
	"user_id": "<USER-ID>",
	"origins": [[77.622977 ,12.917042]],
    "destinations":[[77.650239 ,12.924304], [77.697418 ,12.959172]]
}'

Get Trip API

Get trip API helps get a list of trips based on various parameters.

Get Trips API

GET https://api.roam.ai/v1/api/trips/

Query Parameters

Name
Type
Description

user_id

string

Used to get the list of trips assigned to the given user_id. E.g.- 5d9450ace47bae6d70064a9b

start_date

string

Date from when trips need to be returned. E.g.- 2020-08-15

end_date

string

Date till when the trip list needs to be returned. E.g.- 2020-08-20

trip_id

string

Used to get one particular trip. E.g.- 5f7d9926e5fc233610297c76

page_number

integer

Used to traverse through pages of data. E.g.- 1

Headers

Name
Type
Description

Api-key

string

Auth-key E.g.- 33223kjhdcscijhb5sdbsdmjsdcbj5f

{
    "status": true,
    "msg": "Success.",
    "code": 200,
    "data": [
        {
            "id": "5f7d9926e5fc233610297c76",
            "project_id": "5f7d656ae5fc233611297c6c",
            "origins": [
                {
                    "id": "5f7d9926e5fc233610297c77",
                    "trip_id": "5f7d9926e5fc233610297c76",
                    "created_at": "2021-06-07T10:32:06.527",
                    "updated_at": "2021-06-07T10:32:06.538",
                    "coordinates": {
                        "type": "Point",
                        "coordinates": [
                            77.622977,
                            12.917042
                        ]
                    },
                    "loc_type": "origin"
                },
                {
                    "id": "5f7d9926e5fc233610297c78",
                    "trip_id": "5f7d9926e5fc233610297c76",
                    "created_at": "2021-06-07T10:32:06.545",
                    "updated_at": "2021-06-07T10:32:06.552",
                    "coordinates": {
                        "type": "Point",
                        "coordinates": [
                            77.650239,
                            12.924304
                        ]
                    },
                    "loc_type": "origin"
                },
                {
                    "id": "5f7d9926e5fc233610297c79",
                    "trip_id": "5f7d9926e5fc233610297c76",
                    "created_at": "2021-06-07T10:32:06.560",
                    "updated_at": "2021-06-07T10:32:06.571",
                    "coordinates": {
                        "type": "Point",
                        "coordinates": [
                            77.743206,
                            12.954302
                        ]
                    },
                    "loc_type": "origin"
                }
            ],
            "destinations": [
                {
                    "id": "5f7d9926e5fc233610297c7a",
                    "trip_id": "5f7d9926e5fc233610297c76",
                    "created_at": "2021-06-07T10:32:06.578",
                    "updated_at": "2021-06-07T10:32:06.584",
                    "coordinates": {
                        "type": "Point",
                        "coordinates": [
                            78.743206,
                            12.954302
                        ]
                    },
                    "loc_type": "destination"
                }
            ],
            "events": [
                {
                    "id": "5f7d99298fd7a058fbff9ff9",
                    "trip_id": "5f7d9926e5fc233610297c76",
                    "user_id": "5f7d95f1ffb3fb58435309de",
                    "event_type": "geospark:trip:created",
                    "created_at": "2021-06-07T10:32:09.699",
                    "is_deleted": false,
                    "event_source": "geospark:trip",
                    "event_version": "1.0"
                }
            ],
            "user_id": "5f7d95f1ffb3fb58435309de",
            "is_started": false,
            "is_ended": false,
            "is_deleted": false,
            "created_at": "2021-06-07T10:32:06.522",
            "updated_at": "2021-06-07T10:32:06.603"
        }
    ]
}

Sample Request

curl --location --request GET 'https://api.roam.ai/v1/api/trips/?user_id=5f7d95f1ffb3fb58435309de' \
--header 'Api-key: 4db3d709296a4a518a03bf15f37c55b7' \
--header 'Content-Type: application/json'

Update Trip API v1

This API allows you to update the origin, destination or user_id for a given trip_id before starting the trip.

Update Trip API

PUT https://api.roam.ai/v1/api/trips/

Headers

Name
Type
Description

Api-key

string

Auth-key E.g.- 33223kjhdcscijhb5sdbsdmjsdcbj5f

Request Body

Name
Type
Description

user_id

string

user_id to which the trip is to be reassigned E.g.- 5d9450ace47bae6d70064a9q

trip_id

string

Trip id which needs to be modified. E.g.- 5d9450ace47bae6d70064a9b

origins

array

Origin location in [long, lat] format. E.g.- [[77.677270, 12.914131]]

destinations

array

Destination location in [long, lat] format. E.g.- [[77.700475, 12.957005]]

{
    "status": true,
    "msg": "Success.",
    "code": 201,
    "data": [
        {
            "id": "<ID>",
            "origins": [
                {
                    "id": "<ID>",
                    "trip_id": "<TRIP-ID>",
                    "created_at": "2021-06-22T06:00:34.264",
                    "updated_at": "2021-06-22T06:00:34.269",
                    "coordinates": {
                        "type": "Point",
                        "coordinates": [
                            77.622977,
                            12.917042
                        ]
                    },
                    "loc_type": "origin"
                }
            ],
            "destinations": [
                {
                    "id": "<ID>",
                    "trip_id": "<TRIP-ID>",
                    "created_at": "2021-06-22T06:01:44.680",
                    "updated_at": "2021-06-22T06:01:44.687",
                    "coordinates": {
                        "type": "Point",
                        "coordinates": [
                            77.700475,
                            12.957005
                        ]
                    },
                    "loc_type": "destination"
                }
            ],
            "events": [
                {
                    "id": "<ID>",
                    "trip_id": "<TRIP-ID>",
                    "user_id": "<USER-ID>",
                    "event_type": "motion:trip:created",
                    "created_at": "2021-06-22T06:00:35.210",
                    "is_deleted": false,
                    "event_source": "motion:trip",
                    "event_version": "1.0"
                },
                {
                    "id": "<ID>",
                    "trip_id": "<TRIP-ID>",
                    "user_id": "<USER-ID>",
                    "event_type": "motion:trip:created",
                    "created_at": "2021-06-22T06:01:42.606",
                    "is_deleted": false,
                    "event_source": "motion:trip",
                    "event_version": "1.0"
                }
            ],
            "user_id": "<USER-ID>",
            "is_started": false,
            "is_ended": false,
            "is_deleted": false,
            "created_at": "2021-06-22T06:00:34.261",
            "updated_at": "2021-06-22T06:01:44.699"
        }
    ]
}

Sample Request

curl --location --request PUT 'https://api.roam.ai/v1/api/trips/' \
--header 'Api-key: <API-KEY>' \
--header 'Content-Type: application/json' \
--data-raw '{
	"trip_id": "<TRIP-ID>",
	"destinations": [[77.700475, 12.957005]]
}'

Delete Trip API v1

This API helps you to delete an existing trip.

Delete Trip API

DELETE https://api.roam.ai/v1/api/trips/

Query Parameters

Name
Type
Description

trip_id

string

Trip id which needs to be deleted. E.g.- 5cd0299d77aebe2d78758d32

Headers

Name
Type
Description

Api-key

string

Auth-key E.g.- 33223kjhdcscijhb5sdbsdmjsdcbj5f

{
    "status": true,
    "msg": "Trip deleted successfully.",
    "code": 200,
    "data": null
}

Sample Request

curl --location --request DELETE 'https://api.roam.ai/v1/api/trips/?trip_id=<TRIP-ID>' \
--header 'Content-Type: application/json' \
--header 'Api-key: <API-KEY>'

Trip Summary API

This API helps you to get the trip summary for a given trip_id with its route, distance and duration. Note: distance_covered is in meters and the duration is in seconds.

Trip Summary API

GET https://api.roam.ai/v1/api/trips/summary/

Query Parameters

Name
Type
Description

trip_id

string

Trip_id of the trip. E.g.- 5cd0299d77aebe2d78758d32

Headers

Name
Type
Description

Api-key

string

Auth-key E.g.- 33223kjhdcscijhb5sdbsdmjsdcbj5f

{
    "status": true,
    "msg": "Success.",
    "code": 200,
    "data": {
        "trip_id": "60bdebd006f8a03affc5968a",
        "user_id": "60bdebb051efb059ab7daf67",
        "project_id": "60af306a8ce7db2392eb7a75",
        "trip_status": "completed",
        "distance_covered": 129.25,
        "duration": 791,
        "route_indexes": [
            [
                1,
                6
            ],
            [
                7,
                8
            ],
            [
                9,
                10
            ],
            [
                11,
                12
            ],
            [
                13,
                14
            ],
            [
                15,
                16
            ],
            [
                17,
                18
            ],
            [
                19,
                20
            ],
            [
                21,
                22
            ],
            [
                23
            ]
        ],
        "route": [
            {
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        85.06944606259113,
                        25.605387669529264
                    ]
                },
                "altitude": 55.26,
                "activity": "STOP",
                "recorded_at": "2021-06-07T09:50:53.344",
                "duration": 0,
                "elevation_gain": 0
            },
            {
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        85.06933924413998,
                        25.60538919064786
                    ]
                },
                "altitude": 55.41,
                "activity": "MOVING",
                "recorded_at": "2021-06-07T09:51:17.232",
                "distance": 10.71,
                "duration": 23,
                "elevation_gain": 0
            },
            {
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        85.06922514582031,
                        25.60543086974654
                    ]
                },
                "altitude": 55.17,
                "activity": "MOVING",
                "recorded_at": "2021-06-07T09:51:46.472",
                "distance": 23.05,
                "duration": 53,
                "elevation_gain": 0
            },
            {
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        85.06934236442666,
                        25.605409750585785
                    ]
                },
                "altitude": 55.1,
                "activity": "MOVING",
                "recorded_at": "2021-06-07T09:51:59.177",
                "distance": 35.04,
                "duration": 65,
                "elevation_gain": 0
            },
            {
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        85.06926644486715,
                        25.605338334863347
                    ]
                },
                "altitude": 55.2,
                "activity": "MOVING",
                "recorded_at": "2021-06-07T09:53:26.418",
                "distance": 46.04,
                "duration": 153,
                "elevation_gain": 0
            },
            {
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        85.06948839273373,
                        25.60535318995217
                    ]
                },
                "altitude": 55.39,
                "activity": "STOP",
                "recorded_at": "2021-06-07T09:56:55.008",
                "distance": 68.36,
                "duration": 361,
                "elevation_gain": 0
            },
            {
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        85.0696403400277,
                        25.605349751588847
                    ]
                },
                "altitude": 55.7,
                "activity": "STOP",
                "recorded_at": "2021-06-07T09:57:06.271",
                "distance": 68.36,
                "duration": 361,
                "elevation_gain": 0
            },
            {
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        85.06963043776017,
                        25.60536547480913
                    ]
                },
                "altitude": 55.63,
                "activity": "STOP",
                "recorded_at": "2021-06-07T09:57:17.229",
                "distance": 70.37,
                "duration": 372,
                "elevation_gain": 0
            },
            {
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        85.0696539020383,
                        25.605395658660587
                    ]
                },
                "altitude": 55.81,
                "activity": "STOP",
                "recorded_at": "2021-06-07T09:57:30.023",
                "distance": 70.37,
                "duration": 372,
                "elevation_gain": 0
            },
            {
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        85.06974352418014,
                        25.60534320757614
                    ]
                },
                "altitude": 55.57,
                "activity": "STOP",
                "recorded_at": "2021-06-07T09:57:53.778",
                "distance": 81.08,
                "duration": 396,
                "elevation_gain": 0
            },
            {
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        85.06974881589383,
                        25.605281419845706
                    ]
                },
                "altitude": 55.64,
                "activity": "STOP",
                "recorded_at": "2021-06-07T09:58:09.240",
                "distance": 81.08,
                "duration": 396,
                "elevation_gain": 0
            },
            {
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        85.0696629610238,
                        25.60548954876263
                    ]
                },
                "altitude": 55.94,
                "activity": "STOP",
                "recorded_at": "2021-06-07T09:58:25.454",
                "distance": 105.77,
                "duration": 412,
                "elevation_gain": 0
            },
            {
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        85.06961812544034,
                        25.6054897625167
                    ]
                },
                "altitude": 55.37,
                "activity": "STOP",
                "recorded_at": "2021-06-07T09:58:33.947",
                "distance": 105.77,
                "duration": 412,
                "elevation_gain": 0
            },
            {
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        85.06957021187245,
                        25.605456725096815
                    ]
                },
                "altitude": 55.19,
                "activity": "STOP",
                "recorded_at": "2021-06-07T09:58:49.033",
                "distance": 111.82,
                "duration": 427,
                "elevation_gain": 0
            },
            {
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        85.06954017101675,
                        25.60544866085004
                    ]
                },
                "altitude": 55.22,
                "activity": "STOP",
                "recorded_at": "2021-06-07T09:58:57.831",
                "distance": 111.82,
                "duration": 427,
                "elevation_gain": 0
            },
            {
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        85.0694966539289,
                        25.605459740246193
                    ]
                },
                "altitude": 55.18,
                "activity": "STOP",
                "recorded_at": "2021-06-07T09:59:11.070",
                "distance": 116.35,
                "duration": 440,
                "elevation_gain": 0
            },
            {
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        85.0694966539289,
                        25.605459740246193
                    ]
                },
                "altitude": 55.18,
                "activity": "STOP",
                "recorded_at": "2021-06-07T09:59:22.460",
                "distance": 116.35,
                "duration": 440,
                "elevation_gain": 0
            },
            {
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        85.0694966539289,
                        25.605459740246193
                    ]
                },
                "altitude": 55.18,
                "activity": "STOP",
                "recorded_at": "2021-06-07T09:59:35.226",
                "distance": 116.35,
                "duration": 453,
                "elevation_gain": 0
            },
            {
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        85.06940685335138,
                        25.605458887846826
                    ]
                },
                "altitude": 55.03,
                "activity": "STOP",
                "recorded_at": "2021-06-07T09:59:47.560",
                "distance": 116.35,
                "duration": 453,
                "elevation_gain": 0
            },
            {
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        85.06931932513449,
                        25.605412577919306
                    ]
                },
                "altitude": 55.22,
                "activity": "STOP",
                "recorded_at": "2021-06-07T10:00:29.244",
                "distance": 126.53,
                "duration": 495,
                "elevation_gain": 0
            },
            {
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        85.06932052635601,
                        25.605400950443308
                    ]
                },
                "altitude": 55.43,
                "activity": "STOP",
                "recorded_at": "2021-06-07T10:01:43.687",
                "distance": 126.53,
                "duration": 495,
                "elevation_gain": 0
            },
            {
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        85.06932052635601,
                        25.605400950443308
                    ]
                },
                "altitude": 55.43,
                "activity": "STOP",
                "recorded_at": "2021-06-07T10:01:56.587",
                "distance": 126.53,
                "duration": 508,
                "elevation_gain": 0
            },
            {
                "coordinates": {
                    "type": "Point",
                    "coordinates": [
                        85.06934078651096,
                        25.605384688483593
                    ]
                },
                "altitude": 55.48,
                "activity": "STOP",
                "recorded_at": "2021-06-07T10:06:40.153",
                "distance": 129.25,
                "duration": 791,
                "elevation_gain": 0
            }
        ],
        "total_elevation_gain": 0
    }
}

Sample Request

curl --location --request GET 'https://api.roam.ai/v1/api/trips/summary/?trip_id=60bdiuy006f8a03affc5968a' \
--header 'Api-key: 63598c5b3aa84f14914013700402bbc6'

Export Trip Summary as GPX

This API helps you to export trip data in the .gpx format.

Export Trip Summary as GPX

GET https://api.roam.ai/v1/api/trips/export/

Query Parameters

Name
Type
Description

trip_id

string

trip_id required to export its data in gpx format. E.g.- 5fdc5470203bda0000abacc0

type

string

format to be given in which data need to be exported. E.g.- gpx

Headers

Name
Type
Description

Api-key

string

Auth-key E.g.- 083591a3392c483e838f66ac788126eb

{
    "status": true,
    "msg": "Success.",
    "code": 200,
    "data": {
        "download_url": "https://geospark-gpx-files.s3.amazonaws.com/5fdc5470203bda0000abacc0.gpx"
    }
}

Sample Request

curl --location --request GET 'https://api.roam.ai/v1/api/trips/export/?trip_id=5f44a2fce289b825457e5497&type=gpx' \
--header 'Api-key: <API-KEY>'