The Toit console provides a publicly available gRPC API with API packages and examples for Java, Python, Dart, C# and NodeJS, allowing a client application to do all public operations on the Toit console.

The service is available on: https://api.toit.io.

The API is guarded so all requests should be authorized with Authorization: Bearer access-token. with the access-token available using the toit.api.Auth service.

API keys

Create an API key to be used when connecting server applications to the API.

Navigate to the API keys section in the Toit console and press the Create API key button.

Then, view (and copy) the API key secret.

Navigate to the API keys section in the Toit console and view the API key secret by clicking the key icon.

The API key secret must be used when creating the connection - in your server application - to the Toit Cloud. See examples of how to create the connection using the API key secret in the demo repository, where we provide examples of API usage in four different programming languages: NodeJS, Java, Go, and Python.

Data API

The Toit console provides a data ingestion API. The type of data to be ingested is grouped into two groups:

  • Metrics - measurement at a point in time for the system generated by the metrics library.
  • Logs - system generated set of data that describe an event generated by the logs library.

For application data, use the bi-directional PubSub API.

Metrics and logs are collected on the device by the system process from your application code and sent to the Toit cloud, where it will be grouped and available for ingestion.

Data subscriptions

Data in the Toit console is grouped into the types: Metrics and Logs. For each type, a Toit project can have multiple subscriptions. A subscription is simply a cursor managed by the Toit console on which messages the subscriber has read. Every time a message has been read it needs to be acknowledged by the subscriber in order to move the subscription cursor forward, permanently. Each message must be acknowledged before the acknowledge deadline (10 minutes by default), otherwise it will be enqueued again.

If a subscription is more than 7 days behind, messages will be pruned and missed by the subscriber.

It is possible to do concurrent reads on one subscription. When doing so, the concurrent reads will receive different batches of the same data set, making it easier to make ingestion concurrent.

Create a subscription for logs or metrics

Go to the Data section in the Toit console, choose either the Logs or Metrics tabs, click on Create Subscription, and add a name to the subscription to create.

Use the CLI commands to acknowledge messages for a subscription.