integration.insert
This call inserts data for one or more signals. Each signal is uniquely identified by its input ID in combination with the integration ID. If no signal with the given combination exists, an empty signal is created.
An integration can only interact with it's own signals using this call.
Example
- cURL
- Python
- Go
# BASIC_AUTH_USERNAME=<Username from Basic Auth credentials>
# BASIC_AUTH_PASSWORD=<Password from Basic Auth credentials>
# INTEGRATION_ID=${BASIC_AUTH_USERNAME}
curl -u ${BASIC_AUTH_USERNAME}:${BASIC_AUTH_PASSWORD} \
--request POST \
--url https://api.clarify.io/v1/rpc \
--header 'Content-Type: application/json' \
--header 'X-API-Version: 1.1beta1' \
--data \
'
{
"jsonrpc" : "2.0",
"method": "integration.insert",
"id": "1",
"params": {
"integration": "'${INTEGRATION_ID}'",
"data":{
"times" : ["2021-03-11T21:00:00Z", "2021-03-11T22:00:00Z"],
"series": {
"a": [1.0, 1.2],
"b": [2.0, null]
}
}
}
}
'
from pyclarify.client import APIClient
from pyclarify.data import DataFrame
from datetime import datetime
client = APIClient(credentials=open("credentials.json"))
t1 = datetime.now()
t2 = t1 + datetime.timedelta(hours=1)
df = DataFrame(
times=[t1, t2],
series={
"a":[1.0, 1.2],
"b":[2.0, None],
},
)
client.insert(df)
package main
import (
"context"
"time"
clarify "github.com/clarify/clarify-go"
"github.com/clarify/clarify-go/data"
)
func main() {
creds, err := clarify.CredentialsFromFile("credentials.json")
if err != nil {
panic(err)
}
ctx := context.Background()
client := creds.Client(ctx)
t1 := data.AsTimestamp(time.Now())
t2 := t1.Add(data.Hour)
df := data.Frame{
"a": {t1: 1.0, t2: 1.2},
"b": {t1: 2.0},
}
if _, err := client.Insert(df).Do(ctx); err != nil {
panic(err)
}
}
Method parameters
Name | Type | Required | Description |
---|---|---|---|
integration | Integration ID | Yes | The ID if the integration to save signal information for. |
data | Data frame | Yes | The data to insert accompanied by timestamps. |
Result properties
Name | Type | Description |
---|---|---|
signalsByInput | map of Input ID => Save summary | Save operation summary per input. |
Rates and limits
API:
- The API is rate-limited to 1 request/sec.
- The JSON encoded size of the request MUST not be more than 9MiB.
Data property:
- Signals SHOULD not have an average same rate of more than 1 sample/min.
- Signals SHOULD not have a burst sample rate of more than 1 sample/sec.
- Clarify CAN NOT show timestamps with more than one millisecond resolution (ms).
- Clarify CAN NOT store timestamps with more than microsecond resolution (µs).
Billing:
- Signals above the amount allowed by your selected plan, may be charged.
Schema references
Data frame
Data frame holds data for one or more time-series.
type: object
Properties
Name | Type | Required | Description |
---|---|---|---|
times | array of Timestamp | Yes | Array of timestamps to insert. |
series | map of Input ID => array of (number or null ) | Yes | Array of data points to insert by Input ID. The length of each array must match that of the times array. To omit a value for a given timestamp in times , use the value null . |
Example
{
"times": [
"2021-03-11T21:49:00Z",
"2021-03-11T21:50:00Z",
"2021-03-11T21:51:00.00123Z",
"2021-04-08T00:00:00Z"
],
"series": {
"banana-stand-temp": [-10, 10, 20, 55.3, 231, 34],
"banana-stand-cash": [10000000, null, null, null, null, 0]
}
}
Input ID
Input ID routes data to a signal during insert. The input ID must be unique per integration only.
type: string(regex: ^[a-zA-Z0-9-_:.#+/]{1,128}$
)
Integration ID
Integration ID uniquely identities a integration resource entry.
type: string(regex: "^[a-v0-9]{20}$"
)
Save summary
type: object
Properties
Name | Type | Description |
---|---|---|
id | string | Unique ID of the saved resource entry. |
created | boolean | True if a new instance was created. |
Example
{
"id": "c9137visahsjsdhrim6g",
"created": true
}