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.
Type interfaces
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.
Byte primitives
All the classes below extend Bytes
, therefor the following methods are available on all of them: toUint8Array
,
toHex
, toBase64
, toBase32
, toUtf8
, toJSON
, static keccak256
, static fromUtf8
.
The toString
method uses toHex
.
Bytes
and its subclasses may be constructed with new
from Uint8Array
or hex string
.
Elliptic
Name | Description | Methods |
---|
PrivateKey | 32 bytes private key | publicKey , sign |
PublicKey | 64 bytes public key | address , toCompressedUint8Array , toCompressedHex |
EthAddress | 20 bytes Ethereum address | toChecksum |
Signature | 65 bytes signature | recoverPublicKey |
Swarm
Name | Description | Methods |
---|
Reference | 32/64 bytes reference (chunk, feed) | toCid |
Identifier | 32 bytes identifier (SOC, Feed) | - |
TransactionId | 32 bytes transaction ID | - |
FeedIndex | 8 bytes feed index (BE) | static fromBigInt , toBigInt |
Topic | 32 bytes topic | static fromString |
PeerAddress | 32 bytes peer address | - |
BatchId | 32 bytes batch ID | - |
Span | 8 bytes span (LE) | static fromBigInt , toBigInt |
Tokens
Name | Description | Methods |
---|
DAI | ERC20 DAI token (18 digits) | static fromDecimalString , static fromWei , toWeiString , toWeiBigInt , toDecimalString |
BZZ | ERC20 BZZ token (16 digits) | static fromDecimalString , static fromPLUR , toPLURString , toPLURBigInt , toDecimalString |
Swarm chunks
Name | Description | Creation |
---|
Chunk | Span, max. 4096 bytes payload; address dervied from content | makeContentAddressedChunk |
SingleOwnerChunk | Identifier, signature, span, max. 4096 bytes payload; address derived from identifier and owner | makeSingleOwnerChunk |
Swarm primitives
Name | Description | Methods |
---|
MantarayNode | Compact trie with reference values and JSON metadata | addFork , removeFork , calculateSelfAddress , find , findClosest , collect , marshal , unmarshal , saveRecursively , loadRecursively |
MerkleTree | Streaming BMT of chunks | append , finalize , static root |
Swarm objects
Name | Description | Creation |
---|
SOCWriter | SingleOwnerChunk writer | bee.makeSOCWriter |
SOCReader | SingleOwnerChunk reader | bee.makeSOCReader |
FeedWriter | Feed writer | bee.makeFeedWriter |
FeedReader | Feed reader | bee.makeFeedReader |
Bee API
Each bee-js
method corresponds to a particular endpoint from the API. The chart below maps each method to its corresponding API endpoint. Refer to the Bee API specifications for more details about each endpoint. It also specifies which node type is supported for each method/endpoint.
- ❌❌✅ - Full node only
- ❌✅✅ - Light node and full node
- ✅✅✅ - Ultra-light node, light node and full node
JS Call | Bee Endpoint | Bee Mode |
---|
uploadFile | POST /bzz 🔗 | ❌✅✅ |
uploadFilesFromDirectory Node.js | POST /bzz 🔗 | ❌✅✅ |
uploadFiles | POST /bzz 🔗 | ❌✅✅ |
uploadCollection | POST /bzz 🔗 | ❌✅✅ |
uploadData | POST /bytes 🔗 | ❌✅✅ |
uploadChunk | POST /chunks 🔗 | ❌✅✅ |
streamDirectory Node.js | POST /chunks 🔗 | ❌✅✅ |
streamFiles Browser | POST /chunks 🔗 | ❌✅✅ |
SOCWriter.upload | POST /soc/:owner/:identifier 🔗 | ❌✅✅ |
FeedReader.download | GET /feeds/:owner/:topic 🔗 | ✅✅✅ |
FeedWriter.updateFeed | POST /soc/:owner/:identifier 🔗 | ❌✅✅ |
downloadFile | GET /bzz/:reference 🔗 | ✅✅✅ |
downloadFile | GET /bzz/:reference/:path 🔗 | ✅✅✅ |
downloadReadableFile | GET /bzz/:reference 🔗 | ✅✅✅ |
downloadData | GET /bytes/:reference 🔗 | ✅✅✅ |
downloadReadableData | GET /bytes/:reference 🔗 | ✅✅✅ |
downloadChunk | GET /chunks/:reference 🔗 | ✅✅✅ |
createFeedManifest | POST /feeds/:owner/:topic 🔗 | ❌✅✅ |
isConnected | GET / | ✅✅✅ |
getHealth | GET /health 🔗 | ✅✅✅ |
getReadiness | GET /readiness 🔗 | ✅✅✅ |
getNodeInfo | GET /node 🔗 | ✅✅✅ |
getChainState | GET /chainstate 🔗 | ❌✅✅ |
getRedistributionState | GET /redistributionstate 🔗 | ❌❌✅ |
getReserveState | GET /reservestate 🔗 | ❌❌✅ |
getStatus | GET /status 🔗 | ✅✅✅ |
getWallet | GET /wallet 🔗 | ❌✅✅ |
getTopology | GET /topology 🔗 | ✅✅✅ |
getAddresses | GET /addresses 🔗 | ✅✅✅ |
getPeers | GET /peers 🔗 | ✅✅✅ |
getAllBalances | GET /balances 🔗 | ❌✅✅ |
getPeerBalance | GET /balances/:peer 🔗 | ❌✅✅ |
getPastDueConsumptionBalances | GET /consumed 🔗 | ❌✅✅ |
getPastDueConsumptionPeerBalance | GET /consumed/:peer 🔗 | ❌✅✅ |
getAllSettlements | GET /settlements 🔗 | ❌✅✅ |
getSettlements | GET /settlements/:peer 🔗 | ❌✅✅ |
getChequebookAddress | GET /chequebook/address 🔗 | ❌✅✅ |
getChequebookBalance | GET /chequebook/balance 🔗 | ❌✅✅ |
getLastCheques | GET /chequebook/cheque 🔗 | ❌✅✅ |
getLastChequesForPeer | GET /chequebook/cheque/:peer 🔗 | ❌✅✅ |
getLastCashoutAction | GET /chequebook/cashout/:peer 🔗 | ❌✅✅ |
cashoutLastCheque | POST /chequebook/cashout/:peer 🔗 | ❌✅✅ |
depositTokens | POST /chequebook/deposit 🔗 | ❌✅✅ |
withdrawTokens | POST /chequebook/withdraw 🔗 | ❌✅✅ |
getAllPendingTransactions | GET /transactions 🔗 | ❌✅✅ |
getPendingTransaction | GET /transactions/:id 🔗 | ❌✅✅ |
rebroadcastTransaction | POST /transactions/:id 🔗 | ❌✅✅ |
cancelTransaction | DELETE /transactions/:id 🔗 | ❌✅✅ |
createTag | POST /tags 🔗 | ❌✅✅ |
retrieveTag | GET /tags/:id 🔗 | ❌✅✅ |
getAllTags | GET /tags 🔗 | ❌✅✅ |
deleteTag | DELETE /tags/:id 🔗 | ❌✅✅ |
updateTag | PATCH /tags/:id 🔗 | ❌✅✅ |
pin | POST /pins/:reference 🔗 | ✅✅✅ |
getAllPins | GET /pins 🔗 | ✅✅✅ |
getPin | GET /pins/:reference 🔗 | ✅✅✅ |
isReferenceRetrievable | GET /stewardship/:reference 🔗 | ✅✅✅ |
reuploadPinnedData | PUT /stewardship/:reference 🔗 | ❌✅✅ |
unpin | DELETE /pins/:reference 🔗 | ✅✅✅ |
getGrantees | GET /grantee/:reference 🔗 | ❌✅✅ |
createGrantees | POST /grantee 🔗 | ❌✅✅ |
patchGrantees | PATCH /grantee/:reference 🔗 | ❌✅✅ |
pssSend | POST /pss/send/:topic/:target 🔗 | ❌✅✅ |
pssSubscribe Websocket | GET /pss/subscribe/:topic 🔗 | ❌❌✅ |
pssReceive | GET /pss/subscribe/:topic 🔗 | ❌❌✅ |
getAllPostageBatch | GET /stamps 🔗 | ❌✅✅ |
getGlobalPostageBatches | GET /batches 🔗 | ❌✅✅ |
getPostageBatch | GET /stamps/:batchId 🔗 | ❌✅✅ |
getPostageBatchBuckets | GET /stamps/:batchId/buckets 🔗 | ❌✅✅ |
createPostageBatch | POST /stamps/:amount/:depth 🔗 | ❌✅✅ |
topUpBatch | PATCH /stamps/topup/:batchId/:amount 🔗 | ❌✅✅ |
diluteBatch | PATCH /stamps/dilute/:batchId/:depth 🔗 | ❌✅✅ |
createEnvelope | POST /envelope/:reference 🔗 | ❌✅✅ |
getStake | GET /stake 🔗 | ❌❌✅ |
depositStake | POST /stake 🔗 | ❌❌✅ |
Utils
General
getCollectionSize
getFolderSize
PSS
Erasure Coding
approximateOverheadForRedundancyLevel
getRedundancyStat
getRedundancyStats
Stamps
getStampCost
getStampEffectiveBytes
getStampUsage