# Price List

This article provides comprehensive information and documentation on a set of API methods specifically designed to handle price lists. By leveraging these methods, users can retrieve, search, and create price lists, allowing for seamless integration and management of price list data within the system.

The article includes detailed explanations, parameter descriptions, and usage examples for each API method, empowering developers to effectively utilize the capabilities provided by the price list API.

## <mark style="color:red;">Get Price List</mark>

PriceList is used to connect `ProductPrice` objects with catalog. Therefore, a catalog can have prices for its catalog items with this relation. PriceList and Catalog objects have `OneToMany` relationship. This means a PriceList can have relation with more than one catalog, while one catalog can only have one PriceList relation. However, with a new implementation for some clients, a PriceList can connect to the `extra_price_lists` field on a catalog object. Therefore, a catalog may also have more than one PriceList. This feature is for clients that want to have multiple price options for their different retail stores.

<table data-header-hidden><thead><tr><th width="144.40234375"></th><th width="117.3515625"></th><th width="107.625"></th><th></th></tr></thead><tbody><tr><td><strong>Parameter</strong></td><td><strong>Data Type</strong></td><td><strong>In</strong></td><td><strong>Description</strong></td></tr><tr><td>api_token</td><td>string</td><td>header</td><td><a href="/pages/qgPMhTo0zEnpGTXNhjIR">The API key of the customer’s account</a></td></tr><tr><td>name</td><td>string</td><td>query</td><td>Price list name</td></tr><tr><td>limit</td><td>integer</td><td>query</td><td>Amount of line items per page that will be returned</td></tr><tr><td>page</td><td>string</td><td>query</td><td>Page number to return</td></tr></tbody></table>

**Note:** If limit and page parameters are not sent, response returns 10 product prices by default.

**Request GET**

GET request is used for reading current price lists from Omnitron (both i1 and v1 can be used). This request is expected to return all price lists data according to page and limit parameters.

‘content\_type’ header represents the response type.

‘Authorization’ header is a required header for authentication. You can retrieve api\_token with login.

Path: `price_list/`

```python

import requests

url = "https://{customer_api_url}/api/v1/price_list/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

headers = {
    'content-type': 'application/json',
    'Authorization': 'Token {}'.format(api_token)
}

response = requests.get(url, headers=headers)
print(response.text)

```

**Response**

Response contains all price list data with given parameters (if exist) and with pagination. Response status is expected to be HTTP-200 Successful. Only ‘v1’ contains ‘created\_date’ and ‘modified\_date’ fields.

Resource properties are in Python format.

| **Property**   | **Data Type** | **Description**                                                                                                                         |
| -------------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| name           | string        | List name                                                                                                                               |
| code           | string        | The list ID in ERP                                                                                                                      |
| is\_auto\_sync | boolean       | Specifies whether the list will have synchronization with ERP. If the parameter is True, the list will be automatically updated by ERP. |
| currency       | string enum   | Currency of the price list                                                                                                              |
| modified\_date | datetime      | Last modified date of the price list                                                                                                    |
| created\_date  | datetime      | Shows the date when the price list was created                                                                                          |

“count” shows how many price lists exist in the system.

“next” shows the next cursor url to retrieve the desired price list.

“previous” shows the previous page url to retrieve the desired price list.

“results” shows every price list property with detailed field descriptions for the current page.

```json

{
  "count": 3,
  "next": "https://{customer_api_url}/api/v1/price_list/?page=2",
  "previous": null,
  "results": [
    {
      "pk": 1,
      "name": "Demo Price List",
      "code": null,
      "is_auto_sync": false,
      "currency": "try",
      "modified_date": "2022-03-02T09:20:07.171465Z",
      "created_date": "2022-03-02T09:20:07.171453Z"
    },
    {
      "pk": 2,
      "name": "Sync Price List",
      "code": "112",
      "is_auto_sync": true,
      "currency": "try",
      "modified_date": "2022-03-02T09:20:07.171465Z",
      "created_date": "2022-03-02T09:20:07.171453Z"
    },
    {
      "pk": 3,
      "name": "Shop Price List",
      "code": null,
      "is_auto_sync": false,
      "currency": "try",
      "modified_date": "2022-03-02T09:20:07.171465Z",
      "created_date": "2022-03-02T09:20:07.171453Z"
    }
  ]
}
```

## <mark style="color:red;">Search Price List</mark>

GET requests can be filtered with parameters. `price_list` endpoint gives the opportunity to make their GET request filtered according to PriceList fields.

<table data-header-hidden><thead><tr><th width="136.3046875"></th><th width="114.45703125"></th><th width="110.5546875"></th><th></th></tr></thead><tbody><tr><td><strong>Parameter</strong></td><td><strong>Data Type</strong></td><td><strong>In</strong></td><td><strong>Description</strong></td></tr><tr><td>api_token</td><td>string</td><td>header</td><td><a href="/pages/qgPMhTo0zEnpGTXNhjIR">The API key of the customer’s account</a></td></tr><tr><td>name</td><td>string</td><td>query</td><td>Price list's name</td></tr><tr><td>limit</td><td>integer</td><td>query</td><td>Amount of items per page that will be returned</td></tr><tr><td>page</td><td>string</td><td>query</td><td>Page number to return</td></tr></tbody></table>

**Note:** If limit and page parameters are not sent, response returns 10 product prices by default.

**Request GET**

Standard GET request with parameters (both i1 and v1 can be used). Parameters are used to get PriceLists with conditions.

Example: params = {'name': 'price'} is expected to return price lists with names containing ‘price’.

‘code’, ‘is\_auto\_sync’ and ‘created\_date’ parameters can also be added.

**Example:**

```json
{
	`name’: ‘price’,
	‘is_auto_sync’: True,
	‘code’: ‘default’,
	‘created_date__date__gte’: ‘2022-01-01’
} 

```

**Note:**

\['gt', 'gte', 'lt', 'lte', 'date\_\_gt', 'date\_\_gte', 'date\_\_lt', 'date\_\_lte'] lookup keys can be used for created\_date field. `code__exact` parameter can be used to get an exact match for the code field.

‘content\_type’ header represents the response type.

‘Authorization’ header is a required header for authentication. You can retrieve api\_token with login.

Path: `price_list/`

```python
import requests

url = "https://{customer_api_url}/api/v1/price_list/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

headers = {
    'content-type': 'application/json',
    'Authorization': 'Token {}'.format(api_token),
}

params = {
    'name': 'price'
}

response = requests.get(url, headers=headers, params=params)
print(response.text)
```

**Response**

Response contains all price list data with search parameters and with pagination. Response status is expected to be HTTP-200 Successful.

Only ‘v1’ contains ‘created\_date’ and ‘modified\_date’ fields.

Resource properties are in Python format.

<table data-header-hidden><thead><tr><th width="158.36328125"></th><th width="149.6875"></th><th></th></tr></thead><tbody><tr><td><strong>Property</strong></td><td><strong>Data Type</strong></td><td><strong>Description</strong></td></tr><tr><td>name</td><td>string</td><td>List name</td></tr><tr><td>code</td><td>string</td><td>The list ID in ERP</td></tr><tr><td>is_auto_sync</td><td>boolean</td><td>Specifies whether the list will have synchronization with ERP. If the parameter is True, the list will be automatically updated by ERP.</td></tr><tr><td>currency</td><td>EnumField</td><td>Currency of the price list</td></tr><tr><td>modified_date</td><td>datetime</td><td>Last modified date of the price list</td></tr><tr><td>created_date</td><td>datetime</td><td>Shows the date when the price list was created</td></tr></tbody></table>

“count” shows how many price lists exist in the system.

“next” shows the next page url to retrieve the desired price list.

“previous” shows the previous page url to retrieve the desired price list.

“results” shows every price list property with detailed field descriptions.

```json
{
  "count": 3,
  "next": null,
  "previous": null,
  "results": [

    {
      "id": 696,
      "name": "Shop Price List v02",
      "code": "Shop Price List v02",
      "is_auto_sync": true,
      "currency": "try",
      "modified_date": "2022-03-02T09:20:07.171465Z",
      "created_date": "2022-03-02T09:20:07.171453Z"
    },
    {
      "id": 697,
      "name": "Example Price List",
      "code": "example_price_list",
      "is_auto_sync": true,
      "currency": "try",
      "modified_date": "2022-03-02T09:20:07.171465Z",
      "created_date": "2022-03-02T09:20:07.171453Z"
    },
    {
      "id": 698,
      "name": "Example Price List 2",
      "code": "example_price_list_2",
      "is_auto_sync": true,
      "currency": "try",
      "modified_date": "2022-03-02T09:20:07.171465Z",
      "created_date": "2022-03-02T09:20:07.171453Z"
    }
  ]
}
```

## <mark style="color:red;">Create Price List</mark>

The prices of the products are kept in the price list. Therefore, before defining a price for a product, if there is no price list, it is necessary to define a price list first.

<table data-header-hidden><thead><tr><th width="116.02734375"></th><th width="109.92578125"></th><th width="87.1484375"></th><th width="98.5625"></th><th></th></tr></thead><tbody><tr><td><strong>Parameter</strong></td><td><strong>Data Type</strong></td><td><strong>In</strong></td><td><strong>Required</strong></td><td><strong>Description</strong></td></tr><tr><td>api_token</td><td>string</td><td>header</td><td>YES</td><td><a href="/pages/qgPMhTo0zEnpGTXNhjIR">The API key of the customer’s account</a></td></tr><tr><td>name</td><td>float</td><td>body</td><td>YES</td><td>List name</td></tr><tr><td>code</td><td>string</td><td>body</td><td>YES</td><td>The list ID in ERP</td></tr><tr><td>is_auto_sync</td><td>id</td><td>body</td><td>YES</td><td>Specifies whether the list will have synchronization with ERP. If the parameter is True, the list will be automatically updated by ERP. If it is False, price creation and updating processes are managed in Omnitron with excel.</td></tr><tr><td>currency</td><td>EnumField</td><td>body</td><td>YES</td><td>Currency of the price list.<br>Default value is “try”</td></tr></tbody></table>

**Request POST**

POST request is used to create a new price list.

‘content\_type’ header represents the response type.

‘Authorization’ header is a required header for authentication. You can retrieve api\_token with login.

‘name’ and ‘code’ fields should be unique.

Path: `v1/price_list/`

```python

import requests
import json

url = "https://{customer_api_url}/api/v1/price_list/"
api_token = "f532eXXXXXXXXXXXXXXXXX201XXXXX9332d"

headers = {
    'content-type': 'application/json',
    'Authorization': 'Token {}'.format(api_token)
}

data = {
    'name': 'shop_price_list_v03',
    'code': 'shop_price_list_v03',
    'is_auto_sync': True,
    'currency': 'usd',    
}

response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.text)

```

**Response**

Returns the created object data, after successfully creating the object. Response status is expected to be HTTP-201 Created.

Resource properties are in Python format.

| **Property**   | **Data Type** | **Description**                                                                                                                         |
| -------------- | ------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| pk             | int           | Primary key of the created list                                                                                                         |
| name           | string        | List name                                                                                                                               |
| code           | string        | The list ID in ERP                                                                                                                      |
| is\_auto\_sync | boolean       | Specifies whether the list will have synchronization with ERP. If the parameter is True, the list will be automatically updated by ERP. |
| modified\_date | date          | Last modified date of the price list                                                                                                    |
| created\_date  | date          | Shows the date when the price list was created                                                                                          |
| currency       | string enum   | Currency of the price list                                                                                                              |

```python

{
  "pk": 697,
  "name": "shop_price_list_v03",
  "code": "shop_price_list_v03",
  "is_auto_sync": true,
  "modified_date": "2021-07-12T08:05:37.190931Z",
  "created_date": "2021-07-12T08:05:37.190905Z",
  "currency": "usd"
}
```

**Bad Request Responses**

When the requested action cannot be executed, API gives an explanation about the request.

While creating a price list, if `is_auto_sync` is \_True \_and `code` is *None*, then the below error appears.

```python
{
    'non_field_errors': u'PriceList code is required when is_auto_sync is True.',
    'error_code': u'product_price_300_2'
}
```

‘name’ and ‘code’ fields should be unique.

```python
{
    'name': [ErrorDetail(string=u'price list with this name already exists.', code=u'unique')]
}
```

```python
{
    'code': [ErrorDetail(string=u'price list with this code already exists.', code=u'unique')]
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://apidocs.akinon.com/omnitron/integration/price/price-list.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
