This page serves as a complete reference to all publicly available classes, methods, types, and utilities provided by the bee-js SDK. After getting started, this is the place to explore everything you can do with bee-js and revisit whenever you need a reminder of how a function works or what a type represents.
Install core-sdk directly when you want the primitives without the HTTP client, for example when hashing or signing chunks in a worker or on a server that never contacts a Bee node:
Operations on the Bee class are grouped into namespaces by subject. Instead of one flat list of methods, you reach bee.data.upload(...), bee.stamp.getAll(...), bee.feed.makeWriter(...) and so on.
A handful of methods stay directly on bee because they do not belong to any one subject: makeContentAddressedChunk, unmarshalContentAddressedChunk, makeSingleOwnerChunk, unmarshalSingleOwnerChunk, calculateSingleOwnerChunkAddress, createEnvelope and rchash.
Migrating from v12 or earlier
Earlier versions exposed every method directly on bee, for example bee.uploadData and bee.getAllPostageBatch. Those are now bee.data.upload and bee.stamp.getAll. A codemod ships with the library and rewrites the call sites for you. See Migrating from v12 to v13 for the full mapping and the other breaking changes.
NumberString is a branded type for marking strings that represent numbers. It interops with string and bigint
types. Where NumberString is present, number is disallowed in order to avoid pitfalls with unsafe large values.
All the classes below extend Bytes, therefore the following methods are available on all of them: toUint8Array,
toHex, toBase64, toBase32, toUtf8, parsePayloadAsJson, static keccak256, static fromUtf8.
The toString method uses toHex.
Bytes and its subclasses may be constructed with new from Uint8Array or hex string.
Both are created through static factories, so they are called without new: BZZ.fromDecimalString('1'). Instances are immutable, and the arithmetic methods return a new instance rather than mutating the receiver.
Every bee-js method that talks to a node is listed below with the endpoint it calls and the least capable node type that can serve it. The tables are grouped by namespace. Most methods call a single endpoint; the few that compose several list each one. Methods that run entirely locally are listed at the end. Refer to the Bee API specifications for the details of each endpoint.
The node mode column reads as a minimum, so a more capable node also serves the endpoint:
Ultra-light — any node, whether ultra-light, light or full.
stamp.create also reads GET /chainstate to check the amount against the current price, and then polls GET /stamps/:batchId until the batch is usable, unless you pass waitForUsable: false.
bee.storage is the size and duration view of bee.stamp, so every method here also reads GET /chainstate to convert a Size and Duration into the depth and amount the endpoints below take. storage.extend and storage.extendSize call the top-up endpoint, the dilute endpoint, or both, depending on whether the duration, the size, or both have to grow.