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
| Need | Use | Status |
|---|---|---|
| Read a blob, or a single file of a site, from a page, a script or a server | The aggregator: plain HTTP, no authentication, CORS enabled | Public |
| Serve a website stored on the network | The portal, at https://<site>.iotastorage.com/, with the headers and routes you set in ws-resources.json | Public |
Store blobs and manage Blob objects from JavaScript, in Node.js or in a browser with a wallet | The JavaScript client, StorageClient | Reference tool, repository not public yet |
| Publish and manage sites from a script or a CI job | The command line, site.mjs, and the sites.mjs library | Reference tool, repository not public yet |
| Store over HTTP without a wallet | The publisher | Requires a token; used by the project |
| Integrate with the chain: types, events, IDs | The contracts on IOTA testnet | Public |
| Talk to a storage node directly | The storage nodes API | Public, 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:
- 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. - The command line, for sites:
node site.mjs deploy ./folder --key …. See Sites CLI. - 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::Blobobject; 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_storagepackage:BlobRegistered,BlobCertified(also on renewal),BlobDeletedand the rest. - A
Blobhasstore, so it can be transferred, wrapped or held by a contract. A contract that needs to prove that some data is available can check itsBloband 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
| Limit | Value on testnet |
|---|---|
| Largest blob | 149,286,452 bytes (about 142 MiB) with 100 shards |
| Epochs per purchase | 1 to 53 (an epoch is 1 day) |
| Files per quilt | 66 |
| Aggregator | 10 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 |
| Publisher | 10 MiB per request, token required |
Prices and gas are in Economics.