Sony Center REST API Documentation

v2.0
March 18th, 2021
Valts Katlaps

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

TypeNameValueInfo
GETlangstring, arraySelect 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

TypeNameValueInfo
GETnamebooleanReturn the name of a store.
GETopenbooleanReturn 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

TypeNameValueInfo
GETnamebooleanReturn 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

TypeNameValueInfo
GETboxbooleanReturn the box contents of an item.
GETfeaturesbooleanReturn the features of an item.
GETfilesintegerInclude list of files attached to each item.
Value is the count of files to return for each item.
GETfiles_extstring, arrayInclude only files with this extension.
Possible values: csv, gif, jpeg, pdf, png and webp.
GETgroup_idsinteger, arrayReturn only items from specific groups.
GETidinteger, arrayReturn only items with specific IDs.
GETinfobooleanReturn the info of an item.
GETlimitintegerHow many items to return.
GETnamebooleanReturn the name of an item.
GETshop_groupsboolean, arrayTrigger shop_groups to return all groups that are used by any of returned items.
GETshop_storesboolean, arrayTrigger shop_stores to return all stores that are used by stock info in any of returned items.
GETsortarraySort items.
Possible values: id_desc, code_asc, price_asc, price_desc, score_desc and id_list (match order of requested IDs).
GETstockbooleanReturn the stock of an item.
Only items with "arrives=0" in stock info can be purchased.
GETtagsarrayReturn 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, preorder and vat_r.
Default: {active: 1} (only if no specific IDs requested)

Variables

NameValueInfo
sizearrayThree integers representing packaging size in millimeters for X, Y and Z axes (width, height and depth for non-abstract, not rotatable geometrical objects)
weightintegerGross 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.