Our public API uses the ISO/IEC 20802-2 Standard known as OData JSON Format v4.
Thank you ahead of time for using this data responsibly and providing the appropriate citations when necessary when being presented to external parties. These citations must be accompanied by a link to the DOI (https://doi.org/{value}). The licence, citation, and DOI can be retrieved from the /Metadata endpoint.
We have built modules to wrap around our API to make it easier to use.
RPython(future)JavaScript(future)
You can test out your script by prefixing https://qa-api.datastream.org/v1/odata/v4 to the endpoints.
When you're ready to pull data from the production system you can use: https://api.datastream.org/v1/odata/v4.
For browser requests all you need to do is let us know your domain name and we can add it to the CORS whitelist, only GET requests are supported. All other application should store the API Key in the header x-api-key.
Remember that your API key is for your use only. Please do not share your API key. If it does become public, please let us know, we can give you a new one.
-
GET /Metadata
- Select By:
Id,Name,Abstract,Citation,DataStewardEmail,DataCollectionOrganization,DataCollectionInformation,DataProcessing,DataUploadOrganization,DataSources,FundingSources,Licence,Disclaimer,Doi,TopicCategories,Keywords,Version,CreateTimestamp - Filter By:
Id,Name,Doi,CreateTimestamp,RegionId,Latitude,Longitude,LatitudeNormalized,LongitudeNormalized - Order By:
Name,CreateTimestamp
- Select By:
-
POST /Metadata (Future)
- Type:
metadata - Body:
Name,Abstract,Citation,DataStewardEmail,DataCollectionOrganization,DataCollectionInformation,DataProcessing,DataUploadOrganization,DataSources,FundingSources,Licence,Disclaimer,Doi,TopicCategories,Keywords
- Type:
-
PATCH /Metadata?@DatasetId= (Future)
- Type:
metadata - Body:
Name,Abstract,Citation,DataStewardEmail,DataCollectionOrganization,DataCollectionInformation,DataProcessing,DataUploadOrganization,DataSources,FundingSources,Licence,Disclaimer,TopicCategories,Keywords
- Type:
-
GET /Locations
- Select By:
Id,DatasetId,NameId,Name,Latitude,Longitude,HorizontalCoordinateReferenceSystem,LatitudeNormalized*,LongitudeNormalized*,HorizontalCoordinateReferenceSystemNormalized* - Filter By:
Id,Name,Doi,CharacteristicName,RegionId,Latitude,Longitude,LatitudeNormalized,LongitudeNormalized - Order By:
Name
* Normalized coordinates are in
WGS84projection. - Select By:
-
GET /Observations
- Select By:
Id,DatasetId,LocationId,ActivityType,ActivityStartDate,ActivityStartTime,ActivityEndDate,ActivityEndTime,ActivityDepthHeightMeasure,ActivityDepthHeightUnit,SampleCollectionEquipmentName,CharacteristicName,MethodSpeciation,ResultSampleFraction,ResultValue,ResultUnit,ResultValueType,ResultDetectionCondition,ResultDetectionQuantitationLimitUnit,ResultDetectionQuantitationLimitMeasure,ResultDetectionQuantitationLimitType,ResultStatusId,ResultComment,ResultAnalyticalMethodId,ResultAnalyticalMethodContext,ResultAnalyticalMethodName,AnalysisStartDate,AnalysisStartTime,AnalysisStartTimeZone,LaboratoryName,LaboratorySampleId,ActivityDepthHeightMeasureNormalized,ActivityDepthHeightUnitNormalized,ResultValueNormalized,ResultUnitNormalized,ResultDetectionQuantitationLimitMeasureNormalized,ResultDetectionQuantitationLimitUnitNormalized,CreateTimestamp - Filter By:
DatasetId,LocationId,Doi,ActivityStartDate,ActivityStartTime,ActivityType,CharacteristicName,MethodSpeciation,ResultSampleFraction,RegionId,LatitudeNormalized,LongitudeNormalized,MonitoringLocationType - Order By:
ActivityStartDate,ActivityStartTime,CharacteristicName
- Select By:
-
GET /Records
- Select By:
Id,DatasetName,MonitoringLocationID,MonitoringLocationName,MonitoringLocationLatitude,MonitoringLocationLongitude,MonitoringLocationHorizontalCoordinateReferenceSystem,MonitoringLocationType,ActivityType,ActivityMediaName,ActivityStartDate,ActivityStartTime,ActivityEndDate,ActivityEndTime,ActivityDepthHeightMeasure,ActivityDepthHeightUnit,SampleCollectionEquipmentName,CharacteristicName,MethodSpeciation,ResultSampleFraction,ResultValue,ResultUnit,ResultValueType,ResultDetectionCondition,ResultDetectionQuantitationLimitMeasure,ResultDetectionQuantitationLimitUnit,ResultDetectionQuantitationLimitType,ResultStatusID,ResultComment,ResultAnalyticalMethodID,ResultAnalyticalMethodContext,ResultAnalyticalMethodName,AnalysisStartDate,AnalysisStartTime,AnalysisStartTimeZone,LaboratoryName,LaboratorySampleID - Filter By:
Id,DatasetName,MonitoringLocationID,MonitoringLocationName,MonitoringLocationLatitude,MonitoringLocationLongitude,MonitoringLocationHorizontalCoordinateReferenceSystem,MonitoringLocationType,ActivityType,ActivityMediaName,ActivityStartDate,ActivityStartTime,ActivityEndDate,ActivityEndTime,ActivityDepthHeightMeasure,ActivityDepthHeightUnit,SampleCollectionEquipmentName,CharacteristicName,MethodSpeciation,ResultSampleFraction,ResultValue,ResultUnit,ResultValueType,ResultDetectionCondition,ResultDetectionQuantitationLimitMeasure,ResultDetectionQuantitationLimitUnit,ResultDetectionQuantitationLimitType,ResultStatusID,ResultComment,ResultAnalyticalMethodID,ResultAnalyticalMethodContext,ResultAnalyticalMethodName,AnalysisStartDate,AnalysisStartTime,AnalysisStartTimeZone,LaboratoryName,LaboratorySampleID,RegionID - Order By:
DatasetName,ActivityStartDate,ActivityStartTime,ActivityEndDate,ActivityEndTime,CharacteristicName
- Select By:
-
POST /Records?@DatasetId=
- Type:
record - Max Items: 10
- Body:
DatasetName,MonitoringLocationID,MonitoringLocationName,MonitoringLocationLatitude,MonitoringLocationLongitude,MonitoringLocationHorizontalCoordinateReferenceSystem,MonitoringLocationType,ActivityType,ActivityMediaName,ActivityStartDate,ActivityStartTime,ActivityEndDate,ActivityEndTime,ActivityDepthHeightMeasure,ActivityDepthHeightUnit,SampleCollectionEquipmentName,CharacteristicName,MethodSpeciation,ResultSampleFraction,ResultValue,ResultUnit,ResultValueType,ResultDetectionCondition,ResultDetectionQuantitationLimitMeasure,ResultDetectionQuantitationLimitUnit,ResultDetectionQuantitationLimitType,ResultStatusID,ResultComment,ResultAnalyticalMethodID,ResultAnalyticalMethodContext,ResultAnalyticalMethodName,AnalysisStartDate,AnalysisStartTime,AnalysisStartTimeZone,LaboratoryName,LaboratorySampleID
- Type:
{
"@data.context": "odata/v4/Records/$links/Metadata(Id=@DatasetId)"
"value":[
...
]
}OData accepts certain query parameters. The ones supported by this API are:
- $select
- Fields to be selected are entered comma delimited.
- Example:
$select=Name,Abstract - Default: All columns available.
- $orderby
- Fields to order by are entered comma delimited.
- Example:
$orderby=Name,CreateTimestamp
- $filter
- Available filters:
eq,lt,gt,lte,gte,ne - Grouping:
$filter=CharacteristicName eq 'Dissolved oxygen saturation'or$filter=Doi eq '10.25976/n02z-mm23' - Temporal:
$filter=CreateTimestamp gt '2020-03-23' and CreateTimestamp lt '2020-03-25' - Spatial:
$filter=RegionId eq 'hub.atlantic'- RegionId Values (We're actively working on these, values will change):
- Partner Hubs:
hub.{atlantic,lakewinnipeg,mackenzie} - Countries:
admin.2.{ca} - Provinces/Territories/States:
admin.4.ca-{ab,bc,...,yt} - Watersheds/Drainage Areas:
watershed.oda.*,watershed.mda.*,watershed.sda.*,watershed.ssda.*(Future) - Water:
waterbody.marine.*,waterbody.greatlakes.*,waterbody.lakes.*,waterbody.rivers.*(Future)
- Partner Hubs:
- Bounding box
$filter=LongitudeNormalized gt '-102.01' and LongitudeNormalized lt '-88.99' and LatitudeNormalized gt '49' and LatitudeNormalized lt '60'
- RegionId Values (We're actively working on these, values will change):
- Available filters:
- $top
- Maximum: 10000
- Example:
$top=10
- $skip
- Example:
$skip=10
- Example:
- $skiptoken
- Return the next items after the skipped token, cannot be paired with
$orderby - Example:
$skiptoken=Id:1234
- Return the next items after the skipped token, cannot be paired with
- $count
- Return only the count for the request. When the value is large enough it becomes and estimate (~0.0005% accurate)
- Example:
$count=true - Default:
false
When building an integration with any API, it's important to URL encode all query string parameters.
- Using
$selectto request only the parameters you need will decrease the amount of data needed to be transfer. - Using large
$skipvalues can be slow (it's a database thing), slicing your data byGeometryIdand/orCharacteristicNamewill help prevent this. - Don't use
$orderbyunless you plan to pull a smaller number of results.
Get the citation and licence for a dataset:
curl -G -H 'x-api-key: PRIVATE-API-KEY' \
https://api.datastream.org/v1/odata/v4/Metadata \
--data-urlencode "\$select=Name,Licence,Citation,Doi,Version" \
--data-urlencode "\$filter=DatasetId eq '0000-00000-00000-00000'" \Get all pH observations in Alberta:
curl -G -H 'x-api-key: PRIVATE-API-KEY' \
https://api.datastream.org/v1/odata/v4/Observations \
--data-urlencode "\$filter=CharacteristicName eq 'pH' and GeometryId eq 'iso.3166-2.ab'"{
"value": [{
"Id": "UUID",
...
}],
"@odata.nextLink": "https://api.datastream.org/v1/odata/v4/Observations?$skiptoken=Id:99999&$top=1000"
}This means your request result was too large. Lowering $top or only requesting the values you need should resolve this issue.
This means your request was too complicated and was unable to complete within 30sec. Lowering $top should resolve this issue.
We are currently in a Beta, changes will happen. We will do our best effort to keep you informed of any breaking changes.