Skip to main content

Route Alerts

Endpoint
POST https://api.i3.safeandthecity.com/api/v1/alert/route?start_date=2022-08-24T13:07:16Z

i3 Route Alerts allows us to get directions from a mapping provider (e.g. Google Maps Directions API) and identify i3 Alerts that may affect that journey. This endpoint allows us to provide contextual journey risk information to end users. By using the optional start_date querystring parameter, we can plan journeys in to the future with the current available information.

Request

import requests
from geojson import Feature, Point, FeatureCollection

# Send a FeatureCollection of LineString(s) to identify alerts relating to each feature


directions = LineString([(-0.13716, 51.497351), (-0.137008, 51.497373), (-0.137118, 51.497813), (-0.136995, 51.497875), (-0.137019, 51.497973), (-0.136602, 51.498489)...])
feature = Feature(geometry=directions)
data = FeatureCollection([feature])

r = requests.post('https://api.i3.safeandthecity.com/api/v1/alert/route', headers={'Content-Type': 'application/json', 'x-api-key': '{YOUR_API_KEY}'}, json=data)

Accepted Parameters

ParametersTypeDescriptionRequired
AuthorizationheaderThe Bearer token to authenticate with the serverYes
databodyThe body parameter expects a valid geojson FeatureCollection with a LineString (See GeoJSON standard). This LineString should represent the directions line return from Google Maps Directions API/Mapbox Directions APIYes
start_datequerystringThe start_date querystring allows us to define a date and time (in RFC3339) in the future to facilitate journey planning. If left empty this will default to the current data and timeNo

Response

Route Alerts Response
{
"type": "FeatureCollection"
"features": [
{
"type": "Feature",
"geometry": {
"type": "LineString",
"coordinates": [
[
-0.13716,
51.497351
],
[
-0.137008,
51.497373
],
[
-0.137118,
51.497813
],
[
-0.136995,
51.497875
],
[
-0.137019,
51.497973
],
[
-0.136602,
51.498489
],
...
]
},
},
{
"id": "d140f8f3-7818-4f9a-bd42-d23c084dc677",
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
-0.127557,
51.503339
]
},
"properties": {
"description": "London Euromaidan have organised a protest outside 10 Downing Street to demand the UK government to do more to stop the Ukraine war.",
"location": "10 Downing Street, 10 Downing St, London, England SW1A 2AB, United Kingdom",
"start_date": "2022-08-17T17:00:00Z",
"title": "Ukraine War",
"type": "PROTEST"
}
}
],
}
info

Should no alerts affect the requested location, the same FeatureCollection you requested will be returned with no properties.