🏠 Home
ShopAI API
Developer Documentation
← Back to Site

🚀 ShopAI API

Access products, generate payment links, and integrate ShopAI into your applications.

API Status: Operational Checking...

Authentication

🔐 API Key Configuration

Loading configuration status...

📍 Where to Use the API Key

If an API key is configured on the server, you must include it in your requests using one of these methods:

Method 1: HTTP Header (Recommended)

// Using Fetch API fetch('/api?action=products', { headers: { 'X-API-Key': 'YOUR_API_KEY' // OR use Authorization header: // 'Authorization': 'YOUR_API_KEY' } }); // Using cURL curl "/api?action=products" \ -H "X-API-Key: YOUR_API_KEY" // Using Python requests import requests headers = {'X-API-Key': 'YOUR_API_KEY'} res = requests.get('/api?action=products', headers=headers)

Method 2: Query Parameter

// Append api_key to the URL fetch('/api?action=products&api_key=YOUR_API_KEY'); // cURL curl "/api?action=products&api_key=YOUR_API_KEY" // Python requests.get('/api?action=products&api_key=YOUR_API_KEY')
⚠️ Important:
  • Use X-API-Key header for server-side requests (more secure)
  • Use api_key query parameter only for client-side/browser requests
  • Never expose your API key in public client-side code
  • If no API key is configured on the server, all endpoints are publicly accessible

Endpoints

📦 List All Products

Get complete product catalog with all details.

GET /api?action=products
// Get all products fetch('/api?action=products') .then(res => res.json()) .then(data => { console.log(data.categories); data.categories.forEach(cat => { cat.products.forEach(p => { console.log(p.name, '$' + p.price); }); }); });

🔍 Get Single Product

Fetch detailed information for a specific product.

GET /api?action=product&productId=PRODUCT_ID
ParameterTypeRequiredDescription
productIdstringYesProduct identifier
// Get single product by ID const productId = 'startup-001'; fetch('/api?action=product&productId=' + productId) .then(res => res.json()) .then(product => { console.log(product.name); console.log('Price: $' + product.price); console.log('Pages:', product.page_count); });

📋 List Categories

Get category summary with product counts.

GET /api?action=categories
// Get categories fetch('/api?action=categories') .then(res => res.json()) .then(data => { data.categories.forEach(cat => { console.log(cat.name, '(' + cat.product_count + ' products)'); }); });

💳 Generate Payment Link

Create payment invoice for a product. Free products return success URL directly.

GET /api?action=payment&productId=PRODUCT_ID&email=USER_EMAIL
ParameterTypeRequiredDescription
productIdstringYesProduct identifier
emailstringNoCustomer email for delivery
chatIdstringNoSession/chat identifier
// Generate payment link const productId = 'startup-001'; const email = 'user@example.com'; fetch('/api?action=payment&productId=' + productId + '&email=' + encodeURIComponent(email)) .then(res => res.json()) .then(payment => { if (payment.payment_id && payment.payment_id.startsWith('FREE_')) { // Free product - direct download window.location.href = payment.invoice_url; } else { // Paid product - redirect to payment page window.location.href = payment.invoice_url; } });

Code Examples

🌐 JavaScript (Browser)

async function getProducts() { const res = await fetch('/api?action=products'); const data = await res.json(); return data; } async function getProduct(id) { const res = await fetch('/api?action=product&productId=' + id); return await res.json(); } async function buyProduct(id, email) { const res = await fetch('/api?action=payment&productId=' + id + '&email=' + encodeURIComponent(email)); const payment = await res.json(); window.location.href = payment.invoice_url; }

🐍 Python

import requests BASE_URL = 'https://your-domain.com' def get_products(): res = requests.get(f'{BASE_URL}/api?action=products') return res.json() def get_product(product_id): res = requests.get(f'{BASE_URL}/api?action=product&productId={product_id}') return res.json() def generate_payment(product_id, email=None): params = {'productId': product_id} if email: params['email'] = email res = requests.get(f'{BASE_URL}/api?action=payment', params=params) return res.json()

📡 cURL

# List all products curl "https://your-domain.com/api?action=products" # Get single product curl "https://your-domain.com/api?action=product&productId=startup-001" # Generate payment link curl "https://your-domain.com/api?action=payment&productId=startup-001&email=user@example.com" # With API key (if configured) curl "https://your-domain.com/api?action=products" \ -H "X-API-Key: YOUR_API_KEY"

Response Formats

Product Object

FieldTypeDescription
idstringUnique product identifier
namestringProduct display name
descriptionstringProduct description
pricenumberPrice in USD (0 = free)
is_premiumbooleanPremium badge flag
page_countnumberNumber of pages
mega_urlstringDownload link
tagsarrayProduct tags
currencystringCurrency code (USD)

Payment Response

FieldTypeDescription
invoice_urlstringPayment page URL
payment_idstringPayment identifier
price_amountnumberAmount to pay
price_currencystringCurrency code
productobjectProduct info (id, name, price)

FREE For free products, payment_id starts with FREE_

Try It Live

Click a button to test the API...