Package Exports
- @gopu.inc/chariow-sdk
- @gopu.inc/chariow-sdk/cli
- @gopu.inc/chariow-sdk/dns
- @gopu.inc/chariow-sdk/hooks
- @gopu.inc/chariow-sdk/marketplace
- @gopu.inc/chariow-sdk/pay
- @gopu.inc/chariow-sdk/products
- @gopu.inc/chariow-sdk/sales
- @gopu.inc/chariow-sdk/store
Readme
๐ Chariow SDK
โจ Features
- ๐ Products API โ Create, update, publish products
- ๐ณ Chariow Pay โ Payments & checkout (Stripe-compatible)
- ๐ Webhooks โ Manage webhooks with events
- ๐ DNS โ Custom domains & SSL management
- ๐ช Marketplace โ Browse stores and products
- ๐ Sales โ Orders and revenue tracking
- ๐ WebSocket โ Real-time events & notifications
- ๐ฅ๏ธ CLI โ Interactive terminal dashboard
- โก Func Gateway โ Stripe-compatible payment gateway
- ๐ฆ TypeScript โ Full type definitions included
๐ฆ Installation
NPM
npm install chariow-sdkYarn
yarn add chariow-sdkGlobal CLI
npm install -g chariow-sdk๐ Quick Start
Node.js / TypeScript
import { Chariow } from 'chariow-sdk';
// Initialize the SDK
const client = new Chariow('your-api-key');
// List products
const products = await client.products.list({ per_page: 10 });
// Create a product
const product = await client.products.create({
name: 'Awesome Product',
description: 'The best product ever',
pricing: {
type: 'one_time',
current_price: {
value: 29.99,
currency: 'USD'
}
},
status: 'published'
});
// Process a payment
const payment = await client.pay.checkout({
items: [{ product_id: product.id, quantity: 1 }],
customer_email: 'customer@example.com',
currency: 'USD'
});
console.log(payment.checkout_url);CLI
# Configure API key
chariow config --set your-api-key
# Interactive dashboard
chariow dashboard
# Manage products
chariow products --list
chariow products --create
chariow products --publish <id>
# Process payments
chariow pay --checkout
chariow pay --buy https://chariow.com/store/myshop/products/my-product
# Start payment gateway
chariow serve --port 4242
# Real-time WebSocket monitoring
chariow ws๐ง CLI Commands
Command Description
chariow dashboard Interactive TUI dashboard
chariow config --set
๐ Modules
Products API
import { ProductsAPI } from 'chariow-sdk/products';
const products = new ProductsAPI(client);
// List with pagination
await products.list({ per_page: 20, status: 'published' });
// Search
await products.search('awesome');
// Get by ID
await products.get('prod_abc123');
// Update
await products.update('prod_abc123', { name: 'New Name' });
// Delete
await products.delete('prod_abc123');Payment API (Chariow Pay)
import { PayAPI } from 'chariow-sdk/pay';
const pay = new PayAPI(client);
// Create checkout
const payment = await pay.checkout({
items: [{ product_id: 'prod_abc123', quantity: 2 }],
customer_email: 'buyer@example.com',
customer_name: 'John Doe',
currency: 'USD',
payment_method: { type: 'card' },
success_url: 'https://myshop.com/success',
cancel_url: 'https://myshop.com/cancel'
});
// Get payment
await pay.get('pay_xyz789');
// List payments
await pay.list({ status: 'succeeded', per_page: 20 });
// Refund
await pay.refund('pay_xyz789', { reason: 'Customer request' });Marketplace
import { MarketplaceAPI } from 'chariow-sdk/marketplace';
const marketplace = new MarketplaceAPI(client);
// List stores
const stores = await marketplace.listStores({ search: 'tech' });
// Get store
const store = await marketplace.getStore('my-store');
// Get store products
const products = await marketplace.getStoreProducts('my-store');Webhooks
import { HooksAPI } from 'chariow-sdk/hooks';
const hooks = new HooksAPI(client);
// Create webhook
await hooks.create({
url: 'https://myserver.com/webhook',
events: ['sale.created', 'payment.succeeded'],
secret: 'your-webhook-secret'
});
// List webhooks
await hooks.list();
// Test webhook
await hooks.test('wh_abc123', 'sale.created');
// Get deliveries
await hooks.deliveries('wh_abc123');DNS / Domains
import { DnsAPI } from 'chariow-sdk/dns';
const dns = new DnsAPI(client);
// Add domain
await dns.add({ domain: 'myshop.com' });
// List domains
await dns.list();
// Verify domain
await dns.verify('dom_abc123');
// Set default domain
await dns.setDefault('dom_abc123');WebSocket
import { ChariowWebSocket } from 'chariow-sdk/websocket';
const ws = new ChariowWebSocket('your-api-key');
// Connect
await ws.connect();
// Subscribe to events
await ws.subscribeToStore();
await ws.subscribeToProduct('prod_abc123');
// Listen for events
ws.on('new_sale', (sale) => {
console.log(`New sale: ${sale.amount} ${sale.currency}`);
});
ws.on('product_updated', (product) => {
console.log(`Product updated: ${product.name}`);
});
ws.on('notification', (notification) => {
console.log(`Notification: ${notification.message}`);
});
// Search products in real-time
const results = await ws.searchProducts({
term: 'awesome',
minPrice: 10,
maxPrice: 50,
sortBy: 'rating'
});๐ Payment Gateway (Stripe-compatible)
# Start the gateway
chariow serve --port 4242
# Generate nginx config with SSL
chariow serve --ssl --domain pay.myshop.comEndpoints
Method Endpoint Description POST /v1/payment_intents Create payment intent GET /v1/payment_intents/:id Get payment intent POST /v1/payment_intents/:id/confirm Confirm payment POST /v1/payment_intents/:id/cancel Cancel payment POST /v1/charges Create charge GET /v1/charges List charges POST /v1/refunds Create refund POST /v1/customers Create customer GET /v1/balance Get balance GET /v1/products List products
Example with curl
# Create payment intent
curl -X POST http://localhost:4242/v1/payment_intents \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"amount": 5000,
"currency": "usd",
"customer_email": "user@example.com",
"items": [{"product_id": "prod_abc123", "quantity": 1}]
}'
# Process charge
curl -X POST http://localhost:4242/v1/charges \
-H "Authorization: Bearer your-api-key" \
-H "Content-Type: application/json" \
-d '{
"amount": 2999,
"currency": "usd",
"product_id": "prod_abc123",
"customer_email": "buyer@example.com"
}'๐งช Testing
# Run all tests
npm test
# Run unit tests
npm run test:unit
# Run integration tests
npm run test:integration
# Run tests with coverage
npm run test:coverage
# Run tests in watch mode
npm run test:watch๐ Test Results
โ
141 tests passed
โ
31 test suites
โฑ๏ธ 3.63 seconds๐ ๏ธ Development
# Clone repository
git clone git@github.com:gopu-inc/chariow-sdk.git
cd chariow-sdk
# Install dependencies
npm install
# Build
npm run build
# Development mode
npm run dev
# Type check
npm run type-check
# Link locally
npm run link:local๐ Examples
Check out the examples directory for complete usage examples:
ยท Basic Product Management ยท Payment Processing ยท Webhook Setup ยท Marketplace Integration ยท WebSocket Monitoring ยท Full E-commerce Flow
๐ค Contributing
We welcome contributions! Please see our Contributing Guide.
- Fork the repository
- Create your feature branch (git checkout -b feature/amazing-feature)
- Commit your changes (git commit -m 'Add amazing feature')
- Push to the branch (git push origin feature/amazing-feature)
- Open a Pull Request
๐ License
This project is licensed under the MIT License โ see the LICENSE file for details.
๐ Acknowledgments
ยท Built with TypeScript ยท Powered by Chariow Platform ยท CLI with Commander.js ยท TUI with Chalk + Inquirer
๐ซ Contact & Support
ยท Documentation: docs.chariow.com ยท API Reference: docs.chariow.com/api ยท Issues: GitHub Issues ยท Discord: Chariow Community ยท Twitter: @Chariow
Built with โค๏ธ by the Chariow Team
โญ Star us on GitHub โ it helps!