Docs / 0G Storage API

0G Storage API

Fast append-only interaction with the 0G decentralized data network.

1. Overview

The Storage API seamlessly blobs JSON or text off-chain onto the 0G data availability layer without requiring you to hold 0g tokens or manage wallets.

2. Use Cases

3. Pricing

4. API

POST /v1/storage/upload

Headers: Authorization: Bearer sk_...

Request Body: Form-Data or JSON.

{ "content": "{"task":"done"}", "type": "json" }

Response Schema:

{
  "ok": true,
  "cid": "baegbe...",
  "size": 1500
}

5. Examples

TypeScript SDK:

const receipt = await opacus.ogStorage.store({ data: myData });
console.log('Saved to 0G at CID:', receipt.cid);

6. Errors

413 PAYLOAD_TOO_LARGE - Max 5MB per direct request.

7. Best Practices

Compress data aggressively before upload. Retain the CID to fetch egress context.