ساخت هشدار قیمت
POST
/api/v1/price-alertsscope: prices:readاحراز هویت: Bearerlive و test
وقتی قیمت استارز، TON یا یک محصول از حد تعیینشده پایینتر یا بالاتر رفت، یک بار رویداد وبهوک price.alert برایت فرستاده میشود (بررسی هر دقیقه). حداکثر ۵۰ هشدار فعال. برای دریافت، یک وبهوک هممحیط بساز.
درخواست
| نام | محل | نوع | توضیح | |
|---|---|---|---|---|
Authorization | header | string | الزامی | Bearer sk_live_… یا Bearer sk_test_… |
بدنه (JSON)
| فیلد | نوع | توضیح | |
|---|---|---|---|
asset | string | الزامی | stars، ton یا product |
product_id | integer | اختیاری | برای asset=product |
condition | string | الزامی | below یا above |
price | integer | الزامی | قیمت هدف به تومان |
نمونه
curl -X POST "https://stard-market.ir/api/v1/price-alerts" \
-H "Authorization: Bearer $STARD_API_KEY" \
-H "Content-Type: application/json" \
-d '{"asset": "stars", "condition": "below", "price": 4000}'const res = await fetch("https://stard-market.ir/api/v1/price-alerts", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.STARD_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"asset": "stars",
"condition": "below",
"price": 4000
}),
});
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/price-alerts", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.STARD_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
"asset": "stars",
"condition": "below",
"price": 4000
}),
});
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/price-alerts",
headers={
"Authorization": f"Bearer {os.environ['STARD_API_KEY']}",
},
json={
"asset": "stars",
"condition": "below",
"price": 4000
},
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/price-alerts");
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([
"asset" => "stars",
"condition" => "below",
"price" => 4000
]),
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(`{"asset": "stars", "condition": "below", "price": 4000}`)
req, _ := http.NewRequest("POST", "https://stard-market.ir/api/v1/price-alerts", 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))
}پاسخ — 201
{
"object": "price_alert",
"id": "pa_9SzgiaSZTsX3dqeX10BI",
"environment": "test",
"asset": "stars",
"product_id": null,
"condition": "below",
"price": {
"amount": 4000,
"currency": "IRT"
},
"status": "active",
"last_value": null,
"triggered_at": null,
"created_at": "2026-10-02T17:43:25Z"
}هدرهای پاسخ
content-type: application/json
x-request-id: req_58yHzL3zlPLzO9HFld2x
x-ratelimit-limit: 1000
x-ratelimit-remaining: 979خطاها
| HTTP | code | کی |
|---|---|---|
400 | product_not_found | asset=product بدون product_id معتبر |
400 | limit_reached | بیش از ۵۰ هشدار فعال |
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-* برمیگردد — جزئیات.
