Download Grid File For Specific Data Scenario
curl --request GET \
--url https://stage-api.getswitch.io/grids/stream/{data_scenario_id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://stage-api.getswitch.io/grids/stream/{data_scenario_id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://stage-api.getswitch.io/grids/stream/{data_scenario_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://stage-api.getswitch.io/grids/stream/{data_scenario_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))
}{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
9.18,
45.46
],
[
9.1928,
45.46
],
[
9.1928,
45.469
],
[
9.18,
45.469
],
[
9.18,
45.46
]
]
]
},
"properties": {
"zone_id": "1042"
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
9.1928,
45.46
],
[
9.2056,
45.46
],
[
9.2056,
45.469
],
[
9.1928,
45.469
],
[
9.1928,
45.46
]
]
]
},
"properties": {
"zone_id": "1043"
}
}
]
}Grids
Download Grid File For Specific Data Scenario
Same as GET /grids/stream, but checks that data_scenario_id is your company’s data scenario first. Returns the grid as a grid.geojson file: a GeoJSON FeatureCollection with one Polygon feature per zone, whose only property is zone_id.
Use this endpoint to download the complete grid file.
Failure Modes:
- 400: Location, grid type or tile size not enabled for your company
- 401: Invalid or missing authentication credentials
- 403: Insufficient permissions for grid:read scope
- 404: Your company has no forecast data configured, or
data_scenario_idis not your company’s data scenario - 422: Request validation errors (invalid parameters)
- 500: The grid file could not be read
Required Auth Scopes:
grid:read
GET
/
grids
/
stream
/
{data_scenario_id}
Download Grid File For Specific Data Scenario
curl --request GET \
--url https://stage-api.getswitch.io/grids/stream/{data_scenario_id} \
--header 'Authorization: Bearer <token>'import requests
url = "https://stage-api.getswitch.io/grids/stream/{data_scenario_id}"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://stage-api.getswitch.io/grids/stream/{data_scenario_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://stage-api.getswitch.io/grids/stream/{data_scenario_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))
}{
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
9.18,
45.46
],
[
9.1928,
45.46
],
[
9.1928,
45.469
],
[
9.18,
45.469
],
[
9.18,
45.46
]
]
]
},
"properties": {
"zone_id": "1042"
}
},
{
"type": "Feature",
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
9.1928,
45.46
],
[
9.2056,
45.46
],
[
9.2056,
45.469
],
[
9.1928,
45.469
],
[
9.1928,
45.46
]
]
]
},
"properties": {
"zone_id": "1043"
}
}
]
}Authorizations
HTTPBearerHTTPBearer
Path Parameters
Query Parameters
Type of spatial grid, e.g. squares for a regular grid of square tiles. Only the grid types (and tile sizes) enabled for your company are accepted; a 400 response lists them.
Available options:
squares, categorical, hdbscan, agent-3, agent-2, agent-1, agent-4, agent-5, agent-6, agent-7, agent-8, agent-9, custom-polygons Response
Grid GeoJSON file downloaded successfully. Returns a GeoJSON FeatureCollection containing polygon features with zone_id properties for the specified data scenario's grid configuration.
