How to Stream Events via RESTful API
The full API documentation can be found at http://docs.initialstateeventsapi.apiary.io.
API usage example using cURL (video demo here):
If you don't have cURL installed, you can download it here: http://curl.haxx.se/download.html
Create a streaming Event BucketYou can try this cURL command, just replace the X-IS-AccessKey header value with one from your account.
curl --include \
--request POST \
--header "Content-Type: application/json" \
--header "X-IS-AccessKey: YOUR_KEY" \
--header "Accept-Version: ~0" \
--data-binary "{
\"bucketKey\": \"curl_example_bucket\",
\"bucketName\": \"cURL Example Bucket\"
}" \
'https://groker.initialstate.com/api/buckets'
Create a streaming Event Bucket (URL parameters, no headers):
You can try this cURL command, just replace the accessKey parameter value with one from your account.
curl --request POST 'https://groker.initialstate.com/api/buckets?accessKey=YOUR_KEY&bucketKey=curl_example_bucket&bucketName=cURL%20Example%20Bucket'
Send events to the bucket (iso8601 timestamp specified)You can try this cURL command, just replace the X-IS-AccessKey header value with one from your account. In this example, the timestamp is specified in iso8601.
curl --include \
--request POST \
--header "Content-Type: application/json" \
--header "X-IS-AccessKey: YOUR_KEY" \
--header "X-IS-BucketKey: curl_example_bucket" \
--header "Accept-Version: ~0" \
--data-binary "[
{
\"iso8601\": \"2015-10-08T07:54+06:00\",
\"key\": \"temperature\",
\"value\": \"25.4\"
}
]" \
'https://groker.initialstate.com/api/events'
Send events to the bucket (URL parameters, no headers, no timestamp, this also works using a GET)You can try this cURL command, just replace the accessKey parameter value with one from your account. In this example, the timestamp is specified in iso8601.
curl --request POST 'https://groker.initialstate.com/api/events?accessKey=YOUR_KEY&bucketKey=curl_example_bucket&temperature=25.4'
Send multiple events to the bucket at once (no timestamp)You can try this cURL command, just replace the X-IS-AccessKey header value with one from your account. In this example, no timestamp is specified so the server will provide the timestamp when it is received.
curl --include \
--request POST \
--header "Content-Type: application/json" \
--header "X-IS-AccessKey: YOUR_KEY" \
--header "X-IS-BucketKey: curl_example_bucket" \
--header "Accept-Version: ~0" \
--data-binary "[
{
\"key\": \"temperature\",
\"value\": \"22.2\"
},
{
\"key\": \"power\",
\"value\": \"6\"
},
{
\"key\": \"status\",
\"value\": \":thumbsup:\"
},
{
\"key\": \"current\",
\"value\": \"156\"
},
{
\"key\": \"door\",
\"value\": \"open\"
}
]" \
'https://groker.initialstate.com/api/events'
Send multiple events to the bucket at once (URL parameters, no headers, no timestamp, this also works using a GET)You can try this cURL command, just replace the accessKey parameter value with one from your account. In this example, the timestamp is specified in iso8601.
curl --request POST 'https://groker.initialstate.com/api/events?accessKey=YOUR_KEY&bucketKey=curl_example_bucket&temperature=22.2&power=6&status=:thumbs_up:¤t=156&door=open'
Send events to the bucket (epoch timestamp)You can try this cURL command, just replace the X-IS-AccessKey header value with one from your account. In this example, the timestamp is specified in epoch.
curl --include \
--request POST \
--header "Content-Type: application/json" \
--header "X-IS-AccessKey: YOUR_KEY" \
--header "X-IS-BucketKey: curl_example_bucket" \
--header "Accept-Version: ~0" \
--data-binary "[
{
\"epoch\": 1444309192,
\"key\": \"temperature\",
\"value\": \"27.8\"
}
]" \
'https://groker.initialstate.com/api/events'
Video demo of using the Initial State events API to send data into a dashboard via cURL commands (3:14):