Date and time (Historical data)
Specifying a date and time to send data to is optional. By doing so, you can store historical data, create more sophisticated graphs, and analyze trends right away.
Event data that is sent to Databox typically doesn’t need a ‘date’ property, since the event triggered the send at the appropriate time. Therefore, by default the timestamp is accurate.
However, when sending data for events in the past or even in future, the date property allows you to store data to a specific point in time.
- cURL
- PHP
- JavaScript
- Java
- Go
- Python
- C#
curl https://push.databox.com \
-u <your_token>: \
-X POST \
-H 'Content-Type: application/json' \
-H 'Accept: application/vnd.databox.v2+json' \
-d '{
"data":[
{
"$conversion_rate" : 0.09,
"date" : "2024-09-08"
},
{
"$conversion_rate" : 0.19,
"date" : "2024-09-10T02:00:00Z"
}
]
}'
<?php
require_once __DIR__ . '/../../../vendor/autoload.php';
use Databox\Api\DefaultApi;
use Databox\ApiException;
use Databox\Configuration;
use Databox\Model\PushData as DataboxPushData;
use GuzzleHttp\Client;
execute();
function execute()
{
// Configure HTTP basic authorization: basicAuth
$config = Configuration::getDefaultConfiguration()
->setHost('https://push.databox.com')
->setUsername('<your_token>');
$headers = [
'Content-Type' => 'application/json',
'Accept' => 'application/vnd.databox.v2+json'
];
$apiInstance = new DefaultApi(
new Client(['headers' => $headers]),
$config
);
try {
$apiInstance->dataPost([
(new DataboxPushData())
->setKey('conversion_rate')
->setValue(0.09)
->setDate('2024-09-08'),
(new DataboxPushData())
->setKey('conversion_rate')
->setValue(0.19)
->setDate('2024-09-10T00:00:00Z')
]);
echo "Successfully pushed data to Databox";
} catch (ApiException $e) {
echo 'Exception when calling DefaultApi->dataPost: ' . $e->getMessage() . PHP_EOL . $e->getResponseBody() . PHP_EOL;
}
}
import {
ApiResponse,
Configuration,
DataPostRequest,
DefaultApi,
} from "databox";
const config: Configuration = new Configuration({
basePath: "https://push.databox.com",
username: "<your_token>",
headers: {
Accept: "application/vnd.databox.v2+json",
},
});
const dataPostRequest: DataPostRequest = {
pushData: [
{
key: "conversion_rate",
value: 0.09,
date: "2024-09-08",
},
{
key: "conversion_rate",
value: 0.19,
date: "2024-09-10T00:00:00Z",
}
],
};
const api = new DefaultApi(config);
try {
api
.dataPostRaw(dataPostRequest)
.then((response: ApiResponse<void>) => response.raw.json())
.then((responseBody) => {
console.log("Response data", responseBody);
});
} catch (error) {
console.log("Error: ", error);
}
import org.databox.ApiClient;
import org.databox.ApiException;
import org.databox.Configuration;
import org.databox.api.DefaultApi;
import org.databox.auth.HttpBasicAuth;
import org.openapitools.client.model.PushData;
import java.util.List;
public class PushDataExample {
public static void main(String[] args) {
ApiClient defaultClient = Configuration.getDefaultApiClient();
defaultClient.setBasePath("https://push.databox.com");
defaultClient.addDefaultHeader("Accept", "application/vnd.databox.v2+json");
HttpBasicAuth basicAuth = (HttpBasicAuth) defaultClient.getAuthentication("basicAuth");
basicAuth.setUsername("<your_token>");
DefaultApi apiInstance = new DefaultApi(defaultClient);
try {
apiInstance.dataPost(List.of(
new PushData()
.key("conversion_rate")
.value(0.09f)
.date("2024-09-08"),
new PushData()
.key("conversion_rate")
.value(0.19f)
.date("2024-09-10T00:00:00Z")
));
} catch (ApiException e) {
e.printStackTrace();
}
}
}
// Example not available yet, check other languages
# Example not available yet, check other languages
// Example not available yet, check other languages
Dates format like ‘YYYY-MM-DD’ (i.e. 2018-01-19) will translate to 2018-01-19 00:00:00 UTC. If you omit the date parameter, the current date and time (in UTC) will be used by default. To avoid discrepancies in your data, you should double-check that all of your data has a timezone specified, or is in UTC. Learn more about time zones