0.1.0 • Published 5 months ago
@devdraft/sdk-node v0.1.0
Devdraft SDK
Official Node.js SDK for the Devdraft API. This SDK provides a developer-friendly interface to interact with Devdraft's services, including payment links, invoices, customer management, and more.
Installation
npm install @devdraft/sdk-node
# or
yarn add @devdraft/sdk-nodeQuick Start
import { DevdraftSDK } from '@devdraft/sdk-node';
const sdk = new DevdraftSDK({
clientKey: 'your_client_key',
clientSecret: 'your_client_secret',
// Optional configurations
baseUrl: 'https://api.devdraft.ai', // Default
version: 'v0', // Default
timeout: 30000, // Default: 30 seconds
});
// Create a payment link
const paymentLink = await sdk.paymentLinks.create({
amount: 100,
currency: 'usdc',
customerId: 'cus_abc123',
});
// List invoices
const invoices = await sdk.invoices.list({
skip: 0,
take: 10,
});
// Create a webhook
const webhook = await sdk.webhooks.create({
name: 'Payment Notifications',
url: 'https://api.example.com/webhooks/payments',
isActive: true,
signing_secret: 'whsec_123456789',
encrypted: false,
});Features
- 🔄 Auto-generated from OpenAPI spec
- 📦 TypeScript support with full type definitions
- 🔒 Automatic authentication handling
- 🚀 Axios-based HTTP client
- ⚡️ Promise-based API
- 🛡️ Error handling with consistent error format
- 📝 Comprehensive API documentation
Error Handling
The SDK provides consistent error handling across all API calls:
try {
const paymentLink = await sdk.paymentLinks.create({
amount: 100,
currency: 'usdc',
});
} catch (error) {
console.error({
statusCode: error.statusCode,
message: error.message,
error: error.error,
details: error.details,
});
}Available Resources
sdk.paymentLinks- Payment link managementsdk.invoices- Invoice operationssdk.customers- Customer managementsdk.webhooks- Webhook configuration
Configuration
The SDK accepts the following configuration options:
interface DevdraftSDKConfig {
clientKey: string; // Required: Your API client key
clientSecret: string; // Required: Your API client secret
baseUrl?: string; // Optional: API base URL
version?: string; // Optional: API version
timeout?: number; // Optional: Request timeout in milliseconds
}Publishing
To publish a new version of the SDK:
Update the version in
package.json:npm version patch # for bug fixes npm version minor # for new features npm version major # for breaking changesBuild the package:
npm run buildPublish to npm:
npm publishCreate a git tag and push:
git tag v<version> git push origin v<version>
License
MIT