Integrate live diamond inventory and orders into your website
All endpoints require your API Key in the X-API-Key request header.
X-API-Key: dsm_your_api_key_here
Your API key is provided by the stock manager. Keep it secret — it gives access to your company's orders.
https://www.diamond.codimai.com
| Parameter | Type | Description |
|---|---|---|
| page | integer | Page number (default: 1) |
| page_size | integer | Results per page, max 200 (default: 50) |
| shape | string | Filter by shape e.g. Round |
| color | string | Filter by color e.g. D |
| clarity | string | Filter by clarity e.g. VS1 |
| carat_min | float | Minimum carat weight |
| carat_max | float | Maximum carat weight |
| total_price_min | float | Minimum total price (USD) |
| total_price_max | float | Maximum total price (USD) |
| lab | string | Filter by lab e.g. GIA, IGI |
{
"total": 120,
"page": 1,
"page_size": 50,
"items": [
{
"id": 1,
"status": "available",
"data": {
"stone_id": "DIA-001",
"shape": "Round",
"carat": 1.52,
"color": "D",
"clarity": "VS1",
"cut": "Excellent",
"lab": "GIA",
"total_price": 8500,
"image_urls": ["https://example.com/img/dia001.jpg"],
"video_urls": []
}
}
]
}
Returns full details of a single available diamond by its ID.
Place an order for one or more diamonds. Selected diamonds are automatically placed on hold. The hold expires if not confirmed by the stock manager.
Company details are auto-filled from your API key. You only need to send items. Contact name, email, phone, and company name are pulled automatically from your registered account.
| Field | Required | Description |
|---|---|---|
| items | Yes | Array of {"diamond_id": N} objects (max 50) |
| note | No | Order note or delivery instructions |
| customer_name | No | Override contact name for this order (defaults to your registered contact person) |
| customer_email | No | Override email for this order (defaults to your registered email) |
| customer_phone | No | Override phone for this order (defaults to your registered phone) |
// Minimal request — company info auto-filled from API key
{
"items": [
{ "diamond_id": 1 },
{ "diamond_id": 5 }
],
"note": "Please deliver by Friday"
}
// Response (201 Created)
{
"id": 42,
"status": "pending",
"customer_name": "Rajesh Shah", // from your registered contact
"customer_company": "Shah Jewellers", // from your registered company name
"customer_email": "rajesh@example.com",
"customer_phone": "+91 98765 43210",
"total_amount": 15200,
"items": [ ... ],
"created_at": "2024-01-15T10:30:00"
}
Returns only orders placed by your API key. Optional ?status=pending|confirmed|shipped|cancelled filter.
Returns full detail of one of your orders including all diamond snapshots.
Order starts as pending — diamonds are put on hold. The stock manager confirms → confirmed, then ships → shipped. Either party can cancel at any stage.
const API_KEY = 'dsm_your_key_here';
const BASE = 'https://www.diamond.codimai.com';
// Browse available diamonds
async function getStock(page = 1) {
const r = await fetch(`${BASE}/api/public/stock.php?page=${page}&page_size=20`, {
headers: { 'X-API-Key': API_KEY }
});
return r.json(); // { total, page, page_size, items: [...] }
}
// Place an order — company info is auto-filled from your API key
async function placeOrder(diamondIds, note = '') {
const r = await fetch(`${BASE}/api/public/orders.php`, {
method: 'POST',
headers: { 'X-API-Key': API_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({
items: diamondIds.map(id => ({ diamond_id: id })),
note
})
});
return r.json();
}