# Product stock

::: info
Har bir javob umumiy konvertda qaytadi — `code`, `message`, `messages`, `status_code`, `time` — foydali yuk esa `data` ichida. Quyidagi jadvallar faqat `data` ichini tavsiflaydi.
:::

## POST /product-stock/get-paging

Get product-stocks by paging

**Kerakli ruxsat:** `product_stock` · [ruxsatlar qanday ishlaydi](https://docs.bito.uz/api/permissions.md)

**So‘rov namunasi**

::: code-group

```bash [curl]
curl -X POST 'https://api.bito.uz/integration-api/integration/api/v2/product-stock/get-paging' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "page": 1,
  "limit": 20
}'
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/product-stock/get-paging', {
  method: 'POST',
  headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "page": 1,
    "limit": 20
  }),
})
const { code, data } = await res.json()
```

```python [Python]
import os
import requests

res = requests.request(
    "POST",
    "https://api.bito.uz/integration-api/integration/api/v2/product-stock/get-paging",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "page": 1,
        "limit": 20,
    },
)
print(res.json())
```

```php [PHP]
<?php
$body = <<<'JSON'
{
  "page": 1,
  "limit": 20
}
JSON;

$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/product-stock/get-paging');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => ['api-key: ' . getenv('BITO_API_KEY'), 'Content-Type: application/json'],
    CURLOPT_POSTFIELDS => $body,
    CURLOPT_RETURNTRANSFER => true,
]);
$response = json_decode(curl_exec($ch), true);
```

:::

**So‘rov tanasi**

| Maydon | Tur | Majburiy | Tavsif |
|---|---|---|---|
| `page` | `number` | Ha | Standart: `1` |
| `limit` | `number` | Ha | Standart: `20` |
| `organization_id` | `string` | Yo‘q |  |
| `warehouse_id` | `string` | Yo‘q |  |
| `product_id` | `string` | Yo‘q |  |
| `states` | `string[]` | Yo‘q |  |
| `is_marked` | `boolean` | Yo‘q |  |
| `search` | `string` | Yo‘q |  |
| `nin` | `string[]` | Yo‘q |  |
| `purchase_id` | `string` | Yo‘q |  |
| `trade_id` | `string` | Yo‘q |  |
| `category_id` | `string` | Yo‘q |  |
| `sort` | `object` | Yo‘q |  |
| `sort.amount` | `boolean` | Yo‘q |  |
| `sort.name` | `number` | Yo‘q | asc 1 , desc -1 |
| `update_trade_id` | `string` | Yo‘q |  |
| `is_semi_product` | `boolean` | Yo‘q |  |
| `is_product` | `boolean` | Yo‘q |  |
| `is_material` | `boolean` | Yo‘q |  |
| `is_main_warehouse` | `boolean` | Yo‘q |  |
| `updated_at` | `string (date-time)` | Yo‘q | Only records updated at or after this time. |

```json
{
  "page": 1,
  "limit": 20,
  "organization_id": "string",
  "warehouse_id": "string",
  "product_id": "string",
  "states": [
    "string"
  ],
  "is_marked": false,
  "search": "string",
  "nin": [
    "string"
  ],
  "purchase_id": "string",
  "trade_id": "string",
  "category_id": "string",
  "sort": {
    "amount": false,
    "name": 0
  },
  "update_trade_id": "64b7f4d9e2b3b6a0b7c5d7ff",
  "is_semi_product": false,
  "is_product": false,
  "is_material": false,
  "is_main_warehouse": false,
  "updated_at": "2025-05-01T12:00:00Z"
}
```

**Javob**

`data.total` — jami yozuvlar soni, `data.data[]` — joriy sahifadagi yozuvlar. Quyidagi jadval bitta yozuvni tavsiflaydi.

| Maydon | Tur | Tavsif |
|---|---|---|
| `product` | `object` |  |
| `product._id` | `string` |  |
| `product.measure` | `object` |  |
| `product.measure._id` | `string` |  |
| `product.measure.system_code` | `string` |  |
| `product.measure.code` | `string` |  |
| `product.measure.short_name` | `string` |  |
| `product.measure.name` | `string` |  |
| `product.measure.decimal_count` | `number` |  |
| `product.name` | `string` |  |
| `product.barcode` | `string` |  |
| `product.sku` | `string` |  |
| `product.box_item` | `number` |  |
| `product.box_type` | `object` |  |
| `product.box_type._id` | `string` |  |
| `product.box_type.code` | `string` |  |
| `product.box_type.short_name` | `string` |  |
| `product.box_type.name` | `string` |  |
| `purchase_id` | `string` |  |
| `trade_id` | `string` |  |
| `organization` | `object` |  |
| `organization._id` | `string` |  |
| `organization.name` | `string` |  |
| `warehouse` | `object` |  |
| `warehouse._id` | `string` |  |
| `warehouse.name` | `string` |  |
| `state` | `string` |  |
| `mark` | `string` |  |
| `cost` | `number` |  |
| `amount` | `number` |  |
| `cost_currency_id` | `string` |  |
| `initial_cost` | `number` |  |
| `initial_cost_currency_id` | `string` |  |
| `created_at` | `string` |  |
| `updated_at` | `string` |  |
| `income_id` | `string` |  |
| `revision_id` | `string` |  |
| `transfer_id` | `string` |  |
| `write_off_id` | `string` |  |
| `purchase_return_id` | `string` |  |
| `production_operation_id` | `string` |  |
| `operation_item_id` | `string` |  |
| `total` | `number` |  |
| `income_date` | `string` |  |

```json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "total": 0,
    "data": [
      {
        "product": {
          "_id": "string",
          "measure": {
            "_id": "string",
            "system_code": "string",
            "code": "string",
            "short_name": "string",
            "name": "string",
            "decimal_count": 0
          },
          "name": "string",
          "barcode": "string",
          "sku": "string",
          "box_item": 0,
          "box_type": {
            "_id": "string",
            "code": "string",
            "short_name": "string",
            "name": "string"
          }
        },
        "purchase_id": "string",
        "trade_id": "string",
        "organization": {
          "_id": "string",
          "name": "string"
        },
        "warehouse": {
          "_id": "string",
          "name": "string"
        },
        "state": "string",
        "mark": "string",
        "cost": 0,
        "amount": 0,
        "cost_currency_id": "string",
        "initial_cost": 0,
        "initial_cost_currency_id": "string",
        "created_at": "string",
        "updated_at": "string",
        "income_id": "string",
        "revision_id": "string",
        "transfer_id": "string",
        "write_off_id": "string",
        "purchase_return_id": "string",
        "production_operation_id": "string",
        "operation_item_id": "string",
        "total": 0,
        "income_date": "string"
      }
    ]
  },
  "time": "2025-05-01T12:00:00Z"
}
```

## POST /product-stock/get-by-mark

Get the product that a marked (serial/IMEI) stock belongs to, enriched for sale (prices, taxes, available quantity). When warehouse_id is omitted, the organization's main warehouse is used. Returns a not-found error if no stock matches the mark.

**Kerakli ruxsat:** `product_stock` · [ruxsatlar qanday ishlaydi](https://docs.bito.uz/api/permissions.md)

**So‘rov namunasi**

::: code-group

```bash [curl]
curl -X POST 'https://api.bito.uz/integration-api/integration/api/v2/product-stock/get-by-mark' \
  -H "api-key: $BITO_API_KEY" \
  -H 'Content-Type: application/json' \
  -d '{
  "mark": "string"
}'
```

```js [JavaScript]
const res = await fetch('https://api.bito.uz/integration-api/integration/api/v2/product-stock/get-by-mark', {
  method: 'POST',
  headers: { 'api-key': process.env.BITO_API_KEY, 'Content-Type': 'application/json' },
  body: JSON.stringify({
    "mark": "string"
  }),
})
const { code, data } = await res.json()
```

```python [Python]
import os
import requests

res = requests.request(
    "POST",
    "https://api.bito.uz/integration-api/integration/api/v2/product-stock/get-by-mark",
    headers={"api-key": os.environ["BITO_API_KEY"]},
    json={
        "mark": "string",
    },
)
print(res.json())
```

```php [PHP]
<?php
$body = <<<'JSON'
{
  "mark": "string"
}
JSON;

$ch = curl_init('https://api.bito.uz/integration-api/integration/api/v2/product-stock/get-by-mark');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'POST',
    CURLOPT_HTTPHEADER => ['api-key: ' . getenv('BITO_API_KEY'), 'Content-Type: application/json'],
    CURLOPT_POSTFIELDS => $body,
    CURLOPT_RETURNTRANSFER => true,
]);
$response = json_decode(curl_exec($ch), true);
```

:::

**So‘rov tanasi**

| Maydon | Tur | Majburiy | Tavsif |
|---|---|---|---|
| `mark` | `string` | Ha | Mark (serial/IMEI) of the marked product-stock to look up |
| `organization_id` | `string` | Yo‘q | Organization id the stock belongs to |
| `warehouse_id` | `string` | Yo‘q | Warehouse id. When omitted, the organization's main warehouse is used |
| `states` | `string[]` | Yo‘q | Optional product-stock states to filter by (e.g. stock, sold) |
| `state` | `string` | Yo‘q | Mumkin qiymatlar: `stock`, `in_transit`, `trash`, `sold`, `booked`, `on_the_way`, `deleted`, `used` |

```json
{
  "mark": "string",
  "organization_id": "string",
  "warehouse_id": "string",
  "states": [
    "string"
  ],
  "state": "stock"
}
```

**Javob**

| Maydon | Tur | Tavsif |
|---|---|---|
| `_id` | `string` |  |
| `name` | `string` |  |
| `sku` | `string` |  |
| `barcode` | `string` |  |
| `image` | `string` |  |
| `measure_id` | `string` |  |
| `measure` | `object` |  |
| `box_item` | `number` |  |
| `is_marked` | `boolean` |  |
| `is_compound` | `boolean` |  |
| `is_service` | `boolean` |  |
| `category` | `object` |  |
| `prices` | `object[]` |  |
| `taxes` | `object[]` |  |
| `cost` | `number` |  |
| `cost_currency_id` | `string` |  |
| `quantity` | `number` | Available amount of the product in the resolved warehouse |
| `parent_id` | `string` |  |

```json
{
  "code": 0,
  "message": "Success",
  "status_code": 200,
  "data": {
    "_id": "string",
    "name": "string",
    "sku": "string",
    "barcode": "string",
    "image": "string",
    "measure_id": "string",
    "measure": {},
    "box_item": 0,
    "is_marked": false,
    "is_compound": false,
    "is_service": false,
    "category": {},
    "prices": [
      {}
    ],
    "taxes": [
      {}
    ],
    "cost": 0,
    "cost_currency_id": "string",
    "quantity": 0,
    "parent_id": "string"
  },
  "time": "2025-05-01T12:00:00Z"
}
```

---

*Bu sahifa OpenAPI spetsifikatsiyasidan yaratilgan.*
