Store and Retrieve Data with the SDKs

In this guide, you use antd, the local daemon used by the SDKs, to store public data, private data, files, and directories through language SDKs.

If you want direct shell access instead, see Use the CLI. If you want direct programmatic Rust access without the daemon, see Build Directly in Rust.

Featured examples on this page use cURL, Python, Node.js / TypeScript, and Rust. Other SDK languages are available in the Language Bindings section.

Prerequisites

  • antd running on http://localhost:8082 (see Start the Local Daemon)

  • For the write examples on this page, a write-enabled daemon. On the default network, restart antd with wallet configuration first. On a local devnet, ant dev start provisions that for you. See Prepare a Wallet for Uploads for the default-network setup.

  • Optional: the runtime or toolchain for the SDK examples you want to run, such as Python, Node.js, or Rust

The read examples work with any running daemon if you already have an address or DataMap. The write examples on this page require the write-enabled setup above.

Steps

1. Store public data

DATA_B64=$(printf 'Hello, Autonomi!' | base64)

curl -X POST http://localhost:8082/v1/data/public \
  -H "Content-Type: application/json" \
  -d "{\"data\":\"$DATA_B64\"}"

2. Retrieve public data

The REST response uses base64 in the data field. The Python, Node.js / TypeScript, and Rust SDKs decode it back into bytes.

3. Store private data

Private uploads return a serialized DataMap instead of a public address.

Expected response shape:

In the Python, Node.js / TypeScript, and Rust SDKs, the returned private data_map is surfaced through PutResult.address.

4. Retrieve private data

5. Upload and download a file

These endpoints work on paths visible to the machine running antd.

6. Upload and download a directory

Verify it worked

For raw data, compare the retrieved bytes to the original payload. For files and directories, compare the downloaded output on disk with the original local source before you uploaded it.

Common errors

400 Bad Request: Check base64 encoding, address length, and local path values.

402 Payment Required: Fund the configured wallet or switch to a local devnet with test funds.

503 Service Unavailable: The daemon does not have wallet configuration. Restart it with AUTONOMI_WALLET_KEY or let ant dev start provision a local environment.

Next steps

Last updated