Import / Export data via API Elbuz
The API provides access to information stored in the database of the Elbuz software product. Items can be retrieved, added, updated, and deleted.
Exchange format, authentication
- The JSON format is used for interaction.
- Requests use the POST HTTP method.
- For authentication, a username and password are used to obtain a token.
Basic Information
Access limitation
- API access with indication of IP addresses from which access is possible.
- Read-only mode (blocks access to change data).
- By the number of requests - no more than 30 connections within 60 seconds.
Pagination - pagination
The output of the requested data is paginated. The maximum number of entries depends on the element type, the default is 100 entries per page. The "page" parameter is used to specify the page number.
When answering, "meta" information is generated, for example:
[meta] => array ( [item_scope] => category [total_row] => 474 [page_total] => 5 [page_next] => 2 [page_current] => 1 [request_time] => 00:00:00 )
Description meta information:
- item_scope - the type of the requested item
- total_row - total number of elements
- page_total - total number of pages
- page_next - next page number
- page_current - current page
- request_time - time taken to get information
Selection of elements
Depending on the element type, different parameters are available that limit the data selection, for example, you can get products of only a certain category, for this you need to pass the category_id parameter in which you specify the category ID.
Restriction of output fields
The system allows you to increase the speed of work for the exchange of information, receiving only the data you need. For example, a product card can contain 150 fields, while you need to get only 10 of them, you can specify the set of fields you need when requesting data, thereby significantly reducing the amount of data transferred and increasing the speed of both response and time for further processing this information on your site. For this purpose, the limit_field parameter is used, in which you need to list the fields you need, separated by commas.
Description of working with the API
API service start address: https://your_domain_address/admin/index.php?route=
The route parameter takes a path based on which the system understands what operation to perform.
The following values are available for the route parameter:
- api/login - getting a token to get started
- api/scope/describe – description of element fields
- api/scope/get - getting elements
- api/scope/add - adding elements
- api/scope/update - update elements
- api/scope/delete - deleting elements
The route parameter can be supplemented with the element type on which the operation is performed.
The following values are available depending on the operation type:
- category - product categories
- product – base catalog products
- product_price - products from price lists
- attribute - product attributes
- attribute_block - attribute blocks
- language - languages
- article - articles
- manufacturer - manufacturers
- stock_status - stock statuses
- warehouse - warehouses
- store - stores
- company - companies
- contractor - contractors
- contractor_group - groups of contractors
- currency - currencies
- document - documents
- document_type - types of documents
- document_status - document statuses
- document_payment_status - payment statuses
- document_delivery_status - delivery statuses
An example of a link to get a list of product categories: https://your_domain_address/admin/index.php?route=api/scope/get/category
Also, the element type can be passed in the scope parameter via a POST request, then it is not required to specify the type in the link.
Creating an API user, getting a token
Data exchange via API is performed using login and password (token). To create a new API user, go to the "Settings" subsystem
Then select "Access API Jumper"
Click the + button to create a new user
To start working with the API, you need to get a token, for this you need to send a POST request with a login and password, specifying route=api/login.
Full address:
https://your_domain_address/admin/index.php?route=api/login
Required POST parameters:
- username - your username
- key - password
In response, you will receive a token, which will be indicated in the api_token field, this token must be used for further requests to the API.
An example implementation in PHP (the send_data_to_jumper_api() function is a wrapper for CURL)
Retrieving Items
To get a list of items, send a POST request with route=api/scope/get.
Full address:
https://your_domain_address/admin/index.php?route=api/scope/get
Required POST parameters:
- api_token - the token received earlier
- scope is the id of the element from which you want to get data. The element code can be specified in the link, in which case this parameter is optional.
List of available element codes:- category - product categories
- product – base catalog products
- product_price - products from price lists
- attribute - product attributes
- attribute_block - attribute blocks
- language - languages
- article - articles
- manufacturer - manufacturers
- stock_status - stock statuses
- warehouse - warehouses
- store - stores
- company - companies
- contractor - contractors
- contractor_group - groups of contractors
- currency - currencies
- document - documents
- document_type - types of documents
- document_status - document statuses
- document_payment_status - payment statuses
- document_delivery_status - delivery statuses
Optional parameters:
- page - the page number for getting the next list of records
- limit_field - list of fields to limit output
- extend - getting extended data. For example, when receiving a product card, you can expand the information and receive additional data such as:
- attribute – product attributes
- image - product photo
- category - list of categories where the product is located
- extend_limit_field_attribute - list of fields to limit the output of extended information on attributes
- extend_limit_field_image - a list of fields for limiting the output of extended information about the photo
- extend_limit_field_category - a list of fields to limit the output of extended information about categories
PHP Implementation Example
Adding elements
To add a new element, send a POST request with route=api/scope/add.
Full address:
https://your_domain_address/admin/index.php?route=api/scope/add
Required POST parameters:
- api_token - the token received earlier
- scope is the id of the element to be added. The element code can be specified in the link, in which case this parameter is optional.
List of available element codes:- category - product categories
- product – base catalog products
- product_price - products from price lists
- attribute - product attributes
- attribute_block - attribute blocks
- article - articles
- manufacturer - manufacturers
- document - documents
- name - the name of the element (depending on the type of element, different fields can be passed)
PHP Implementation Example
Updating Items
To update an element, send a POST request with route=api/scope/update.
Full address:
https://your_domain_address/admin/index.php?route=api/scope/update
Required POST parameters:
- api_token - the token received earlier
- scope is the id of the element to be updated. The element code can be specified in the link, in which case this parameter is optional.
List of available element codes:- category - product categories
- product – base catalog products
- currency - currency chickens
- contractor - contractors
- name - the name of the element (depending on the type of element, different fields can be passed)
PHP Implementation Example
Removing elements
To delete an element, send a POST request with route=api/scope/delete.
Full address:
https://your_domain_address/admin/index.php?route=api/scope/delete
Required POST parameters:
- api_token - the token received earlier
- scope is the id of the element to be removed. The element code can be specified in the link, in which case this parameter is optional.
List of available element codes:- category - product categories
- product – base catalog products
- attribute - product attributes
- attribute_block - attribute blocks
- contractor - contractors
- article - articles
- manufacturer - manufacturers
- document - documents
- Element ID (depending on the element type, a different field name is used)
PHP Implementation Example
Description of element fields
To get the description of element fields, send a POST request with route=api/scope/describe.
Full address:
https://your_domain_address/admin/index.php?route=api/scope/describe
Required POST parameters:
- api_token - the token received earlier
- scope is the id of the element by which information is to be obtained. The element code can be specified in the link, in which case this parameter is optional.
List of available element codes:- product – base catalog products
- product_price - products from price lists
- manufacturer - manufacturers
- contractor - contractors
- document - documents
- user - users (employees)
- company - companies
PHP Implementation Example
Extended API example, PHP language
Extended examples of working with the API using the PHP language are available at this link .
You can test various modes of operation, for this you need to activate the desired variable to activate the block of code responsible for the required operation and element.