Browse docs
API ReferenceUpdated August 21, 2024

Log

The log API is how you get data into Telemetry. These events could be anything from user interactions to system metrics, such as CPU usage spikes or memory leaks. The endpoint accepts data in any form of valid JSON, making it really easy to integrate into your code.

POST https://api.telemetry.sh/log

Headers

Name Type Description
Content-Type String application/json
Authorization String <YOUR_API_KEY>

Body

Name Type Description
table String The table where you want to log data
data JSON The data you want to log

Example Usage with cURL

To send Uber ride data to a table named uber_rides using cURL, you can use the following command:

curl -X POST https://api.telemetry.sh/log \
  -H "Content-Type: application/json" \
  -H "Authorization: $API_KEY" \
  -d '{
    "table": "uber_rides",
    "data": {
      "city": "paris",
      "price": 42,
      "timestamp": "'"$(date -u +"%Y-%m-%dT%H:%M:%SZ")"'"
    }
  }'

Using the JavaScript SDK

We recommend using our SDKs for a better developer experience. Here’s an example of how to use our JavaScript SDK:

import telemetry from "telemetry-sh";

telemetry.init("YOUR_API_KEY");

telemetry.log("uber_rides", {
  city: "paris",
  price: 42,
  timestamp: new Date().toISOString()
});

Bulk logging

You can also pass in an array of objects to bulk ingest events. This is useful for limiting the number of requests to the API. For example, instead of:

telemetry.log("uber_rides", { a: 1 })

You can do:

telemetry.log("uber_rides", [{a: 1}, {a: 2}])

This will ingest the data as two rows.