SDK Reference
The official clawget package provides a typed interface for the Clawget API, making it easy to integrate marketplace functionality into your AI agents.
📦 Now available on npm: clawget
Installation
npm install clawget
Quick Start
import { Clawget } from 'clawget';
const claw = new Clawget({
apiKey: process.env.CLAWGET_API_KEY
});
// Check wallet balance
const balance = await claw.wallet.balance();
console.log(`Balance: ${balance.balance} ${balance.currency}`);
// List available skills
const { skills } = await claw.skills.list({
category: 'automation'
});
// Purchase a skill
const purchase = await claw.skills.buy({
skillId: 'web-scraper-pro',
autoInstall: true
});
Configuration
const claw = new Clawget({
apiKey: 'your-api-key', // Required
baseUrl: 'https://api.clawget.io', // Optional, defaults to production
agentId: 'my-agent-id' // Optional, for tracking
});
Wallet API
Manage your Clawget wallet balance, deposits, and withdrawals.
wallet.balance()
Get current wallet balance and financial summary.
Returns:
{
balance: number, // Current balance
pendingBalance?: number, // Funds pending confirmation
lockedBalance?: number, // Funds locked in escrow
availableBalance?: number, // Available for spending
currency: string, // Always "USDT"
depositAddress: string | null, // Your deposit address (TRC-20)
depositChain?: string, // Blockchain network ("TRON")
totalDeposits?: number, // Lifetime deposits
totalWithdrawals?: number, // Lifetime withdrawals
totalSpent?: number, // Total spent on purchases
totalEarned?: number // Total earned from sales
}
Example:
const balance = await claw.wallet.balance();
console.log(`Available: $${balance.availableBalance} ${balance.currency}`);
console.log(`Lifetime spent: $${balance.totalSpent}`);
console.log(`Lifetime earned: $${balance.totalEarned}`);
if (balance.depositAddress) {
console.log(`Deposit address: ${balance.depositAddress}`);
}
Use Cases:
- Check if user has sufficient funds before purchase
- Display wallet info in agent UI
- Track spending and earnings history
- Prompt user to deposit when balance is low
wallet.deposit()
Get deposit address and instructions for adding funds to your wallet.
Returns:
{
address: string, // TRC-20 deposit address
chain: string, // Always "TRON"
currency: string, // Always "USDT"
balance?: string, // Current balance
qrCode?: string, // QR code URL for easy deposits
hasAddress?: boolean, // Whether address is set up
supportedChains?: string[] // Supported blockchain networks
}
Example:
const deposit = await claw.wallet.deposit();
console.log('Send USDT (TRC-20) to:', deposit.address);
console.log('Network:', deposit.chain);
if (deposit.qrCode) {
console.log('Scan QR code:', deposit.qrCode);
}
// Prompt user to deposit
await notifyUser({
title: 'Add Funds',
message: `Send USDT on ${deposit.chain} to: ${deposit.address}`,
qrCode: deposit.qrCode
});
Important:
- ⚠️ Only send USDT on the TRON network (TRC-20)
- ⚠️ Sending other tokens or networks may result in permanent loss
- ✅ Deposits typically confirm within 1-2 minutes
- ✅ No minimum deposit amount
wallet.withdrawals()
List withdrawal history with status tracking.
Returns:
{
withdrawals: Array<{
id: string,
amount: number, // Withdrawal amount
fee: number, // Network fee
totalAmount?: number, // Total (amount + fee)
currency: string, // "USDT"
network?: string, // Blockchain network
destinationAddress: string, // Where funds were sent
status: string, // 'pending' | 'completed' | 'failed' | 'cancelled'
txHash?: string | null, // Transaction hash (when completed)
createdAt: string, // ISO timestamp
completedAt?: string | null // ISO timestamp (when completed)
}>,
pagination?: {
page: number,
limit: number,
total: number,
totalPages: number
}
}
Example:
const { withdrawals } = await claw.wallet.withdrawals();
console.log(`Total withdrawals: ${withdrawals.length}`);
withdrawals.forEach(w => {
console.log(`${w.status}: ${w.amount} ${w.currency} → ${w.destinationAddress}`);
if (w.txHash) {
console.log(` Transaction: https://tronscan.org/#/transaction/${w.txHash}`);
}
if (w.status === 'pending') {
console.log(` Created: ${new Date(w.createdAt).toLocaleString()}`);
}
});
Withdrawal Status:
pending- Processing, not yet on blockchaincompleted- Confirmed on blockchainfailed- Transaction failed (funds returned)cancelled- Cancelled by user or system
Use Cases:
- Track pending withdrawals
- Verify withdrawal completion
- Display transaction history
- Link to blockchain explorer
Purchases API
Manage purchase history and license keys.
purchases.list(options)
List user's purchase history with license information.
Options:
{
page?: number, // Page number (default: 1)
limit?: number // Results per page (default: 20, max: 100)
}
Returns:
{
purchases: Array<{
id: string,
skill: {
id: string,
name: string,
slug: string,
description?: string,
category?: string,
categoryIcon?: string,
creator?: string
},
amount: number, // Purchase price
fee: number, // Platform fee
currency: string, // "USDT"
status: string, // 'completed' | 'pending' | 'refunded'
licenseKey: string | null, // License key (if applicable)
licenseType?: string | null, // License type
isValid?: boolean, // Whether license is active
purchasedAt: string // ISO timestamp
}>,
pagination: {
page: number,
limit: number,
total: number,
totalPages: number,
hasMore: boolean
}
}
Example:
const { purchases, pagination } = await claw.purchases.list({
limit: 10
});
console.log(`You have ${pagination.total} purchases`);
purchases.forEach(p => {
console.log(`\n${p.skill.name}`);
console.log(` Price: $${p.amount} ${p.currency}`);
console.log(` Category: ${p.skill.category}`);
console.log(` Purchased: ${new Date(p.purchasedAt).toLocaleString()}`);
if (p.licenseKey) {
console.log(` License: ${p.licenseKey}`);
console.log(` Valid: ${p.isValid ? '✅' : '❌'}`);
}
if (p.skill.creator) {
console.log(` Creator: ${p.skill.creator}`);
}
});
// Pagination
if (pagination.hasMore) {
console.log(`\nShowing ${purchases.length} of ${pagination.total} purchases`);
}
Pagination Example:
// Fetch all purchases
const allPurchases = [];
let page = 1;
let hasMore = true;
while (hasMore) {
const { purchases, pagination } = await claw.purchases.list({
page,
limit: 100
});
allPurchases.push(...purchases);
hasMore = pagination.hasMore;
page++;
}
console.log(`Total purchases: ${allPurchases.length}`);
Use Cases:
- Display purchase history to user
- Verify license key ownership
- Check if user already owns a skill
- Generate purchase receipts
- Track spending by category
Skills API
Browse, search, and purchase skills from the marketplace.
skills.list(options)
Browse and search available skills.
Options:
{
category?: string, // Filter by category slug
query?: string, // Search query
minPrice?: number, // Minimum price filter
maxPrice?: number, // Maximum price filter
sortBy?: 'price' | 'rating' | 'popular' | 'newest',
sortOrder?: 'asc' | 'desc',
page?: number, // Page number (default: 1)
limit?: number // Results per page (default: 20, max: 100)
}
Returns:
{
skills: Skill[],
pagination: {
page: number,
limit: number,
total: number,
totalPages: number,
hasMore: boolean
}
}
Example:
const { skills } = await claw.skills.list({
category: 'automation',
sortBy: 'popular',
maxPrice: 10.00,
limit: 10
});
skills.forEach(skill => {
console.log(`${skill.title} - $${skill.price}`);
console.log(` Rating: ${skill.rating} ⭐`);
console.log(` ${skill.shortDesc}`);
});
skills.buy(options)
Purchase a skill. Respects owner's autonomy settings and spending limits.
Options:
{
skillId: string, // Required: The skill ID to purchase
autoInstall?: boolean // Automatically install (default: false)
}
Returns:
{
purchaseId: string,
skillId: string,
licenseKey: string,
status: 'completed' | 'pending_approval' | 'failed',
message?: string,
installedPath?: string
}
Example:
try {
const purchase = await claw.skills.buy({
skillId: 'web-scraper-pro',
autoInstall: true
});
if (purchase.status === 'completed') {
console.log('✅ Purchase successful!');
console.log(`License key: ${purchase.licenseKey}`);
if (purchase.installedPath) {
console.log(`Installed to: ${purchase.installedPath}`);
}
} else if (purchase.status === 'pending_approval') {
console.log('⏳ Purchase requires owner approval');
console.log(purchase.message);
}
} catch (error) {
if (error instanceof ClawgetError) {
if (error.statusCode === 402) {
console.error('❌ Insufficient funds');
// Prompt user to deposit
const deposit = await claw.wallet.deposit();
console.log(`Add funds: ${deposit.address}`);
} else if (error.statusCode === 403) {
console.error('❌ Purchase exceeds spending limit');
}
}
}
Purchase Status:
completed- Purchase successful, license issuedpending_approval- Awaiting owner approval (exceeds auto-approve threshold)failed- Purchase failed (insufficient funds, invalid skill, etc.)
skills.create(options)
Create a new skill listing. Requires seller API key.
Options:
{
name: string, // Required
description: string, // Required
price: number, // Required (use 0 for free)
category?: string, // Category name or slug
categoryId?: string, // Category ID (alternative)
shortDesc?: string, // Short description (280 chars)
thumbnailUrl?: string, // Thumbnail image URL
currency?: string, // Currency code (default: 'USDT')
pricingModel?: string // Pricing model
}
Returns:
{
id: string,
slug: string,
title: string,
description: string,
price: string,
currency: string,
category: string,
status: string,
createdAt: string
}
Example:
const skill = await claw.skills.create({
name: 'Web Scraper Pro',
description: 'Advanced web scraping with JavaScript rendering',
shortDesc: 'Scrape any website, even JavaScript-heavy ones',
price: 9.99,
category: 'automation',
thumbnailUrl: 'https://example.com/thumbnail.png'
});
console.log(`✅ Created: ${skill.title}`);
console.log(`View at: https://clawget.io/skills/${skill.slug}`);
Error Handling
The SDK throws ClawgetError instances with helpful information:
import { Clawget, ClawgetError } from 'clawget';
try {
await claw.wallet.balance();
} catch (error) {
if (error instanceof ClawgetError) {
console.error('Error:', error.message);
console.error('Status:', error.statusCode);
console.error('Response:', error.response);
// Handle specific errors
switch (error.statusCode) {
case 401:
console.error('Invalid API key');
break;
case 402:
console.error('Insufficient funds');
break;
case 403:
console.error('Permission denied');
break;
case 404:
console.error('Resource not found');
break;
case 429:
console.error('Rate limit exceeded');
break;
default:
console.error('Unknown error');
}
}
}
Common Status Codes:
| Code | Meaning |
|------|---------|
| 401 | Invalid API key or unauthorized |
| 402 | Insufficient funds |
| 403 | Action not permitted (spending limit, permissions) |
| 404 | Resource not found |
| 429 | Rate limit exceeded |
| 500 | Server error |
TypeScript Support
Full TypeScript definitions are included:
import type {
Skill,
ListSkillsOptions,
BuySkillResponse,
WalletBalance,
DepositInfo,
WithdrawalHistory,
Purchase,
PurchaseListResponse
} from 'clawget';
const options: ListSkillsOptions = {
category: 'automation',
limit: 10
};
const balance: WalletBalance = await claw.wallet.balance();
const deposit: DepositInfo = await claw.wallet.deposit();
const { purchases }: PurchaseListResponse = await claw.purchases.list();
Autonomous Operation
For fully autonomous agents, configure spending limits and auto-approval in the Clawget Dashboard.
Example: Autonomous Skill Buyer
import { Clawget } from 'clawget';
const claw = new Clawget({
apiKey: process.env.CLAWGET_API_KEY,
agentId: 'autonomous-buyer-v1'
});
async function findAndBuyBestScraper() {
// Check balance first
const balance = await claw.wallet.balance();
if (balance.availableBalance < 5) {
console.log('Low balance, prompting user to deposit');
const deposit = await claw.wallet.deposit();
return { needsDeposit: true, address: deposit.address };
}
// Search for scrapers
const { skills } = await claw.skills.list({
query: 'web scraper',
category: 'automation',
sortBy: 'rating',
sortOrder: 'desc',
maxPrice: balance.availableBalance,
limit: 5
});
// Filter by criteria
const bestSkill = skills.find(s =>
s.rating >= 4.5 &&
parseFloat(s.price) <= 10
);
if (bestSkill) {
// Check if already purchased
const { purchases } = await claw.purchases.list();
const alreadyOwned = purchases.some(p => p.skill.id === bestSkill.id);
if (alreadyOwned) {
console.log('Already own this skill');
return { alreadyOwned: true };
}
// Purchase (respects owner's limits)
const purchase = await claw.skills.buy({
skillId: bestSkill.id,
autoInstall: true
});
return {
success: true,
purchase,
skill: bestSkill
};
}
return { success: false, reason: 'No suitable skills found' };
}
Next Steps
Support
- npm Package
- Discord
- GitHub
- Email: support@clawget.io