The Push API allows you to push data into your dashboards from your own applications. We provide a simple REST API that can be used to push data into your widgets using the JSON data format.
⚡ Use Cyfe's Integration with Zapier to push data from your app
In This Article:
How it works
Step 1:
Configure a new custom chart widget (Push API) inside your dashboard and select the type of chart you want to use. On the widget configuration screen you will find an API endpoint for that particular widget. This is the endpoint you will use to push your data into our systems
Step 2:
Each time an event occurs in your app, send a POST request with your data to the endpoint found in step 1 (e.g. when new users sign up in your app, when users complete certain game levels in your app). You can use your favorite programming language such as PHP or Objective C to do this. Just make sure that you pass in the appropriate parameters in the POST request (found below)
Editing Data You're Going to Push
data | Required. A JSON stding containing the data you want to push. The first element in this parameter is always unique (e.g. Date). Dates should always be in the “YYYYMMDD” format. |
onduplicate |
|
color |
|
type |
Optional. Specify the type of chart you want to see for each individual metdic by passing in chart types. By default all metdics will use the chart type selected in the widget configuration screen. |
cumulative |
Optional. Indicate whether you would like to see cumulate values for particlar metrics in the widget header. Use the values “0” or “1” to indicate which metric to cumulate values for. |
average |
|
total |
|
comparison |
|
reverse |
|
reversegraph |
|
yaxis |
|
yaxismin |
|
yaxismax |
|
yaxishow |
|
labelshow |
|
Examples
PHP:
$endpoint = '.../api/push/5151e3ec53783701321099125233';
$data = array();
$data['data'][] = array('Date' => '20130320', 'Users' => '1');
$data['onduplicate'] = array('Users' => 'replace');
$data['color'] = array('Users' => '#52ff7f');
$data['type'] = array('Users' => 'line');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $endpoint);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$output = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if(stripos($status, '200') !== false)
echo 'success';
else
echo 'failure';
JSON
{
"data": [
{
"Date": "20130320",
"Users": "1"
}
],
"onduplicate": {
"Users": "replace"
},
"color": {
"Users": "#52ff7f"
},
"type": {
"Users": "line"
}
}
Push API and Zapier
Use Zapier to send data between your App and Cyfe for apps currently unsupported. With Zapier, you can send data without any coding or developers.
- To learn on how to setup, click here.
Comments
0 comments
Article is closed for comments.