پیشقیمت سفارش
POST
/api/v1/orders/quotescope: prices:readاحراز هویت: Bearerlive و test
قبل از ثبت سفارش، مبلغ نهایی را به تومان (و معادل TON) بگیر و به مشتری نشان بده. پاسخ یک id امضاشده دارد که تا expires_at (۲ دقیقه) معتبر است؛ آن را بهصورت quote_id به POST /orders، /boosts/orders یا /gifts/send بده تا اگر قیمت در این فاصله بالا رفت، سفارش بدون کسر پول با 409 price_changed رد شود.
درخواست
| نام | محل | نوع | توضیح | |
|---|---|---|---|---|
Authorization | header | string | الزامی | Bearer sk_live_… یا Bearer sk_test_… |
بدنه (JSON)
| فیلد | نوع | توضیح | |
|---|---|---|---|
type | string | الزامی | stars، product یا boost |
quantity | integer | اختیاری | تعداد (استارز حداقل ۵۰؛ بوست ۱ تا سقف) |
product_id | integer | اختیاری | برای type=product |
duration | integer | اختیاری | برای type=boost: مدت به روز (از GET /boosts) |
نمونه
curl -X POST "https://stard-market.ir/api/v1/orders/quote" \
-H "Authorization: Bearer $STARD_API_KEY" \
-H "Content-Type: application/json" \
-d '{"type": "stars", "quantity": 500}'const res = await fetch("https://stard-market.ir/api/v1/orders/quote", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.STARD_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"type": "stars",
"quantity": 500
}),
});
const data = await res.json();
if (!res.ok) throw new Error(`${data.error.code}: ${data.error.message}`);
console.log(data);type StardError = { error: { type: string; code: string; message: string; param: string | null; request_id: string } };
const res = await fetch("https://stard-market.ir/api/v1/orders/quote", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.STARD_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"type": "stars",
"quantity": 500
}),
});
if (!res.ok) {
const { error } = (await res.json()) as StardError;
throw new Error(`${error.code}: ${error.message} (${error.request_id})`);
}
const data: Record<string, unknown> = await res.json();import os
import requests
r = requests.post(
"https://stard-market.ir/api/v1/orders/quote",
headers={
"Authorization": f"Bearer {os.environ['STARD_API_KEY']}",
},
json={
"type": "stars",
"quantity": 500
},
timeout=20,
)
data = r.json()
if r.status_code >= 400:
raise RuntimeError(f"{data['error']['code']}: {data['error']['message']}")
print(data)<?php
$ch = curl_init("https://stard-market.ir/api/v1/orders/quote");
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("STARD_API_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"type" => "stars",
"quantity" => 500
]),
CURLOPT_TIMEOUT => 20,
]);
$data = json_decode(curl_exec($ch), true);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if ($status >= 400) {
throw new RuntimeException($data["error"]["code"] . ": " . $data["error"]["message"]);
}
print_r($data);package main
import (
"fmt"
"io"
"net/http"
"os"
"strings"
)
func main() {
body := strings.NewReader(`{"type": "stars", "quantity": 500}`)
req, _ := http.NewRequest("POST", "https://stard-market.ir/api/v1/orders/quote", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("STARD_API_KEY"))
req.Header.Set("Content-Type", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
b, _ := io.ReadAll(res.Body)
fmt.Println(res.StatusCode, string(b))
}پاسخ — 200
{
"object": "quote",
"id": "qt_1790963122_2249000_122dd345912201ab58da15f0ac16f63a",
"type": "stars",
"quantity": 500,
"product_id": null,
"duration": null,
"amount": 2249000,
"unit_price": 4498,
"currency": "IRT",
"ton_amount": "5.6342",
"product_available": true,
"not_available_reason": null,
"expires_at": "2026-10-02T17:45:22Z",
"note": "quote_id را به POST /orders یا /boosts/orders بده؛ اگر قیمت تا آن لحظه بالا رفته باشد سفارش با 409 price_changed رد میشود و پولی کسر نمیشود."
}هدرهای پاسخ
content-type: application/json
x-request-id: req_ZykdDzNsBRzXELW04rdp
x-ratelimit-limit: 1000
x-ratelimit-remaining: 999خطاها
| HTTP | code | کی |
|---|---|---|
400 | parameter_invalid | نوع/تعداد نامعتبر |
404 | product_not_found | محصول پیدا نشد |
409 | boost_unavailable | این مدت/تعداد بوست فعلاً موجود نیست |
403 | insufficient_scope | کلید scope prices:read را ندارد |
401 | invalid_api_key / missing_api_key / api_key_revoked / api_key_expired | کلید نیامده، نامعتبر، باطل یا منقضی است |
429 | rate_limit_exceeded | سقف درخواست در دقیقه پر شده؛ بعد از Retry-After ثانیه دوباره بفرست |
محدودیت نرخ
پیشفرض ۶۰ درخواست در دقیقه برای هر کلید (قابل تنظیم در داشبورد). وضعیت در هدرهای X-RateLimit-* برمیگردد — جزئیات.
