Sony Center REST API Documentation

v2.0.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 must 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 (/).

Possible response formats include json, func.jsonp, print (human readable JSON), xml, csv and php (serialized), but at this time we would encourage You to choose between first two where possible.

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 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.

Authentication

To authenticate any request, include Your authentication token as a variable named TOKEN into the HEADER part of Your request.

Methods

This is not a full list of available methods. We plan to make more methods public asap.

Global settings

TypeNameValueInfo
GETlangstring, arraySelect one or multiple languages to receive data in.
Possible values: en, lv, ru.
Default value: lv.

shop_stores

Method returns info about stores. This information will help to determine where the items are located at the moment.

Settings

TypeNameValueInfo
GETnamebooleanReturn the name of a store.

Example

Request (PHP)

$c = curl_init('https://center.lv/API/shop_stores/print?'.http_build_query([
    'lang' => ['en', 'lv', 'ru'],
    'name' => TRUE,
]));
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('https://center.lv/API/shop_groups/print?'.http_build_query([
    'lang' => ['en', 'lv', 'ru'],
    'name' => TRUE,
]));
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.
GETfiles_extstring, arrayInclude only files with this extension.
Possible values: csv, gif, jpeg, pdf, png, webp.
GETgroup_idsinteger, arrayReturn only items from specific groups.
GETidinteger, arrayReturn only items with specific IDs.
GETinfobooleanReturn the info of an item.
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, id.
GETtagsarrayReturn items with these tags.
Possible values: new, vat_r.

Example

Request (PHP)

$c = curl_init('https://center.lv/API/shop_items/print?'.http_build_query([
    'lang' => ['en', 'lv', 'ru'],
    'name' => TRUE,
    'files' => 5,
    'stock' => TRUE,
    'shop_groups' => TRUE,
    'shop_stores' => TRUE,
]));
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": null,
            "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.