HTTP API
Ditto offers an HTTP API that you can use to programmatically interact with the Big Peer. The Big Peer is an optional feature that you can use for managing and coordinating data in the peer-to-peer mesh network. For more information, see Platform Manual > Big Peer.
The HTTP API is designed following the principles of the remote procedure call (RPC) framework. So, despite the actual exchange occuring over a network, you make requests from Ditto's APIs as if making local calls.
This article provides an overview of the HTTP API:
The remote procedure call (RPC) framework is of the request-response category, where a client sends one message to the Big Peer and receive one response in return.
The HTTP API is structured around various resources, which are endpoints you call in your code to perform specific actions, such as upsert, and receive corresponding responses from the Big Peer.
These resources correspond to the key elements of the Ditto document model. For more information, see Document Model.
Ditto uses UTF-8 to encode data. For more information, see Encoding Standard: UTF-8.
Unless otherwise specified, the default representation format for individual resources is JSON, as indicated by the Content‑Type HTTP header included in your response:
Unless you have a specific requirement for a different encoding, encode your input data in UTF-8. UTF-8 is a variable-length schema for universal character encoding.
Make sure to encode your JSON text-based data, such as JSON, using UTF-8.
If encoding using another schema, such as UTF-16, decoding errors and invalid results are likely to occur.
For resources that follow a chronological or sequential pattern, such as time-series data, event logs, and so on, use JSON Lines.
JSON Lines is a text file format for storing structured data that follows a chronological or sequential pattern, such as time-series data, event logs, and so on.
For more information, see the official JSON Lines documentation.
To specify alternative data representations, indicate which representation you want in the Accept header in your request.
For instance, to set representation to JSON Lines:
When sending binary data, such as a media file, to the Big Peer, you must first convert the binary data into a Base64-encoded string.
Once converted, include your Base64-encoded string in your request.
Failing to send binary data encoded with Base64 may result in compatibility issues leading to data corruption or loss.