Documentation
Basics
-
ACCOUNT TYPES
Currently we offer free or individual API accounts. Free access is restricted in terms of the time series and resolutions that can be queried. Moreover, stricter limits apply and it is not possible to choose the time period for the values to be queried.
However, it is still possible to obtain complete, gapless time series if the requests are issued periodically within the limits.
For a summary of the current capabilities of your account, check out the overview.
If the free access does not meet your needs, please feel free to contact us.
-
HTTP REQUEST METHODS
POST or GET request method can be used via HTTPS only connection.
-
AUTHENTICATION
A security token must be included in every request. The prefered method is to include the token as authorization header.
Example header:Authorization: Bearer your-tokenAlternatively the token can be included as key value pair in the JSON object sent by the POST method.
Example POST request:{ "token": "your-token" }Or via token url paramter using the GET method.
Example GET request:https://api.gridradar.net/?token=your-token -
LIMITS
If exceeded, a corresponding message and error code 429 is returned. Limits apply to each account and metric individually.
- General LIMITS
API Description
-
HELP
The following example uses the curl command to POST a JSON object to the
Example curl POST request:/helpendpoint forcing a response in HTML format.curl -i -X POST \ -H "Content-Type: application/json" \ -H "Authorization: Bearer your-token" \ -d '{"format":"html"}' \ https://api.gridradar.net/helpThe API description below is the HTML response to this API call with some custom CSS style attached.
- ENDPOINTS
/ Test security token /help Returns this API short description. /attrib Shows account infos. /metrics List of metric names permitted for the transmitted security token. /alerts Alert management endpoint. /search List of metric names (grafana compatibility). /pmus List of phasor measurement units permitted for the transmitted security token. /areas List of synchronous grid areas permitted for the transmitted security token. /tso List of available transmission system operators. /ranges List of timestamps for the first and last value of the phasor measurement units. /aggr_functions Available aggregation functions and selectors /aggregations Available aggregation units /formats Available response formats /ts_formats Available timestamp formats /fill Available fill actions /query Time series data endpoint. - GENERAL URL PARAMETERS
help Returns a descriptive string for the called endpoint format Sets the response format (e.g.: format=json) token An alternative option if the security token cannot be included as 'Authorization: Bearer [token]' header - ENDPOINT SPECIFIC PARAMETERS
/help?html Shows a HTML version of this help /metrics all Optinally include existing not permitted metrics (e.g. /metrics?all). grp Optinally include the metric group name (e.g. /metrics?all&grp). filter Optinally list only metrics matching the specified filter (e.g. /metrics?all&grp&filter=forecast).
If the filter parameter is set without a filter value, a list of possible filter values is returned./pmus all Optinally lists all existing phasor measurement units (e.g. /pmus?all) sync Optinally include synchronous areas (e.g.: /metrics?all&sync). filter Optinally list only PMUs matching the specified filter (e.g.: /metrics?all&grp&filter=DE).
If the filter parameter is set without a filter value, a list of allowed filter values is returned./areas?all Lists all available synchronous grid areas. /search?ep Returns the result of supported endpoints as a list.
Can be combined with the endpoint specific arguments 'all' and 'filter'.
(e.g.: search?ep=metrics&filter=60hz)
If no 'ep' parameter value is set, a list of supported endpoints is returned.
Not specifying the 'ep' parameter at all is equivalent to ep=metrics./ranges?all Lists the data time range of all existing phasor measurement units /query metric The key name of the time series to be queried format Sets the response format (default: format=json) ts Sets the response timestamp format (default: ts=rfc3339) func An aggregation or selector function to aggregate data (default: first) aggr The duration literal specifying the aggregation level of the time series data (default: aggr=1s) pmus A CSV list of PMU keys for which time series data should be included in the response (e.g.: pmus=wien,dresden,..). area A single synchronous area key (currently supported only by median metrics) tso A CSV list of transmission system operators and directions (mandatory for afrr-activated-15m metric, see /tso endpoint for supported values) fill Optional fill action for missing values (default: null) from Optional rfc3339 timestamp representing the time series data start time (e.g.: from=2021-01-08T00:00:00.5Z)
If omitted, the last timestamp of the previous query plus one aggregation unit step is usedto Optional rfc3339 timestamp representing the time series data end time (e.g.: to=2021-01-08T00:00:00.5Z)
Requireds from timestamp
If omitted, the current time is usedrt For real-time metrics only.
Ensures that there are no gaps at the end of the series included in a real-time response.
By default, the API returns what is available at the time of the request, which can lead to a mixture of complete and incomplete series.
This parameter eliminates the need to permanently handle gaps using overlapping time spans, making it much simpler to query continuous measurements as fast as possible. The from/to parameters are not necessary anymore.
NOTE: An integer number representing a real-time threshold in seconds can optionally be set as parameter value.
E.g.: If at the time of a request (ts_now) for any reason no new measurements of a PMU exist since the timestamp of the last delivered value (ts_last) and the difference (ts_now - ts_last) is below the real-time threshold, the delivery is postponed for all PMUs until the next request and an empty result is returned instead. This repeats until at least the next measurement after ts_last is available for all pmus specified by pmus parameter or the realtime threshold is exceeded.
If the time difference exceeds the threshold, the one PMU without data gets excluded from the response and all timestamps since ts_last with complete measurements for the remaining PMUs are returned.
Specifying the rt parameter without a threshold value is equivalent to rt=0 and causes the request interval to act as the realtime threshold./alerts all Lists all existing alerts status Show alerts with the specified status value
Status value can be one of:enabled show only permitted and enabled alerts disabled show only permitted and disabled alerts enable Turn on notifications of the specified alert key disable Turn off notifications of the specified alert key include_img If the 'include_img' parameter is combined with 'enable', an image will be included in the alert mail. - HTTP CODES
200 Request was successful 400 Invalid api call (e.g.:malformed query arguments) 401 Failed authentication (e.g.: unknown security token) 403 Lack of permission for the transmitted security token to process the request 408 Timeout 429 Some limit exceeded 500 Unexpected errors
Response Formats
-
JSON
The default response format is JSON. The example below calls the
Example querying available response formats using Python:/formatsendpoint and does not use any parameters. The response is a JSON object containing all available response format keys and a corresponding description line.
JSON response:import requests url = 'https://api.gridradar.net/formats' headers = { 'Content-type': 'application/json', 'Authorization': 'Bearer your-token' } response = requests.post(url, headers=headers) print(response.content){ "columns":["response format","description"], "data":[ ["json","Json object"], ["csv","Comma separated list"], ["xml","XML document"], ["html","HTML Table"] ] } -
CSV / HTML / XML
Repeating the previous example but with the format parameter specified results in the following responses.
Requesting CSV response:
CSV response:json_request = '{"format":"csv"}' response = requests.post(url, data=json_request, headers=headers)
HTML response:response format,description json,Json object csv,Comma separated list xml,XML document html,HTML Table
XML response:<table border="1" class="dataframe" id="formats"> <thead> <tr style="text-align: right;"> <th>response format</th> <th>description</th> </tr> </thead> <tbody> <tr> <td>json</td> <td>Json object</td> </tr> <tr> <td>csv</td> <td>Comma separated list</td> </tr> <tr> <td>xml</td> <td>XML document</td> </tr> <tr> <td>html</td> <td>HTML Table</td> </tr> </tbody> </table><?xml version='1.0' encoding='utf-8'?> <data> <row> <response_format>json</response_format> <description>Json object</description> </row> <row> <response_format>csv</response_format> <description>Comma separated list</description> </row> <row> <response_format>xml</response_format> <description>XML document</description> </row> <row> <response_format>html</response_format> <description>HTML Table</description> </row> </data>
Query Parameters And Examples
-
ACCOUNT TYPE: Free
Free users currently have permissions to call the
Example arguments for the metric key:/queryendpoint using the metric keysfrequency-ucte-median-1sandnet-timewithout the time range argumentsfromandto. The start timestamp is calculated based on the timestamp of the last value in the previous query response. The maximum time range a response may contain is one hour.frequency-ucte-median-1s{ "metric":"frequency-ucte-median-1s" }The example above is the short form of the next request JSON object.
{ "metric":"frequency-ucte-median-1s", "format":"json", "ts":"rfc3339", "aggr": "1s" }The following
curlcommand example returns the minimum frequency per minute
Example arguments for the metric key:curl -i -X POST \ -H "Content-Type: application/json" \ -H "Authorization: Bearer your-token" \ -d '{"metric":"frequency-ucte-median-1s", "func":"min", "aggr":"1m"}' \ https://api.gridradar.net/querynet-time{ "metric":"net-time" }The
net-timemetric returns the deviation from UTC time in seconds. The previous example is the short form of the request below.{ "metric":"net-time", "format":"json", "ts":"rfc3339", "aggr":"1s", "fill":"none" }The next
curlcommand uses the GET method to query the net time.curl 'https://api.gridradar.net/query?token=your-token&metric=net-time' -
ACCOUNT TYPE: Individual
Individual users have permission to query the
Querying the 100ms frequency of two PMUs using Python:/queryendpoint with additional metric name keys, where the time range argumentsfromandtocan also be used. For certain metrics it may be necessary to specify special arguments, such aspmusfor the metricsfrequencyandphase-angleto define a selection of measuring stations. Depending on the agreement, access can be subject to different limitations. Accessibility of measurement stations can be extended from single locations, whole countries up to the complete network. The minimum query interval can be reduced to 3 seconds with a maximum resolution of 100ms.
The response contains two time series:#!/usr/bin/python3 import requests import json import pprint ## Request and header parameters token = 'your-token' url = 'https://api.gridradar.net/query' headers = { 'Content-type': 'application/json', 'Authorization': 'Bearer '+token } ## API query parameters request = { "metric":"frequency", "pmus":"neustadt,dresden", "from":"2021-05-26T02:36:17.3Z", "to":"2021-05-26T02:36:17.6Z", "aggr":"100ms", "format":"json", "ts":"rfc3339" } ## Converting the Python dictionary to a JSON string json_request = json.dumps(request) ## Request execution and response reception response = requests.post(url, data=json_request, headers=headers) ## Converting the JSON response string to a Python dictionary result_dict = json.loads(response.content) ## Pretty print response dictionary pprint.pprint(result_dict)NOTE: The JSON response format of all endpoints is compatible with the Grafana JSON datasource plugins.
Example response to a limit violation:[ { "target": "neustadt", "datapoints": [ [ 49.9897, "2021-05-26 02:36:17.300" ], [ 49.9893, "2021-05-26 02:36:17.400" ], [ 49.9888, "2021-05-26 02:36:17.500" ], [ 49.9887, "2021-05-26 02:36:17.600" ] ] }, { "target": "dresden", "datapoints": [ [ 49.9921, "2021-05-26 02:36:17.300" ], [ 49.9918, "2021-05-26 02:36:17.400" ], [ 49.9906, "2021-05-26 02:36:17.500" ], [ 49.9906, "2021-05-26 02:36:17.600" ] ] } ]{ "columns":["code","msg"], "data":[ [429,"Limitation: minimum request interval"] ] }
Data Aggregation And Selection
-
If you require downsampling of the desired time series to a lower resolution, or if it's necessary to perform transformations or selections of particular values within a successive time range, a corresponding function must be specified via the
funcparameter. By default, thefirstselector function is used, which has no effect if theaggrparameter is set to the maximum resolution of the requested time series (see the PREC [ms] column of the PMU tables).
EXAMPLES Obtaining a list of available functions
Selecting the first phase-angle measurement of every second using default aggregation settings:curl 'https://api.gridradar.net/aggr_functions?token=your-token'
Aggregating the 100ms frequency to it's one minute average:{ "metric":"phase-angle", "pmus": ..., ... } ## e.g. returned timestamps of the selected values: ## 2021-05-26 02:36:01.0, ## 2021-05-26 02:36:02.0
Calculating the difference of subsequent 10 seconds average frequency values:{ "metric":"frequency" "func":"mean", "aggr":"1m" "pmus": ..., ... } ## e.g. returned timestamps of the result values: ## 2021-05-26 02:36:00.0, ## 2021-05-26 02:37:00.0NOTE: The
differencefunction always uses a nestedmeanfunction, which has no effect if theaggrparameter is set to the maximum resolution.{ "metric":"frequency" "func":"difference", "aggr":"10s" "pmus": ..., ... } ## e.g. returned timestamps of the result values: ## 2021-05-26 02:36:00.0, ## 2021-05-26 02:36:10.0