सामग्री पर जाएँ
मेनू

साइट में खोजें

गाइड, ब्लॉग, API और प्रोडक्ट में खोजने के लिए लिखें।

↑ ↓ से आगे-पीछे · Enter से खोलें · Esc से बंद करें

API रेफ़रेंस

API

प्रोडक्ट

अपना प्रोडक्ट कैटलॉग पढ़ें और सिमैंटिक सर्च करें

Markdown के रूप में देखें

प्रोडक्ट endpoints आपके एजेंट का कैटलॉग खोलते हैं: उसकी लिस्ट देखें, कोई एक प्रोडक्ट पाएँ या उस पर सिमैंटिक सर्च चलाएँ। सिर्फ़ active (पब्लिश किए गए) प्रोडक्ट ही लौटाए जाते हैं: ड्राफ़्ट कभी नहीं दिखाए जाते।

Publishable key: कैटलॉग पढ़ने वाले endpoints के लिए API key एक publishable key की तरह काम करती है (यह आपके अकाउंट की पहचान करती है और इस्तेमाल मापती है; कैटलॉग का डेटा पब्लिक है)। इसे ब्राउज़र कोड से इस्तेमाल करना सुरक्षित है, बिल्कुल Stripe की publishable key की तरह।

MethodPathविवरण
GET/v1/productsList active products
GET/v1/products/:idGet a single product
GET/v1/products/searchSemantic search over the catalog

प्रोडक्ट की लिस्ट

Active प्रोडक्ट की पेज-दर-पेज लिस्ट लौटाता है। कैटेगरी टैग या टाइप से फ़िल्टर करें:

Parameterटाइपविवरण
limitnumber1-100, default 50
offsetnumberPagination offset, default 0
tagstringFilter by category tag
kindstring'product' or 'service'
GET/v1/products
curl "https://rest-api.tbit.app/v1/products?limit=20&tag=fiestas&kind=product" \
  -H "X-API-Key: $TBIT_API_KEY"
const response = await fetch('https://rest-api.tbit.app/v1/products?limit=20&tag=fiestas&kind=product', {
  headers: {
    'X-API-Key': process.env.TBIT_API_KEY,
  },
});
const data = await response.json();
import axios from 'axios';

const { data } = await axios.get(
  'https://rest-api.tbit.app/v1/products?limit=20&tag=fiestas&kind=product',
  {
    headers: {
      'X-API-Key': process.env.TBIT_API_KEY,
    },
  },
);
import os
import requests

response = requests.get(
    'https://rest-api.tbit.app/v1/products?limit=20&tag=fiestas&kind=product',
    headers={'X-API-Key': os.environ['TBIT_API_KEY']},
)
data = response.json()
<?php
$ch = curl_init('https://rest-api.tbit.app/v1/products?limit=20&tag=fiestas&kind=product');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'X-API-Key: ' . getenv('TBIT_API_KEY'),
    ],
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);
Response
{
  "data": [
    {
      "_id": "prod_id_1",
      "kind": "product",
      "title": "Kit fiesta dinosaurios",
      "description": "Decoración completa para fiesta infantil",
      "media": [
        { "url": "https://api.tbit.app/media/dino-kit.jpg", "alt": "Kit fiesta", "type": "image", "position": 0 }
      ],
      "category_tags": ["fiestas", "infantil"],
      "currency": "COP",
      "base_price": 95000,
      "compare_at_price": 120000,
      "variants": [
        {
          "id": "var_id_1",
          "title": "Grande",
          "price": 95000,
          "selected_options": [{ "name": "Tamaño", "value": "Grande" }]
        }
      ],
      "created_at": "2024-09-01T12:00:00Z",
      "updated_at": "2024-09-01T12:00:00Z"
    }
  ],
  "pagination": {
    "total": 134,
    "limit": 20,
    "offset": 0,
    "has_more": true
  }
}

एक प्रोडक्ट पाएँ

id से एक प्रोडक्ट पाएँ। ड्राफ़्ट, अनजान ids और किसी दूसरे एजेंट के प्रोडक्ट 404 लौटाते हैं:

GET/v1/products/prod_id_1
curl "https://rest-api.tbit.app/v1/products/prod_id_1" \
  -H "X-API-Key: $TBIT_API_KEY"
const response = await fetch('https://rest-api.tbit.app/v1/products/prod_id_1', {
  headers: {
    'X-API-Key': process.env.TBIT_API_KEY,
  },
});
const data = await response.json();
import axios from 'axios';

const { data } = await axios.get(
  'https://rest-api.tbit.app/v1/products/prod_id_1',
  {
    headers: {
      'X-API-Key': process.env.TBIT_API_KEY,
    },
  },
);
import os
import requests

response = requests.get(
    'https://rest-api.tbit.app/v1/products/prod_id_1',
    headers={'X-API-Key': os.environ['TBIT_API_KEY']},
)
data = response.json()
<?php
$ch = curl_init('https://rest-api.tbit.app/v1/products/prod_id_1');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'X-API-Key: ' . getenv('TBIT_API_KEY'),
    ],
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);
Response
{
  "error": {
    "code": "NOT_FOUND"
  }
}

सिमैंटिक सर्च

सर्च vector embeddings इस्तेमाल करता है, keyword matching नहीं: "fiesta de dinosaurios" जैसी query डायनासोर थीम वाले पार्टी प्रोडक्ट ढूँढ लेती है, भले ही किसी टाइटल में ठीक वही शब्द न हों। सर्च की सीमा हर key पर प्रति मिनट 30 requests है (100/min की ग्लोबल सीमा के अलावा)। हर नतीजे में relevance score हो सकता है:

GET/v1/products/search
curl "https://rest-api.tbit.app/v1/products/search?q=fiesta%20de%20dinosaurios&limit=10" \
  -H "X-API-Key: $TBIT_API_KEY"
const response = await fetch('https://rest-api.tbit.app/v1/products/search?q=fiesta%20de%20dinosaurios&limit=10', {
  headers: {
    'X-API-Key': process.env.TBIT_API_KEY,
  },
});
const data = await response.json();
import axios from 'axios';

const { data } = await axios.get(
  'https://rest-api.tbit.app/v1/products/search?q=fiesta%20de%20dinosaurios&limit=10',
  {
    headers: {
      'X-API-Key': process.env.TBIT_API_KEY,
    },
  },
);
import os
import requests

response = requests.get(
    'https://rest-api.tbit.app/v1/products/search?q=fiesta%20de%20dinosaurios&limit=10',
    headers={'X-API-Key': os.environ['TBIT_API_KEY']},
)
data = response.json()
<?php
$ch = curl_init('https://rest-api.tbit.app/v1/products/search?q=fiesta%20de%20dinosaurios&limit=10');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER => [
        'X-API-Key: ' . getenv('TBIT_API_KEY'),
    ],
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);
Response
{
  "data": [
    {
      "_id": "prod_id_1",
      "kind": "product",
      "title": "Kit fiesta dinosaurios",
      "currency": "COP",
      "base_price": 95000,
      "score": 0.91
    }
  ]
}

सभी endpoints इस ढाँचे वाले प्रोडक्ट ऑब्जेक्ट लौटाते हैं। base_price कैटलॉग की करेंसी में एक सादा नंबर है (जैसे COP, बिना छोटी इकाइयों के)। compare_at_price सिर्फ़ तब होता है जब प्रोडक्ट सेल में हो, और यह हमेशा base_price से ज़्यादा होता है:

फ़ील्डटाइपविवरण
_idstringProduct id
kindstring'product' or 'service'
titlestringProduct title
descriptionstringProduct description
mediaarrayArray of { url, alt?, type: 'image' | 'video', position? }
category_tagsstring[]Category tags
currencystringISO 4217 currency code
base_pricenumberPrice as a plain number (e.g. COP, no minor units)
compare_at_pricenumber?Only when on sale; always higher than base_price
variantsarrayArray of { id, title, price, compare_at_price?, selected_options: [{ name, value }] }
created_atstringISO 8601 timestamp
updated_atstringISO 8601 timestamp