lunartools-sdk
v1.0.4
Published
Official SDK for Lunar Tools API
Maintainers
Readme
Lunar Tools SDK
Official TypeScript/JavaScript SDK for the Lunar Tools API.
Installation
npm install lunartools-sdkGetting Started
1. Obtain Your API Key
Visit the Lunar Tools Developer Portal to generate your API key.
2. Get User Access Tokens
Each API call requires a user's access token. Users can find their access token in the Lunar Tools application under Settings > Developer.
Usage
Initialize the Client
import { Client } from 'lunartools-sdk';
const client = new Client({
apiKey: 'your-api-key-here'
});Add Product to Inventory
await client.addProduct({
token: 'user-access-token',
name: 'Charizard VMAX',
sku: 'SWSH-074',
qty: 5,
value: 150.00,
spent: 120.00,
size: 'Standard',
store: 'TCGPlayer'
});Add Order
await client.addOrder({
token: 'user-access-token',
name: 'Pokemon Booster Box',
status: 'shipped',
orderNumber: 'ORD-12345',
price: '120.00',
orderTotal: '132.00',
retailer: 'Amazon',
tracking: '1Z999AA10123456784',
qty: '1'
});Add Profile Analytics
await client.addProfile({
token: 'user-access-token',
success: true,
billing: {
name: 'John Doe',
phone: '5551234567',
line1: '123 Main St',
line2: 'Apt 4B',
postCode: '10001',
city: 'New York',
state: 'NY',
country: 'United States'
},
shipping: {
name: 'John Doe',
phone: '5551234567',
line1: '123 Main St',
line2: 'Apt 4B',
postCode: '10001',
city: 'New York',
state: 'NY',
country: 'United States'
},
payment: {
name: 'John Doe',
type: 'Visa',
lastFour: '4242',
expMonth: '12',
expYear: '2025',
cvv: '123'
}
});Add Task Analytics
await client.addTask({
token: 'user-access-token',
bot: 'LunarAIO',
site: 'Nike',
mode: 'Fast',
input: 'DM0121-001',
profile: {
billing: {
name: 'John Doe',
phone: '5551234567',
line1: '123 Main St',
line2: 'Apt 4B',
postCode: '10001',
city: 'New York',
state: 'NY',
country: 'United States'
},
shipping: {
name: 'John Doe',
phone: '5551234567',
line1: '123 Main St',
line2: 'Apt 4B',
postCode: '10001',
city: 'New York',
state: 'NY',
country: 'United States'
},
payment: {
name: 'John Doe',
type: 'Visa',
lastFour: '4242',
expMonth: '12',
expYear: '2025'
}
},
proxy: 'http://username:[email protected]:8080',
account: '[email protected]',
success: true
});Forward Webhook to Discord
const response = await client.webhook(
'https://www.lunartools.co/api/webhooks/YOUR_TOKEN_HERE',
{
content: 'New product in stock!',
embeds: [{
title: 'Product Alert',
description: 'Charizard VMAX is now available',
color: 0x5865F2,
fields: [
{ name: 'Price', value: '$150.00', inline: true },
{ name: 'Quantity', value: '5', inline: true }
],
timestamp: new Date().toISOString()
}]
}
);
console.log(response); // { status: 'queued', queueLength: 1 }API Reference
Constructor
new Client(config: Config)Config:
apiKey(string, required) - Your API key from the Lunar Tools Developer PortalbaseUrl(string, optional) - Custom API base URL (defaults to https://www.lunartools.co)
Methods
addProduct(product: AddProduct): Promise
Add a new product to a user's inventory.
Required fields:
token(string) - User's access tokenname(string) - Product namesku(string) - Product SKUqty(number) - Quantity
Optional fields:
size(string) - Product sizestore(string) - Store namevalue(number) - Product valuespent(number) - Amount spent
Example:
await client.addProduct({
token: 'user-access-token',
name: 'Product Name',
sku: 'SKU-123',
qty: 10,
value: 50.00
});addOrder(order: AddOrder): Promise
Add a new order to a user's orders.
Required fields:
token(string) - User's access tokenname(string) - Order namestatus(string) - Order statusorderNumber(string) - Order number
Optional fields:
image(string) - Product image URLtracking(string) - Tracking numberdate(string) - Order date (format: MM/DD/YYYY, HH:MM:SS AM/PM)qty(string) - Quantityprice(string) - Item priceorderTotal(string) - Total order amountaccount(string) - Account nameretailer(string) - Retailer nametags(string) - Order tags
Example:
await client.addOrder({
token: 'user-access-token',
name: 'Pokemon Cards',
status: 'delivered',
orderNumber: 'ORD-456',
price: '99.99',
retailer: 'eBay'
});addProfile(profile: AddProfile): Promise
Add profile analytics data for tracking successful/declined checkouts.
Required fields:
token(string) - User's access tokensuccess(boolean) - Whether the checkout was successfulbilling(Address) - Billing address informationshipping(Address) - Shipping address informationpayment(Payment) - Payment information
Address fields (all required):
name(string) - Full namephone(string) - Phone numberline1(string) - Address line 1line2(string, optional) - Address line 2postCode(string) - Postal/ZIP codecity(string) - Citystate(string) - State/provincecountry(string) - Country
Payment fields (all required):
name(string) - Name on cardtype(string) - Card type (e.g., Visa, Mastercard)lastFour(string) - Last 4 digits of cardexpMonth(string) - Expiration month (MM)expYear(string) - Expiration year (YYYY)cvv(string, optional) - CVV code
Example:
await client.addProfile({
token: 'user-access-token',
success: true,
billing: {
name: 'John Doe',
phone: '5551234567',
line1: '123 Main St',
postCode: '10001',
city: 'New York',
state: 'NY',
country: 'United States'
},
shipping: {
name: 'John Doe',
phone: '5551234567',
line1: '456 Oak Ave',
postCode: '10002',
city: 'Brooklyn',
state: 'NY',
country: 'United States'
},
payment: {
name: 'John Doe',
type: 'Visa',
lastFour: '4242',
expMonth: '12',
expYear: '2025'
}
});addTask(task: AddTask): Promise
Add task analytics data for tracking checkout attempts and generating AI-powered setup suggestions.
Required fields:
token(string) - User's access tokenbot(string) - Bot name (e.g., "LunarAIO", "Stellar", "Valor")site(string) - Site/retailer name (e.g., "Nike", "Walmart", "Target")mode(string) - Checkout mode (e.g., "Fast", "Safe", "Guest")input(string) - Product input (SKU, URL, keywords, etc.)profile(object) - Profile information used for checkoutbilling(Address) - Billing addressshipping(Address) - Shipping addresspayment(Payment) - Payment method
proxy(string) - Proxy used for the taskaccount(string) - Account email/username (empty string if guest checkout)success(boolean) - Whether the checkout was successful
Address fields (all required):
name(string) - Full namephone(string) - Phone numberline1(string) - Address line 1line2(string, optional) - Address line 2postCode(string) - Postal/ZIP codecity(string) - Citystate(string) - State/provincecountry(string) - Country
Payment fields (all required):
name(string) - Name on cardtype(string) - Card type (e.g., Visa, Mastercard)lastFour(string) - Last 4 digits of cardexpMonth(string) - Expiration month (MM)expYear(string) - Expiration year (YYYY)cvv(string, optional) - CVV code
Example:
await client.addTask({
token: 'user-access-token',
bot: 'LunarAIO',
site: 'Nike',
mode: 'Fast',
input: 'DM0121-001',
profile: {
billing: {
name: 'John Doe',
phone: '5551234567',
line1: '123 Main St',
postCode: '10001',
city: 'New York',
state: 'NY',
country: 'United States'
},
shipping: {
name: 'John Doe',
phone: '5551234567',
line1: '456 Oak Ave',
postCode: '10002',
city: 'Brooklyn',
state: 'NY',
country: 'United States'
},
payment: {
name: 'John Doe',
type: 'Visa',
lastFour: '4242',
expMonth: '12',
expYear: '2025'
}
},
proxy: 'http://user:[email protected]:8080',
account: '[email protected]',
success: true
});Use Case:
The addTask method powers Lunar Tools' AI-driven setup suggestion system. By reporting checkout attempts, the platform:
- Analyzes success/failure patterns across addresses, payment methods, proxies, and accounts
- Identifies burned profiles with high failure rates
- Recommends optimal configurations based on historical performance
- Provides actionable insights to improve checkout success rates
Users can view personalized setup suggestions in the Lunar Tools app under Profiles > Setups.
webhook(webhookUrl: string, payload: Webhook): Promise
Forward a webhook payload to Discord via Lunar Tools.
Parameters:
webhookUrl(string) - Full Lunar Tools webhook URLpayload(Webhook) - Discord webhook payload
Payload structure:
content(string, optional) - Message contentusername(string, optional) - Override webhook usernameavatarUrl(string, optional) - Override webhook avatarembeds(Embed[], optional) - Array of embeds (max 10)
Example:
const response = await client.webhook(
'https://www.lunartools.co/api/webhooks/TOKEN',
{
content: 'Hello!',
embeds: [{
title: 'Alert',
description: 'Something happened',
color: 0xFF0000,
fields: [
{ name: 'Field 1', value: 'Value 1', inline: true }
]
}]
}
);Authentication
The SDK uses two-level authentication:
API Key: Your developer API key (passed in constructor)
- Obtain from: Developer Portal
- Used in
x-api-keyheader for all requests
User Access Token: Individual user's access token (passed per request)
- Users find this in: Lunar Tools App > Settings > Developer
- Identifies which user's data to modify
Error Handling
The SDK validates all inputs and throws descriptive errors:
try {
await client.addProduct({
token: 'user-access-token',
name: '',
sku: 'SKU-123',
qty: 5
});
} catch (error) {
console.error(error.message); // "Product name is required"
}Common Use Cases
E-commerce Bot Integration
// After checkout attempt
await client.addTask({
token: userAccessToken,
bot: 'MyBot',
site: 'Nike',
mode: 'Fast',
input: productSku,
profile: {
billing: billingInfo,
shipping: shippingInfo,
payment: paymentInfo
},
proxy: proxyUsed,
account: accountEmail,
success: checkoutSuccessful
});
// Track order (if successful)
if (checkoutSuccessful) {
await client.addOrder({
token: userAccessToken,
name: productName,
status: 'confirmed',
orderNumber: orderNumber,
price: price,
orderTotal: total,
retailer: 'Nike',
tracking: trackingNumber
});
}
// Track legacy profile analytics
await client.addProfile({
token: userAccessToken,
success: checkoutSuccessful,
billing: billingInfo,
shipping: shippingInfo,
payment: paymentInfo
});Inventory Management
// Add new inventory
await client.addProduct({
token: userAccessToken,
name: 'Limited Edition Sneakers',
sku: 'SNKR-001',
qty: 10,
value: 200.00,
spent: 150.00,
store: 'Footlocker'
});Discord Notifications
// Send success notification
await client.webhook(webhookUrl, {
embeds: [{
title: '✅ Checkout Success',
description: `Successfully checked out ${productName}`,
color: 0x00FF00,
fields: [
{ name: 'Order Number', value: orderNumber, inline: true },
{ name: 'Total', value: `$${total}`, inline: true }
],
timestamp: new Date().toISOString()
}]
});Support
For issues, questions, or feature requests:
- Discord: Join our server
- Email: [email protected]
- Documentation: docs.lunartools.co
License
MIT
