This commit is contained in:
Dominik Werder
2024-09-26 10:01:20 +02:00
parent ce797d2025
commit 633eee5a95
11 changed files with 219 additions and 107 deletions

View File

@@ -3,7 +3,7 @@
Binned data can be fetched like this:
```bash
curl "https://data-api.psi.ch/api/4/binned?backend=sf-databuffer&channelName=S10BC01-DBPM010:Q1&begDate=2024-02-15T00:00:00Z&endDate=2024-02-15T12:00:00Z&binWidth="
curl "https://data-api.psi.ch/api/4/binned?backend=sf-databuffer&channelName=S10BC01-DBPM010:Q1&begDate=2024-02-15T00:00:00Z&endDate=2024-02-15T12:00:00Z&binWidth=5m"
```
Parameters:
@@ -15,7 +15,7 @@ Parameters:
`1h` for 1 hour.
- `binCount`: requested number of bins, can not be combined with `binWidth`.
- `contentTimeout`: return the so-far computed results after the given timeout.
The streaming (e.g. `json-framed`) response will yield results in `contentTimeout` intervals.
When streaming content was requested (e.g. `json-framed`) the response will yield results in `contentTimeout` intervals.
- `allowLargeResult=true` **DEPRECATED, will be rejected in the future**
indicates that the client is prepared to accept also larger responses compared to
what might be suitable for a typical browser. Please download large result sets as
@@ -27,10 +27,41 @@ Note: it is an error to specify both `binWidth` and `binCount`.
The server may return more than `binCount` bins, and it will choose a `binWidth` from a set of
supported widths to best possibly match the requested width.
If the service was not able to complete a single bin within the timeout it returns HTTP 504.
For each bin both edges are returned (ts1 and ts2) in order to maybe support sparse and varying-width
binned responses in the future.
The json response contains timestamps in the form `TIMESTAMP = ANCHOR + MILLIS + NANOS`.
Example response, truncated to 4 bins:
```json
{
"tsAnchor": 1726394700,
"ts1Ms": [
0,
300000,
600000,
900000
],
"ts2Ms": [
300000,
600000,
900000,
1200000
],
"ts1Ns": [
0,
0,
0,
0
],
"ts2Ns": [
0,
0,
0,
0
],
"avgs": [
0.010802877135574818,
0.010565019212663174,
@@ -54,41 +85,18 @@ Example response, truncated to 4 bins:
0.0040797283872962,
0.004329073242843151,
0.004934651777148247
],
"ts1Ms": [
0,
300000,
600000,
900000
],
"ts1Ns": [
0,
0,
0,
0
],
"ts2Ms": [
300000,
600000,
900000,
1200000
],
"ts2Ns": [
0,
0,
0,
0
],
"tsAnchor": 1726394700
]
}
```
Note: the fields `ts1Ns` and `ts2Ns` may be omitted in the response if they are all zero.
## As framed JSON stream
To download larger amounts data as JSON it is recommended to use the `json-framed` content encoding.
Using this encoding, the server can send the requested events as a stream of json objects, where each
json object contains a batch of events.
json object contains a batch of bins.
This content encoding is triggered via the `Accept: application/json-framed` header in the request.
The returned body looks like:
@@ -108,4 +116,4 @@ where each `[JSON-frame]` looks like:
```
Note: "data" objects are currently identified by the presence of the `ts1s` key.
There can be other types of objects, like keepalive, log or statistics.
There can be other types of objects, like keepalive, log messages or request metrics.

View File

@@ -31,6 +31,46 @@ the key `continueAt` which indicates that the response is incomplete and that th
issue another request with `begDate` as given by `continueAt`.
By default, or explicitly with `Accept: application/json` the response will be a json object.
Example response:
```json
{
"tsAnchor": 1727336613,
"tsMs": [
3,
13,
23,
33
],
"tsNs": [
80998,
80999,
81000,
81001
],
"pulseAnchor": 22238080000,
"pulseOff": [
998,
999,
1000,
1001
],
"values": [
-0.005684227774617943,
-0.0056660833356960184,
-0.005697272133280464,
-0.005831689871131955
]
}
```
The timestamp of each event is `TIMESTAMP = ANCHOR + MILLIS + NANOS`.
Note: the field `tsNs` may be omitted in the response if they are all zero.
## Events as framed JSON stream
To download larger amounts data as JSON it is recommended to use the `json-framed` content encoding.