1-2-3-Easy Crossing Delay API Instructions
- Register at https://cascadegatewaydata.com/Account/Register
- Request API Access at https://cascadegatewaydata.com/Account/ViewAccount
- Append key to requests, for example https://cascadegatewaydata.com/CrossingLane/?id=3&start=01/02/2019&end=01/03/2019&data=avg-delay,avg-rate&dg=DayOfWeek&format=json&key=65d3b8f2-f44d-4b11-9956-b7aa010b190c
API Reference
- API Key
- Crossing
- CrossingLane
- Detector
- Current Delay For Crossing
- Returned Record Counts
- Returned Record Format
The Cascade Gateway Border Data Warehouse includes a Developer API that allows users to query the data warehouse and retrieve information in various formats including JSON and CSV. The API allows for the retrieval of data for crossings, crossing lanes and detectors.
API Key
A unique API Key is required to be included in your query. To obtain a key, register for an account, and then request a key from the user’s Account Details page.
Crossing Lanes
A crossing is a specific land port-of-entry and can be queried for both directions or by a single direction. A crossing lane can be queried using query string parameters in the format of: /CrossingLane?key=value¶m1=value¶m2=value...
Crossing Lane Ids can be retrieved using the following call that will retrieve all active Crossing Lanes:
/CrossingLane/?key=value&format=json
ExamplesExample 1: Average Delay and Average Service Rate, between Jan 1-2015 and Jan 3-2015, for crossing lane ID 3. Prepare JSON-formatted response.
CrossingLane/?id=3&start=01/01/2015&end=01/03/2015&data=avg-delay,avg-rate&format=json&key=TEST1234
Example 2: Average Delay and Average Service Rate, between Jan 1-2015 and Jan 3-2015, for crossing lane ID 3. Group results by day-of-the-week. Prepare JSON-formatted response.
CrossingLane/?id=3&start=01/01/2015&end=01/03/2015&data=avg-delay,avg-rate&dg=DayOfWeek&format=json&key=TEST1234
Parameter Definition
Parameter | Default Value | Description |
---|---|---|
id | A valid crossing ID. Use the listing function to get valid IDs. | |
year |
The year to query. Must be a valid 4-digit number. Note: When year is provided, start, end, dg, tg, moy and dow parameters are ignored. |
|
month | The month to query. Only used if year is provided. Must be a valid 1- or 2-digit number (1 to 12). | |
day | The day of the month to query. Only used if year and month are provided. Must be a valid 1- or 2-digit number (1 to last day in the month). | |
start |
The date on which to start querying, inclusive. Must be in format: mm/dd/yyyy. Note: when providing this parameter, end parameter must also be provided. |
|
end |
The date on which to stop querying, inclusive. Must be in format: mm/dd/yyyy. Note: when providing this parameter, start parameter must also be provided. |
|
data | avg-vol |
The metrics and aggregations to return. Must be a comma-separated list of aggregation-metric pairs:
Aggregations:
Metrics: |
dir |
The direction of travel through the crossing to filter for. Must be one of: Northbound Southbound Eastbound Westbound |
|
lane |
The lane type through this crossing to filter for. Must be one of: Unspecified Car Truck Bus Fast Nexus |
|
dg | Day |
The date grouping to use for results. Must be one of: Day DayOfWeek Month MonthOfYear Year All |
tg | Poll |
The time grouping to use for results. Must be one of: Poll Hour AmPm Day |
dow | 127 |
The days of the week to include in the results, represented as a bitmask of the
following values. For instance, to select all days, pass 127. To select just Thursday
and Friday, pass 48. Sunday– 1 Monday – 2 Tuesday – 4 Wednesday – 8 Thursday – 16 Friday – 32 Saturday – 64 |
moy | 4095 |
The months of the year to include in the results, represented as a bitmask of the
following values. For instance, to select all months, pass 4095. To select just
July and October, pass 576. January – 1 February – 2 March – 4 April – 8 May – 16 June – 32 July – 64 August – 128 September – 256 October - 512 November – 1024 December – 2048 |
format | JSON |
The desired output format of the data. Must be one of the following values: |
key | TEST1234 |
Unique key for each user. |
Crossing Lane
A crossing lane refers to a mode of travel within a Crossing. Lanes can be of type Unspecified, Car, Truck, Bus, Fast or Nexus. The data for the crossing lane can be retrieved in json or csv formats.
Crossing Lane Ids can be retrieved using the following call that will retrieve all active Crossing Lanes:
/CrossingLane/?format=json&key=value
ExamplesExample 1: Average Delay and Average Service Rate, between Jan 1-2020 and Mar 1-2020, for crossing lane ID 3. Prepare JSON-formatted response.
CrossingLane/?id=3&start=01/01/2020&end=03/01/2020&data=avg-delay,avg-rate&format=json&key=TEST1234
Parameter DefinitionParameter | Default Value | Description |
---|---|---|
id | A valid crossing lane ID. Use the listing function to get valid IDs. | |
year |
The year to query. Must be a valid 4-digit number. Note: When year is provided, start, end, dg, tg, moy and dow parameters are ignored. |
|
month | The month to query. Only used if year is provided. Must be a valid 1- or 2-digit number (1 to 12). | |
day | The day of the month to query. Only used if year and month are provided. Must be a valid 1- or 2-digit number (1 to last day in the month). | |
start |
The date on which to start querying, inclusive. Must be in format: mm/dd/yyyy. Note: when providing this parameter, end parameter must also be provided. |
|
end |
The date on which to stop querying, inclusive. Must be in format: mm/dd/yyyy. Note: when providing this parameter, start parameter must also be provided. |
|
data | avg-vol |
The metrics and aggregations to return. Must be a comma-separated list of aggregation-metric pairs:
Aggregations:
Metrics: |
dg | Day |
The date grouping to use for results. Must be one of: Day DayOfWeek Month MonthOfYear Year All |
tg | Poll |
The time grouping to use for results. Must be one of: Poll Hour AmPm Day |
dow | 127 |
The days of the week to include in the results, represented as a bitmask of the
following values. For instance, to select all days, pass 127. To select just Thursday
and Friday, pass 48. Sunday– 1 Monday – 2 Tuesday – 4 Wednesday – 8 Thursday – 16 Friday – 32 Saturday – 64 |
moy | 4095 |
The months of the year to include in the results, represented as a bitmask of the
following values. For instance, to select all months, pass 4095. To select just
July and October, pass 576. January – 1 February – 2 March – 4 April – 8 May – 16 June – 32 July – 64 August – 128 September – 256 October - 512 November – 1024 December – 2048 |
format | CSV |
The desired output format of the data. Must be one of the following values: |
key | TEST1234 |
Unique key for each user. |
Detector
Detector data can be queried for any active detector using query string parameters in the format of: /Detector?param1=value¶m2=value...
Detector Ids can be retrieved using the following call that will retrieve all active Detectors:
/Detector?format=json&key=TEST1234
ExamplesExample 1: Average Occupancy and Sum Volume, between Jan 1-2020 and Mar 1-2020, for detector ID 77. Prepare JSON-formatted response.
Detector/?id=77&start=01/01/2020&end=03/01/2020&data=avg-occ,sum-vol &format=json&key=TEST1234
Parameter DefinitionParameter | Default Value | Description |
---|---|---|
id | A valid detector ID. Use the listing function to get valid IDs. | |
year |
The year to query. Must be a valid 4-digit number. Note: When year is provided, start, end, dg, tg, moy and dow parameters are ignored. |
|
month | The month to query. Only used if year is provided. Must be a valid 1- or 2-digit number (1 to 12). | |
day | The day of the month to query. Only used if year and month are provided. Must be a valid 1- or 2-digit number (1 to last day in the month). | |
start |
The date on which to start querying, inclusive. Must be in format: mm/dd/yyyy. Note: when providing this parameter, end parameter must also be provided. |
|
end |
The date on which to stop querying, inclusive. Must be in format: mm/dd/yyyy. Note: when providing this parameter, start parameter must also be provided. |
|
data | avg-vol |
The metrics and aggregations to return. Must be a comma-separated list of aggregation-metric pairs:
Aggregations:
Metrics: |
dg | Day |
The date grouping to use for results. Must be one of: Day DayOfWeek Month MonthOfYear Year All |
tg | Poll |
The time grouping to use for results. Must be one of: Poll Hour AmPm Day |
dow | 127 |
The days of the week to include in the results, represented as a bitmask of the
following values. For instance, to select all days, pass 127. To select just Thursday
and Friday, pass 48. Sunday– 1 Monday – 2 Tuesday – 4 Wednesday – 8 Thursday – 16 Friday – 32 Saturday – 64 |
moy | 4095 |
The months of the year to include in the results, represented as a bitmask of the
following values. For instance, to select all months, pass 4095. To select just
July and October, pass 576. January – 1 February – 2 March – 4 April – 8 May – 16 June – 32 July – 64 August – 128 September – 256 October - 512 November – 1024 December – 2048 |
format | Table |
The desired output format of the data. Must be one of the following values: Note: Table and Chart formats return their values as a formatted HTML page. |
Current Delay For Crossing Lane
Returns the current delay reading for the given crossing lane
Format: /CrossingLane/CurrentDelay/{id}
Example: /CrossingLane/CurrentDelay/12?format=json&key=TEST1234
Parameter | Default Value | Description |
---|---|---|
id | A valid crossing lane ID. Use the listing function to get valid IDs. | |
format | json |
The desired output format of the data. Must be one of the following values:
|
key | TEST1234 |
Unique key for each user. |
Returned Record Counts
The number of returned records depends on the selection criteria and the date / time groupings. The data is available in 5 min increments meaning that there are 288 records per day. If a date / time grouping is selected the following record counts are expected.
Time Grouping | ||||
---|---|---|---|---|
Date Grouping | Poll | Hour | AmPm | Day |
Day | # of days * 288 | # of days * 24 | # of days * 2 | # of days |
DayOfWeek | up to 7 * 288 | up to 7 * 24 | up to 7 * 2 | up to 7 |
Month | # of months * 288 | # of months * 24 | # of months * 2 | # of months |
MonthOfYear | up to 12 * 288 | up to 12 * 24 | up to 12 * 2 | up to 12 |
Year | # of years * 288 | # of years * 24 | # of years * 2 | # of years |
All | 288 | 24 | 2 | 1 |
Returned Record Format
The returned record format depends on selected data points, aggregations and format.
JSON
The JSON output format has the following parts:
DataSources – description of each data points in the query.
GroupStarts – datetime that marks the beginning of each time grouping (Microsoft
DateTime format for JSON).
GroupPollCounts – number of records for each group starts.
Values – array of values for each data point / group start.
The following example demonstrates the JSON output for the following query (for
detector id =1, year 2009, get average volume, average occupancy, average speed
and average length)
Detector?id=1&year=2009&data=avg-vol,avg-occ,avg-spd,avg-len&format=json&key=TEST1234
Output for this query looks the following way:
{ "DataSources":[ { "ID":1,"Calculation":"Average","Metric":"VolumeVehiclesPerHour" }, { "ID":1,"Calculation":"Average","Metric":"OccupancyPercent" }, { "ID":1,"Calculation":"Average","Metric":"AverageSpeedKilometersPerHour" }, { "ID":1,"Calculation":"Average","Metric":"AverageVehicleLengthMeters" } ], "GroupStarts":[ 1230786000000,1233464400000,1235883600000, 1238558400000,1241150400000,1243828800000, 1246420800000,1249099200000,1251777600000, 1254369600000,1257048000000,1259643600000 ], "GroupPollCounts":[ 8928,8064,8928,8640,8928,8640,8928,8928,8640,8928,8640,8928 ], "Values":[ [2.7,2.6,2.6,2.7,2.6,2.8,2.8,2.9,2.8,2.6,2.6,2.5], [49.2,54,56.9,59,59,59,60.7,60.9,55.8,54.5,54.4,55.9], [7.2,7.2,7.2,7.4,7.2,7.6,7.3,7.5,7.5,5.9,5.4,4.7], [8.3,8.6,8.9,9.1,9,9.2,9.2,9.4,8.9,7.8,7.5,7.4] ] }
Where the Data Sources section describes all the data points requests (4 metrics)
Group Starts section returns 12 dates marking the start of each month.
Group Poll Counts describes the number of values for each group start (12 in total)
Values includes 4 arrays of values corresponding to each of the requested metrics. Each array has values corresponding to each group start. CSV
The CSV output returns the data in a format that includes the Group Start (date
time) and a column for each requested metric as a comma separated file. For the
same query as above the output is:
Group Starts,Avg(Volume),Avg(Occupancy),Avg(Avg Speed),Avg(Avg Vehicle Length)
2009-01-01 0:00,2.7,49.2,7.2,8.3
2009-02-01 0:00,2.6,54,7.2,8.6
2009-03-01 0:00,2.6,56.9,7.2,8.9
2009-04-01 0:00,2.7,59,7.4, 9.1
2009-05-01 0:00,2.6,59,7.2,9
2009-06-01 0:00,2.8,59,7.6,9.2
2009-07-01 0:00,2.8,60.7,7.3,9.2
2009-08-01 0:00,2.9,60.9,7.5,9.4
2009-09-01 0:00,2.8,55.8,7.5,8.9
2009-10-01 0:00,2.6,54.5,5.9,7.8
2009-11-01 0:00,2.6,54.4,5.4,7.5
2009-12-01 0:00,2.5,55.9,4.7,7.4