Skip to main content

rickydata SDK

The rickydata SDK is the official TypeScript SDK for interacting with KnowledgeFlowDB. It handles authentication, payment signing, and provides typed APIs for all endpoints.

Installation

npm install @nickydata/sdk

Core Modules

ModulePurpose
AuthManagerWallet authentication (challenge/verify, wallet tokens, GitHub OIDC)
SpendingWalletx402 payment signing with spending limits and circuit breakers
ToolsManagerMCP tool execution with automatic 402 payment handling

Quick Example

import { AuthManager } from '@nickydata/sdk';

// 1. Create auth manager
const auth = new AuthManager('https://api.knowledgedataflow.org');

// 2. Authenticate with wallet
await auth.authenticateAuto({
signFn: wallet.signMessage,
walletAddress: wallet.address,
});

// 3. Make authenticated requests
const response = await auth.fetchWithAuth(
'https://api.knowledgedataflow.org/api/v1/query',
{
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
query: 'MATCH (n:File) RETURN n.path, n.size LIMIT 10'
}),
}
);

const data = await response.json();
console.log(data);

Authentication Strategies

The SDK supports multiple auth strategies for different environments:

StrategyUse CaseToken Type
authenticateAuto()Production (auto-selects best method)mcpwt_ or JWT
authenticateWithWalletToken()Persistent connectionsmcpwt_ (survives restarts)
authenticateWithSignature()Standard web appsJWT (24h)
authenticateWithGitHubOIDC()CI/CD pipelinesJWT

See SDK Authentication for detailed usage of each strategy.

Payment Integration

For MCP tool calls that require x402 payment:

import { SpendingWallet } from '@nickydata/sdk';

const spendingWallet = await SpendingWallet.fromSeedPhrase(
process.env.SEED_PHRASE,
0,
{ maxPerDay: 5.0 } // Spending limits
);

// SpendingWallet handles payment signing automatically
// when integrated with ToolsManager

See x402 Payments for the full payment guide.

Next Steps