أمثلة برمجية
أكثر الطلبات استخدامًا بأربع لغات. لم تُنشر حزم رسمية بعد؛ وإن أردت عميلًا فولّده من مستند OpenAPI.
تحقّق من مفتاحك
GET /me
curl "https://api.opentourbase.com/api/supplier/v1/me" \
-H "Authorization: Bearer $API_KEY"عرض المنتجات
GET /products
curl "https://api.opentourbase.com/api/supplier/v1/products?limit=25" \
-H "Authorization: Bearer $API_KEY"قراءة منتج واحد
GET /products/{uuid}
curl "https://api.opentourbase.com/api/supplier/v1/products/{uuid}" \
-H "Authorization: Bearer $API_KEY"قراءة التوافر
GET /options/{optionUuid}/availability
curl "https://api.opentourbase.com/api/supplier/v1/options/{optionUuid}/availability?local_date=2026-12-05" \
-H "Authorization: Bearer $API_KEY"حجز مؤقت
POST /bookings
curl -X POST "https://api.opentourbase.com/api/supplier/v1/bookings" \
-H "Authorization: Bearer $API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"optionId":"{optionId}","availabilityId":"{availabilityId}","units":[{"unitId":"{unitId}","quantity":2}],"reference":"ORDER-1042"}'تأكيد حجز
POST /bookings/{uuid}/confirm
curl -X POST "https://api.opentourbase.com/api/supplier/v1/bookings/{uuid}/confirm" \
-H "Authorization: Bearer $API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"contact":{"fullName":"Ana Beridze","email":"ana@example.com"},"payment":{"mode":"offline"}}'قراءة الأحداث
GET /events
curl "https://api.opentourbase.com/api/supplier/v1/events?after=evt_01JD3XB0V7M2A8K4R6T9W1Y3Z5" \
-H "Authorization: Bearer $API_KEY"إضافة عنوان Webhook
POST /webhook-endpoints
curl -X POST "https://api.opentourbase.com/api/supplier/v1/webhook-endpoints" \
-H "Authorization: Bearer $API_KEY" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Content-Type: application/json" \
-d '{"url":"https://example.com/webhooks","events":["booking.confirmed","booking.cancelled"]}'التحقق من توقيع Webhook
import crypto from "node:crypto";
export function verify(rawBody, headers, secret, toleranceSec = 300) {
const id = headers["webhook-id"], ts = headers["webhook-timestamp"], sig = headers["webhook-signature"];
if (!id || !ts || !sig || Math.abs(Date.now() / 1000 - Number(ts)) > toleranceSec) return false;
const key = Buffer.from(secret.replace(/^whsec_/, ""), "base64");
const expected = crypto.createHmac("sha256", key).update(`${id}.${ts}.${rawBody}`).digest("base64");
return sig.split(" ").some((p) => {
const [v, s] = p.split(",");
return v === "v1" && s && s.length === expected.length && crypto.timingSafeEqual(Buffer.from(s), Buffer.from(expected));
});
}