AIngle SDK for JavaScript/TypeScript
Official JavaScript/TypeScript SDK for AIngle - the ultra-light distributed ledger for IoT devices.
npm install @anthropic/aingle-sdk
# or
yarn add @anthropic/aingle-sdk
# or
pnpm add @anthropic/aingle-sdk
Connect to an AIngle Node
import { AIngleClient } from '@anthropic/aingle-sdk' ;
const client = new AIngleClient ( {
nodeUrl : 'http://localhost:8080' ,
} ) ;
// Create an entry
const hash = await client . createEntry ( {
type : 'sensor_reading' ,
value : 23.5 ,
unit : 'celsius' ,
} ) ;
console . log ( `Created entry: ${ hash } ` ) ;
// Retrieve an entry
const entry = await client . getEntry ( hash ) ;
console . log ( entry ) ;
Run an Embedded Node (Browser/Node.js)
import { AIngleNode } from '@anthropic/aingle-sdk' ;
const node = new AIngleNode ( {
enableWebRtc : true ,
bootstrapPeers : [ 'wss://bootstrap.aingle.network' ] ,
} ) ;
await node . start ( ) ;
// Create entries directly on the embedded node
const hash = await node . createEntry ( {
sensor : 'temperature' ,
value : 23.5 ,
} ) ;
// Get node statistics
const stats = await node . getStats ( ) ;
console . log ( `Entries: ${ stats . entriesCount } , Peers: ${ stats . peersCount } ` ) ;
// Stop the node
await node . stop ( ) ;
Subscribe to Real-time Updates
const unsubscribe = client . subscribe ( ( entry ) => {
console . log ( 'New entry:' , entry ) ;
} ) ;
// Later, unsubscribe
unsubscribe ( ) ;
Method
Description
connect()
Connect to the AIngle node
disconnect()
Disconnect from the node
createEntry(data)
Create a new entry
getEntry(hash)
Retrieve an entry by hash
getNodeInfo()
Get node information
subscribe(callback)
Subscribe to real-time updates
Method
Description
start()
Start the embedded node
stop()
Stop the embedded node
isRunning()
Check if node is running
createEntry(data)
Create a new entry
getEntry(hash)
Get an entry by hash
getPeers()
Get connected peers
getStats()
Get node statistics
Option
Type
Default
Description
nodeUrl
string
http://localhost:8080
Node URL
wsUrl
string
ws://localhost:8081
WebSocket URL
timeout
number
30000
Request timeout (ms)
debug
boolean
false
Enable debug logging
Option
Type
Default
Description
storagePath
string
aingle-data
Storage location
enableCoap
boolean
false
Enable CoAP transport
enableWebRtc
boolean
true
Enable WebRTC transport
bootstrapPeers
string[]
[]
Bootstrap peer URLs
memoryLimit
number
524288
Memory limit (bytes)
Platform
Client
Embedded Node
Node.js 18+
✅
✅
Browser (Chrome, Firefox, Safari)
✅
✅ (WebAssembly)
React Native
✅
🚧 Coming soon
Deno
✅
✅
Bun
✅
✅
# Install dependencies
npm install
# Run tests
npm test
# Build
npm run build
# Lint
npm run lint
Apache-2.0 - see LICENSE