Live REST API Β· v1

Buy products with
a single API call.

Get your personal API key from the Telegram bot, top up your wallet, and purchase instantly β€” connect your own website or bot in minutes.

Quickstart

Three steps to your first purchase.

01

Get your key

Open the Telegram bot β†’ πŸ”‘ API (or Profile β†’ API Access) β†’ Generate. Copy your key (starts with mk_).

02

Top up your wallet

Use the bot's Top Up button. Purchases are charged against your wallet balance.

03

Call the API

Send your key in the X-API-Key header on every request. That's it.

Base URL: https://api.ai-market.store/api/v1  Β·  Auth: X-API-Key: mk_...  Β·  Rate limit: 20 req / min

πŸ€– Connect with AI β€” no coding needed

Using Claude Code or Cursor? Paste the prompt below, replace the last two lines, and let the AI build your integration for you.

I want to integrate the AI-Market API into my project.

API base URL: {BASE}
Auth: send my key on EVERY request in the header  ->  X-API-Key: <MY_KEY>
(I get the key from the AI-Market Telegram bot: tap "πŸ”‘ API" -> Generate.)

Endpoints:
- GET  /balance   -> { "balance": number, "currency": "USDT" }   (my wallet balance)
- GET  /products  -> { "products": [ { "id", "name", "price", "stock", "in_stock" } ] }
- POST /purchase  -> buy a product using my wallet balance
      body:   { "product_id": "<id from /products>", "quantity": 1 }
      header: Idempotency-Key: <any-unique-id>   (optional; makes retries safe, never double-charges)
      success -> { "success": true, "order_id", "codes": [...], "balance_remaining" }

Rules to follow:
- Send the X-API-Key header on every request.
- Branch on the JSON "code" field for errors:
  NO_KEY / INVALID_KEY (401), VALIDATION (400), INSUFFICIENT_BALANCE (402),
  FORBIDDEN (403), PRODUCT_NOT_FOUND (404), OUT_OF_STOCK (409),
  RATE_LIMITED (429 -> wait "retry_after_seconds" then retry).
- Rate limit: max 20 requests per minute.
- A purchase only works if my wallet has enough balance (I top up inside the bot).

Now please build this for me:
>>> DESCRIBE WHAT YOU WANT, e.g. "a Node.js script that lists products and lets me buy one by id" <<<

Use my API key: >>> PASTE_YOUR_API_KEY_HERE <<<
How to use: open Claude Code / Cursor in an empty folder β†’ paste this prompt β†’ replace the two >>> … <<< lines with what you want and your key β†’ send. The AI writes, runs, and fixes the code for you.

Products

Tap to load the live catalog β€” real product ids, prices & stock, straight from the store.

Endpoints

Three endpoints. Replace YOUR_API_KEY with your key.

GET/balancecurrent wallet balance
GET/productslist products with live stock
POST/purchasebuy with balance, returns codes

Full example

cURL
JavaScript
Python
# 1) Check your balance
curl -s "{BASE}/balance" \
  -H "X-API-Key: YOUR_API_KEY"

# 2) List products
curl -s "{BASE}/products" \
  -H "X-API-Key: YOUR_API_KEY"

# 3) Buy 1 unit (Idempotency-Key makes retries safe)
curl -s -X POST "{BASE}/purchase" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: order-001" \
  -d '{"product_id":"002","quantity":1}'
const BASE = "{BASE}";
const KEY  = "YOUR_API_KEY";
const headers = { "X-API-Key": KEY, "Content-Type": "application/json" };

// 1) Balance
const balance = await fetch(`${BASE}/balance`, { headers }).then(r => r.json());
console.log("Balance:", balance);

// 2) Products
const { products } = await fetch(`${BASE}/products`, { headers }).then(r => r.json());

// 3) Purchase (Idempotency-Key makes retries safe)
const res = await fetch(`${BASE}/purchase`, {
  method: "POST",
  headers: { ...headers, "Idempotency-Key": "order-001" },
  body: JSON.stringify({ product_id: "002", quantity: 1 }),
});
const order = await res.json();
if (order.success) console.log("Codes:", order.codes);
else console.error("Failed:", order.code, order.error);
import requests

BASE = "{BASE}"
KEY  = "YOUR_API_KEY"
headers = {"X-API-Key": KEY, "Content-Type": "application/json"}

# 1) Balance
print(requests.get(f"{BASE}/balance", headers=headers).json())

# 2) Products
products = requests.get(f"{BASE}/products", headers=headers).json()["products"]

# 3) Purchase (Idempotency-Key makes retries safe)
res = requests.post(
    f"{BASE}/purchase",
    headers={**headers, "Idempotency-Key": "order-001"},
    json={"product_id": "002", "quantity": 1},
).json()

print(res["codes"] if res.get("success") else res)

Errors & handling

Every error returns JSON with a stable code you can branch on.

StatuscodeMeaningWhat to do
401NO_KEY / INVALID_KEYMissing or revoked keyCheck the header; regenerate in the bot
400VALIDATIONBad body (quantity 1–10)Fix the request body
402INSUFFICIENT_BALANCEWallet too lowTop up; see required / available
403FORBIDDENAccount suspendedContact support
404PRODUCT_NOT_FOUNDUnknown product idRe-fetch /products
409OUT_OF_STOCKNot enough stockLower quantity or retry later
429RATE_LIMITEDOver 20 req/minBack off retry_after_seconds
Idempotency. Pass an Idempotency-Key header on POST /purchase. Retrying with the same key within 24h returns the original result instead of charging twice.