Sony Center REST API Documentation
Introduction
Sony Center REST API is a web service that offers the same data and functionality as our web site. By using this API, You can gather all the information about our products, stock, stores, create orders, follow the status and delivery of Your existing orders, download documents for accounting and much more.
Communication
All request URLs start with https://center.lv/API/
followed by the name of the method, possible
method-specific selectors and the prefered response format - all separated by a single slash (/
).
General settings for obtaining the data is handled using GET variables while data upload is handled with POST variables. We are using UTF-8 as a default character encoding.
Each method will return its data enclosed in a variable that matches methods name, so API can return the data of multiple methods in a single response where its useful. Likewise, You can specify different GET settings for each method by doing the same.
Possible response formats include json
, print
(human-readable format) and
php
(serialized).
Authentication
To authenticate any request, include Your access token in HEADER TOKEN
.
Without a token, You will be perceived as an anonymous user and will only be able to retrieve public data.
Methods
This is not a full list of available methods. We plan to make more methods public in the future.
Global settings
Type | Name | Value | Info |
---|---|---|---|
GET | lang | string, array | Select one or multiple languages to receive data in. Possible values: en , lv and ru .Default value: lv . |
shop_stores
Method returns info about stores. This information will help to determine where the items are/will be located.
Settings
Type | Name | Value | Info |
---|---|---|---|
GET | name | boolean | Return the name of a store. |
GET | open | boolean | Return each store's working hours for the next seven days. Time is expressed in UNIX format as the period between the "from" and "till" values. |
Example
Request (PHP)
$c = curl_init(); curl_setopt_array($c, [ CURLOPT_URL => 'https://center.lv/API/shop_stores/json?'.http_build_query([ 'lang' => ['en', 'lv', 'ru'], 'name' => TRUE, ]), CURLOPT_HTTPHEADER => [ 'TOKEN: ...', ], ]); curl_exec($c); curl_close($c);
Response
{ "shop_stores": [ { "id": 1, "name": { "en": "Sony Center, Brivibas street 40", "lv": "Sony Center veikals, Brīvības ielā 40", "ru": "Магазин Sony Center, по адресу Brīvības iela 40" } }, ... ] }
shop_groups
Method returns info about product groups. It is important to note that each product can be in multiple groups at the same time, but it can be in none of them, too.
Settings
Type | Name | Value | Info |
---|---|---|---|
GET | name | boolean | Return the name of a group. |
Example
Request (PHP)
$c = curl_init(); curl_setopt_array($c, [ CURLOPT_URL => 'https://center.lv/API/shop_groups/json?'.http_build_query([ 'lang' => ['en', 'lv', 'ru'], 'name' => TRUE, ]), CURLOPT_HTTPHEADER => [ 'TOKEN: ...', ], ]); curl_exec($c); curl_close($c);
Response
{ "shop_groups": [ { "id": 1, "code": "Televizori un Mājas kino", "parent_id": null, "name": { "en": "Televisions & Home Cinema", "lv": "Televizori un Mājas kino", "ru": "Телевизоры и домашние кинотеатры" } }, ... ] }
shop_items
Method returns the info about products.
Settings
Type | Name | Value | Info |
---|---|---|---|
GET | box | boolean | Return the box contents of an item. |
GET | features | boolean | Return the features of an item. |
GET | files | integer | Include list of files attached to each item. Value is the count of files to return for each item. |
GET | files_ext | string, array | Include only files with this extension. Possible values: csv , gif , jpeg , pdf , png and webp . |
GET | group_ids | integer, array | Return only items from specific groups. |
GET | id | integer, array | Return only items with specific IDs. |
GET | info | boolean | Return the info of an item. |
GET | limit | integer | How many items to return. |
GET | name | boolean | Return the name of an item. |
GET | shop_groups | boolean, array | Trigger shop_groups to return all groups that are used by any of returned items. |
GET | shop_stores | boolean, array | Trigger shop_stores to return all stores that are used by stock info in any of returned items. |
GET | sort | array | Sort items. Possible values: id_desc , code_asc , price_asc , price_desc , score_desc and id_list (match order of requested IDs). |
GET | stock | boolean | Return the stock of an item. Only items with "arrives=0" in stock info can be purchased. |
GET | tags | array | Return items that match specified tags. You can also define tags that you do not want by adding tag name as a key with empty value. Possible values: active , new and preorder .Default: {active: 1} (only if no specific IDs requested) |
Variables
Name | Value | Info |
---|---|---|
size | array | Three integers representing packaging size in millimeters for X, Y and Z axes (width, height and depth for non-abstract, not rotatable geometrical objects) |
weight | integer | Gross weight (with packaging) in grams. |
Example
Request (PHP)
$c = curl_init(); curl_setopt_array($c, [ CURLOPT_URL => 'https://center.lv/API/shop_items/json?'.http_build_query([ 'lang' => ['en', 'lv', 'ru'], 'name' => TRUE, 'files' => 5, 'stock' => TRUE, 'shop_groups' => TRUE, 'shop_stores' => TRUE, ]), CURLOPT_HTTPHEADER => [ 'TOKEN: ...', ], ]); curl_exec($c); curl_close($c);
Response
{ "shop_items": [ { "id": 2321, "code": "WH-1000XM3/B", "brand": "Sony", "brand_code": "WH1000XM3B.CE7", "bar_code": "4548736081185", "tags": [], "size": [ 184, 77, 225 ], "weight": 813, "group_ids": [ 13 ], "prices": { "shop": "230.5785", "shop_old": "313.2231" }, "files": [ "https://cdn.center.lv/cms/core_files2/orig/6178.WH-1000XM3-B.jpeg", "https://cdn.center.lv/cms/core_files2/orig/6179.WH-1000XM3-B.jpeg", "https://cdn.center.lv/cms/core_files2/orig/6180.WH-1000XM3-B.jpeg", "https://cdn.center.lv/cms/core_files2/orig/6181.WH-1000XM3-B.jpeg", "https://cdn.center.lv/cms/core_files2/orig/6182.WH-1000XM3-B.jpeg" ], "name": { "en": "WH-1000XM3/B Wireless Noise Cancelling Headphones", "lv": "WH-1000XM3/B Trokšņu slāpējošās bezvadu austiņas", "ru": "WH-1000XM3/B Беспроводные наушники с шумоподавлением" }, "stock": [ { "store_id": 1, "count": 4, "arrives": 0 }, { "store_id": 6, "count": 2, "arrives": 0 } ] }, ... ], "shop_groups": [ { "id": 13, "code": "Austiņas", "parent_id": 41, "name": { "en": "Headphones", "lv": "Austiņas", "ru": "Наушники" } }, ... ], "shop_stores": [ { "id": 1, "name": { "en": "Sony Center, Brivibas street 40", "lv": "Sony Center veikals, Brīvības ielā 40", "ru": "Магазин Sony Center, по адресу Brīvības iela 40" } }, ... ] }
Troubleshooting
In a case of failure, the response can include the data from methods named alert
and/or
error
. The data will explain what happened, so it should be easy to figure out what went wrong.
It is possible to create a test environment. Please contact the staff if You need one.