The SwarmNode TypeScript SDK provides convenient access to the SwarmNode REST API from any Node.js 20+ application. The SDK includes rich type definitions and enables receiving real-time executions via WebSockets.
You can install the SDK using npm
or bun
or pnpm
:
npm install @swarmnode-ai/sdk
or
bun add @swarmnode-ai/sdk
or
pnpm add @swarmnode-ai/sdk
import SwarmNodeAI, { type SwarmNodeConfig } from '@swarmnode-ai/sdk'
const config: SwarmNodeConfig = {
apiKey: process.env.SWARMNODE_API_KEY,
}
const swarmnode = new SwarmNodeAI(config)
const agent = await swarmnode.agents.create({
name: 'testagent5878',
script: "def main():\n print('hello world')\n",
python_version: '3.12',
store_id: store.id,
})
import SwarmNodeAI, { type SwarmNodeConfig } from '@swarmnode-ai/sdk'
const config: SwarmNodeConfig = {
apiKey: process.env.SWARMNODE_API_KEY,
}
const swarmnode = new SwarmNodeAI(config)
const agentExecutorJob = await swarmnode.agentExecutorJobs.create({
agent_id: 'abce1234',
payload: {
key: 'value',
},
})
// OR
const agent = await swarmnode.agents.retrieve('abce1234')
await agent.execute({
payload: {
key: 'value',
},
})
import SwarmNodeAI, { type SwarmNodeConfig } from '@swarmnode-ai/sdk'
const config: SwarmNodeConfig = {
apiKey: process.env.SWARMNODE_API_KEY,
}
const swarmnode = new SwarmNodeAI(config)
const agentExecutorCronJob = await swarmnode.agentExecutorCronJobs.create({
agent_id: agent.id,
name: 'cron-job',
expression: '* * * * *', // every minute
})
import SwarmNodeAI, { type SwarmNodeConfig } from '@swarmnode-ai/sdk'
const config: SwarmNodeConfig = {
apiKey: process.env.SWARMNODE_API_KEY,
}
const swarmnode = new SwarmNodeAI(config)
const stores = await swarmnode.stores.list()
for await (const store of stores) {
console.log(store)
}
const nextPage = await stores.getNextPage()
These are only a few examples of what you can do with the SDK. Check out the examples folder for more examples.
For complete API reference and more examples, please visit:
This project is licensed under the MIT License - see the LICENSE file for details.