Get Commuting Zone Analysis
curl --request GET \
--url https://api.getswitch.io/copilot/zone-based/{provider}/commuting_zones \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.getswitch.io/copilot/zone-based/{provider}/commuting_zones"
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/zone-based/{provider}/commuting_zones', 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/zone-based/{provider}/commuting_zones"
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))
}{
"commuting_analysis": [
{
"context": {
"population": 980,
"top_pois": [
{
"category": "sustenance",
"count": 47
},
{
"category": "leisure",
"count": 6
}
],
"transit_stops_total": 4
},
"evening_inflow": 6.3,
"evening_outflow": 2.4,
"geom": {
"coordinates": [
[
[
9.17496,
45.45181
],
[
9.17633,
45.45181
],
[
9.17633,
45.45319
],
[
9.17496,
45.45319
],
[
9.17496,
45.45181
]
]
],
"type": "Polygon"
},
"morning_inflow": 2.1,
"morning_outflow": 5.8,
"total_flow": 16.6,
"zone_id": "u0nd8f3",
"zone_label": "u0nd8f3",
"zone_latitude": 45.4525,
"zone_longitude": 9.17564,
"zone_type": "Residential"
},
{
"context": {
"population": 655,
"top_pois": [
{
"category": "transportation",
"count": 22
},
{
"category": "sustenance",
"count": 19
}
],
"transit_stops_total": 14
},
"evening_inflow": 3.5,
"evening_outflow": 8.9,
"geom": {
"coordinates": [
[
[
9.2038,
45.48477
],
[
9.20517,
45.48477
],
[
9.20517,
45.48615
],
[
9.2038,
45.48615
],
[
9.2038,
45.48477
]
]
],
"type": "Polygon"
},
"morning_inflow": 9.7,
"morning_outflow": 3.2,
"total_flow": 25.3,
"zone_id": "u0ndc2q",
"zone_label": "u0ndc2q",
"zone_latitude": 45.48546,
"zone_longitude": 9.20448,
"zone_type": "Commercial"
}
],
"zone_type_summary": [
{
"avg_total_flow": 7.9,
"count": 214,
"zone_type": "Residential"
},
{
"avg_total_flow": 13.4,
"count": 96,
"zone_type": "Commercial"
},
{
"avg_total_flow": 4.2,
"count": 1310,
"zone_type": "Balanced"
}
]
}Zone Based Analytics
Get Commuting Zone Analysis
Classify zones as Residential, Commercial or Balanced from their rush-hour flows: a Residential zone sends more trips than it receives in the morning (7-9 UTC) and receives more in the evening (17-19 UTC); a Commercial zone does the opposite. Returns each zone’s average morning and evening inflow and outflow, and a count per zone type.
Failure Modes:
- 400:
precisiongiven with a zoning system other thangeohash7 - 401: Token is missing or invalid
- 403: Insufficient permissions
- 404:
no_data_bindingwhen the provider or location is not enabled for your company - 422: Invalid filter parameters
Required Auth Scopes:
copilot:analytics
GET
/
copilot
/
zone-based
/
{provider}
/
commuting_zones
Get Commuting Zone Analysis
curl --request GET \
--url https://api.getswitch.io/copilot/zone-based/{provider}/commuting_zones \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.getswitch.io/copilot/zone-based/{provider}/commuting_zones"
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/zone-based/{provider}/commuting_zones', 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/zone-based/{provider}/commuting_zones"
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))
}{
"commuting_analysis": [
{
"context": {
"population": 980,
"top_pois": [
{
"category": "sustenance",
"count": 47
},
{
"category": "leisure",
"count": 6
}
],
"transit_stops_total": 4
},
"evening_inflow": 6.3,
"evening_outflow": 2.4,
"geom": {
"coordinates": [
[
[
9.17496,
45.45181
],
[
9.17633,
45.45181
],
[
9.17633,
45.45319
],
[
9.17496,
45.45319
],
[
9.17496,
45.45181
]
]
],
"type": "Polygon"
},
"morning_inflow": 2.1,
"morning_outflow": 5.8,
"total_flow": 16.6,
"zone_id": "u0nd8f3",
"zone_label": "u0nd8f3",
"zone_latitude": 45.4525,
"zone_longitude": 9.17564,
"zone_type": "Residential"
},
{
"context": {
"population": 655,
"top_pois": [
{
"category": "transportation",
"count": 22
},
{
"category": "sustenance",
"count": 19
}
],
"transit_stops_total": 14
},
"evening_inflow": 3.5,
"evening_outflow": 8.9,
"geom": {
"coordinates": [
[
[
9.2038,
45.48477
],
[
9.20517,
45.48477
],
[
9.20517,
45.48615
],
[
9.2038,
45.48615
],
[
9.2038,
45.48477
]
]
],
"type": "Polygon"
},
"morning_inflow": 9.7,
"morning_outflow": 3.2,
"total_flow": 25.3,
"zone_id": "u0ndc2q",
"zone_label": "u0ndc2q",
"zone_latitude": 45.48546,
"zone_longitude": 9.20448,
"zone_type": "Commercial"
}
],
"zone_type_summary": [
{
"avg_total_flow": 7.9,
"count": 214,
"zone_type": "Residential"
},
{
"avg_total_flow": 13.4,
"count": 96,
"zone_type": "Commercial"
},
{
"avg_total_flow": 4.2,
"count": 1310,
"zone_type": "Balanced"
}
]
}Authorizations
HTTPBearerHTTPBearer
Path Parameters
Identifier of the mobility provider whose data you analyse, e.g. acme-bikes. It must be the provider of a data source enabled for your company's zone-based analytics; any other value is refused with 404 no_data_binding (kind: source). Your SWITCH contact tells you the provider identifiers and locations enabled for your company.
