bflow-sdk
v1.0.0
Published
SDK for creating and executing bflow workflows
Readme
BFlow SDK
A lightweight SDK for creating and executing BFlow workflows.
Installation
npm install bflow-sdk
# or
yarn add bflow-sdk
# or
bun add bflow-sdkUsage
Initializing the client
import BFlow from "bflow-sdk";
// Initialize with your API key
const bflow = new BFlow("your-api-key");Creating workflows
// Create a workflow with multiple actions
const workflowInput = {
name: "My Workflow",
actions: [
{
type: ActionType.METEORA,
name: "Meteora LP Action",
node: meteoraNode // Node configuration object
},
{
type: ActionType.JUPITER,
name: "Jupiter Swap Action",
node: jupiterNode // Node configuration object
},
{
type: ActionType.TRANSFER,
name: "Transfer Action",
node: transferNode // Node configuration object
}
]
};
const createdWorkflow = await bflow.createWorkflow(workflowInput);Working with workflows
// Get all workflows
const allWorkflows = await bflow.getWorkflows();
// Get specific workflows by name
const transferWorkflow = await bflow.getWorkflows(["transfer workflow"]);
// Execute a workflow
const result = await transferWorkflow[0].execute();
// Execute a workflow directly with custom nodes
const customResult = await bflow.executeWorkflow(customNodes);
// Get workflow instructions (nodes)
const instructions = await transferWorkflow[0].instructions();API Reference
BFlow Class
constructor(apiKey: string)
Creates a new BFlow client instance with the provided API key.
async getWorkflows(workflowNames?: string[]): Promise<Workflow[]>
Fetches workflows from the API.
workflowNames: Optional array of workflow names to filter by.- Returns: Array of workflow objects with methods for execution and instruction retrieval.
async createWorkflow(input: CreateWorkflowInput): Promise<any>
Creates a new workflow with the specified name and actions.
input: Object containing workflow name and actions.- Returns: The created workflow data.
async executeWorkflow(nodes: WorkflowAction[]): Promise<any>
Executes a workflow with the provided nodes.
nodes: Array of workflow action nodes.- Returns: Execution result from the transaction API.
Workflow Object
Each workflow object has the following properties and methods:
id: Unique identifier (UUID)name: Workflow nameactions: Array of workflow actions
async instructions(): Promise<WorkflowAction[]>
Returns the parsed node instructions for the workflow.
async execute(customPublicKey?: string): Promise<any>
Executes the workflow by sending instructions to the transaction API.
License
MIT
