Trips API

post
Create Trip API

https://api.geospark.co/v3/api/trips/
The Create Trip API helps you to create a new trip with an origin, destination, and user.
Request
Response
Request
Headers
Api-key
required
string
Auth-key E.g.- 33223kjhdcscijhb5sdbsdmjsdcbj5f
Body Parameters
user_id
optional
string
User-id for which the trip need to be assigned E.g.- 5d9450ace47bae6d70064a9b
origins
optional
array
Single or multiple origin locations in [long, lat] format. E.g.- [[77.677270, 12.914131]]
destinations
optional
array
Single or multiple destination locations in [long, lat] format. E.g.- [[77.700475, 12.957005]]
Response
200: OK
{
"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": "2020-09-22T06:00:34.261",
"updated_at": "2020-09-22T06:00:34.261",
"trip_tracking_url": "https://trips.gs/NWY2OTkzMDI5NzI0MjIwNThmY2ZjYTFlfHNmZHNnZHNh"
}
]
}

Sample Request

curl --location --request POST 'https://api.geospark.co/v3/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
Get Trips API

https://api.geospark.co/v3/api/trips/
Get trip_list API helps to get list of trips.
Request
Response
Request
Headers
Api-key
required
string
Auth-key E.g.- 33223kjhdcscijhb5sdbsdmjsdcbj5f
Query Parameters
user_id
optional
string
Used to get the list of trips assigned to the given user_id. E.g.- 5d9450ace47bae6d70064a9b
start_date
required
string
Date from when trips need to be returned. E.g.- 2020-08-15
end_date
required
string
Date till when the trip list need to be returned. E.g.- 2020-08-20
trip_id
optional
string
Used to get one particular trip. E.g.- 5f7d9926e5fc233610297c76
page_number
optional
integer
Used to traverse through pages of data. E.g.- 1
Response
200: OK
{
"status": true,
"msg": "Success.",
"code": 200,
"data": [
{
"id": "5f7d9926e5fc233610297c76",
"project_id": "5f7d656ae5fc233611297c6c",
"origins": [
{
"id": "5f7d9926e5fc233610297c77",
"trip_id": "5f7d9926e5fc233610297c76",
"created_at": "2020-10-07T10:32:06.527",
"updated_at": "2020-10-07T10:32:06.538",
"coordinates": {
"type": "Point",
"coordinates": [
77.622977,
12.917042
]
},
"loc_type": "origin"
},
{
"id": "5f7d9926e5fc233610297c78",
"trip_id": "5f7d9926e5fc233610297c76",
"created_at": "2020-10-07T10:32:06.545",
"updated_at": "2020-10-07T10:32:06.552",
"coordinates": {
"type": "Point",
"coordinates": [
77.650239,
12.924304
]
},
"loc_type": "origin"
},
{
"id": "5f7d9926e5fc233610297c79",
"trip_id": "5f7d9926e5fc233610297c76",
"created_at": "2020-10-07T10:32:06.560",
"updated_at": "2020-10-07T10:32:06.571",
"coordinates": {
"type": "Point",
"coordinates": [
77.743206,
12.954302
]
},
"loc_type": "origin"
}
],
"destinations": [
{
"id": "5f7d9926e5fc233610297c7a",
"trip_id": "5f7d9926e5fc233610297c76",
"created_at": "2020-10-07T10:32:06.578",
"updated_at": "2020-10-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": "2020-10-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": "2020-10-07T10:32:06.522",
"updated_at": "2020-10-07T10:32:06.603"
}
]
}

Sample Request

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

put
Update Trip API

https://api.geospark.co/v3/api/trips/
This API allows you to update the origin, destination or user_id for a given trip_id before starting the trip.
Request
Response
Request
Headers
Api-key
required
string
Auth-key E.g.- 33223kjhdcscijhb5sdbsdmjsdcbj5f
Body Parameters
user_id
optional
string
user_id to which the trip is to be reassigned E.g.- 5d9450ace47bae6d70064a9q
trip_id
required
string
Trip id which needs to be modified. E.g.- 5d9450ace47bae6d70064a9b
origins
optional
array
Origin location in [long, lat] format. E.g.- [[77.677270, 12.914131]]
destinations
optional
array
Destination location in [long, lat] format. E.g.- [[77.700475, 12.957005]]
Response
200: OK
{
"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:01:44.680",
"updated_at": "2020-09-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": "2020-09-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": "2020-09-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": "2020-09-22T06:00:34.261",
"updated_at": "2020-09-22T06:01:44.699"
}
]
}

Sample Request

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

delete
Delete Trip API

https://api.geospark.co/v3/api/trips/
This API helps you to delete an existing trip.
Request
Response
Request
Headers
Api-key
required
string
Auth-key E.g.- 33223kjhdcscijhb5sdbsdmjsdcbj5f
Query Parameters
trip_id
required
string
Trip id which needs to be deleted. E.g.- 5cd0299d77aebe2d78758d32
Response
200: OK
{
"status": true,
"msg": "Trip deleted successfully.",
"code": 200,
"data": null
}

Sample Request

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

get
Trip Summary API

https://api.geospark.co/v3/api/trips/summary/
This API helps you to get the trip summary of given trip_id with its route, distance and duration. Note: distance_covered is in meters and duration is in seconds.
Request
Response
Request
Headers
Api-key
required
string
Auth-key E.g.- 33223kjhdcscijhb5sdbsdmjsdcbj5f
Query Parameters
trip_id
required
string
Trip_id of the trip. E.g.- 5cd0299d77aebe2d78758d32
Response
200: OK
{
"status": true,
"msg": "Success.",
"code": 200,
"data": {
"trip_id": "<TRIP-ID>",
"user_id": "<USER-ID>",
"project_id": "<PROJECT-ID>",
"trip_status": "completed",
"distance_covered": 2938.974,
"duration": 336,
"route_indexes": [
[
1,
43
],
[
44
]
],
"route": [
{
"coordinates": {
"type": "Point",
"coordinates": [
77.7012468,
12.9727756
]
},
"altitude": 803.7,
"activity": "STOP",
"recorded_at": "2020-08-25T06:01:51.875"
},
{
"coordinates": {
"type": "Point",
"coordinates": [
77.70124362,
12.97277827
]
},
"altitude": 796.26,
"activity": "MOVING",
"recorded_at": "2020-08-25T06:01:54.547"
},
{
"coordinates": {
"type": "Point",
"coordinates": [
77.70124358,
12.97277814
]
},
"altitude": 796.8,
"activity": "MOVING",
"recorded_at": "2020-08-25T06:01:55.668"
},
......
......
{
"coordinates": {
"type": "Point",
"coordinates": [
77.7007289,
12.9736034
]
},
"altitude": 807.3,
"activity": "STOP",
"recorded_at": "2020-08-25T06:28:57.152"
}
]
}
}

Sample Request

curl --location --request GET 'https://api.geospark.co/v3/api/trips/summary/?trip_id=5f44a2fce289b825457e5497' \
--header 'Api-key: <API-KEY>'