Skip to main content

Developers

Everything the app does can be done from code. This section describes the pieces, from the one anyone can use today without installing anything to the reference tools of the project.

What is available today​

NeedUseStatus
Read a blob, or a single file of a site, from a page, a script or a serverThe aggregator: plain HTTP, no authentication, CORS enabledPublic
Serve a website stored on the networkThe portal, at https://<site>.iotastorage.com/, with the headers and routes you set in ws-resources.jsonPublic
Store blobs and manage Blob objects from JavaScript, in Node.js or in a browser with a walletThe JavaScript client, StorageClientReference tool, repository not public yet
Publish and manage sites from a script or a CI jobThe command line, site.mjs, and the sites.mjs libraryReference tool, repository not public yet
Store over HTTP without a walletThe publisherRequires a token; used by the project
Integrate with the chain: types, events, IDsThe contracts on IOTA testnetPublic
Talk to a storage node directlyThe storage nodes APIPublic, for clients that implement the protocol

Read a blob from your code​

The aggregator is a plain HTTP server, so any language works. The blob ID is the one the app shows after storing a file, or the blobId of a Blob object.

curl -o file https://aggregator.iotastorage.com/v1/blobs/<blob ID>
// In a browser or in Node.js: CORS is enabled, so a page can read blobs directly.
const response = await fetch(`https://aggregator.iotastorage.com/v1/blobs/${blobId}`);
if (!response.ok) throw new Error(`${response.status}`); // 404: expired or deleted; 503: try again
const bytes = new Uint8Array(await response.arrayBuffer());

To read a blob by the ID of its Blob object, use /v1/blobs/by-object-id/<object ID>; to read one file of a site, /v1/blobs/by-quilt-id/<quilt blob ID>/<path>. Responses carry an etag and a day of cache-control, so browsers and CDNs cache them. See the aggregator API.

Store a blob from your code​

Storing needs an IOTA account that pays, and talking to the storage nodes. Three options:

  1. The JavaScript client (StorageClient): encodes, pays, uploads and certifies, in Node.js with a key pair or in a browser with a wallet. It is what the app and the command line use. See JavaScript client.
  2. The command line, for sites: node site.mjs deploy ./folder --key …. See Sites CLI.
  3. The publisher, over HTTP: PUT /v1/blobs, paid by the publisher's account. The public one requires a token. See Publisher API.

The client and the command line live in the project repository, which is not public yet. Until it is, the app is the way to store with your own wallet.

Integrate with the chain​

  • A stored blob is a <iota_storage>::blob::Blob object; a site is a <sites>::site::Site. The package IDs, the shared objects (System, Staking, Treasury) and the main functions are in Contracts and IDs.
  • The storage nodes and any indexer can follow the events of the iota_storage package: BlobRegistered, BlobCertified (also on renewal), BlobDeleted and the rest.
  • A Blob has store, so it can be transferred, wrapped or held by a contract. A contract that needs to prove that some data is available can check its Blob and its certified epoch.
  • Upgrades keep the IDs of the shared objects; calls go to the current package, read from System.package_id. See Package upgrades.

Limits to keep in mind​

LimitValue on testnet
Largest blob149,286,452 bytes (about 142 MiB) with 100 shards
Epochs per purchase1 to 53 (an epoch is 1 day)
Files per quilt66
Aggregator10 requests per second per IP, bursts of 100 (an IPv6 /48, 4 times that among all its addresses); 2 reads at a time per IP; blobs up to 32 MiB per request
Publisher10 MiB per request, token required

Prices and gas are in Economics.