Get Transit Line Details
curl --request GET \
--url https://api.getswitch.io/copilot/analytics/transit/lines/{route_id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.getswitch.io/copilot/analytics/transit/lines/{route_id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.getswitch.io/copilot/analytics/transit/lines/{route_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.getswitch.io/copilot/analytics/transit/lines/{route_id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"directions": [
{
"direction_id": 0,
"headsign": "Lotto",
"shapes": [
{
"coordinates": [
[
9.1673,
45.4437
],
[
9.1897,
45.4452
],
[
9.2101,
45.4469
]
],
"type": "LineString"
}
],
"stops": [
{
"latitude": 45.4437,
"longitude": 9.1673,
"name": "Romolo",
"sequence": 1,
"stop_id": "S1120"
},
{
"latitude": 45.4469,
"longitude": 9.2101,
"name": "Piazzale Lodi",
"sequence": 2,
"stop_id": "S1123"
}
]
}
],
"route_color": "C8102E",
"route_id": "R90",
"route_long_name": "Circolare Destra",
"route_short_name": "90"
}Transit Analytics
Get Transit Line Details
One line of the transit network, from its timetable: names and colour, and for each direction its headsign, ordered stops and route shapes (GeoJSON). Use it to draw a line from the punctuality or service delivery results.
Failure Modes:
- 401: Token is missing or invalid
- 403: Insufficient permissions, service delivery analytics not enabled, or the location is not configured for it
- 404: No line with this
route_idin the timetable - 422: Invalid
route_idorlocation - 503: The timetable is unavailable
Required Auth Scopes:
copilot:analytics
GET
/
copilot
/
analytics
/
transit
/
lines
/
{route_id}
Get Transit Line Details
curl --request GET \
--url https://api.getswitch.io/copilot/analytics/transit/lines/{route_id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.getswitch.io/copilot/analytics/transit/lines/{route_id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.getswitch.io/copilot/analytics/transit/lines/{route_id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.getswitch.io/copilot/analytics/transit/lines/{route_id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}{
"directions": [
{
"direction_id": 0,
"headsign": "Lotto",
"shapes": [
{
"coordinates": [
[
9.1673,
45.4437
],
[
9.1897,
45.4452
],
[
9.2101,
45.4469
]
],
"type": "LineString"
}
],
"stops": [
{
"latitude": 45.4437,
"longitude": 9.1673,
"name": "Romolo",
"sequence": 1,
"stop_id": "S1120"
},
{
"latitude": 45.4469,
"longitude": 9.2101,
"name": "Piazzale Lodi",
"sequence": 2,
"stop_id": "S1123"
}
]
}
],
"route_color": "C8102E",
"route_id": "R90",
"route_long_name": "Circolare Destra",
"route_short_name": "90"
}Authorizations
HTTPBearerHTTPBearer
