METRO Asset Center

Rest API Authentication

Getting Token

Use /login/client method for get token:

JSON
                POST hostname/login/client
                header:
                  Content-Type: application/json
                body:
                {"apiUser":"username", "apiPw": "userpassword"}
 

Using token

For using token add it to header

   + header "apijwt": "token"

Example of request presented below: 

JSON
                POST hostname/api/product
                header:
                  Content-Type: application/json
                  apijwt: <obtained token>
                body:
                {
                "query": {
                "country": "China",
                "asset type": "Product Offer Image"
                },
                "fields": "title, public url",
                "pagesize":1000,
                "startFrom": 0
                }

 

Description of query

Request

Request consists of the following attributes:

Header: should contains "Content-Type: application/json".

Body: The body to send along with this request. Body is passed to the serializer and converted to either JSON. Possible parts of body:

  • query - list of property which should be matched for searching needed information. Also for getting all information need remove query property from body of request;

    Possible query parameters
    Possible properties
    Possible property value
    Notes
    "angle"

    "Center"
    "Left"
    "No plunge angle"
    "Right"

     
    "article description"    
    "asset type"

    Parent value - "Image": "Product Illustration", "Campaign Image", "Item Group Image", "Discount Image", "Key Visual", "Ambient Image", "Restaurant Image", "Logo", "Graphic", "Infographic", "Energy Label"

    Parent value - "Document": "Campaign Document", "Guideline", "Instruction Manual", "Press Release", "Legal Document", "Brand Manual", "Q&A Document", "Presentation", Parent value - "Packaging Tool": "Design Manual", "Pictograms", "Backgrounds", "Label Illustration", "Master Layouts"

    Parent value - "Media": "Video Script", "Campaign Video", "Corporate Video", "Internal Communication", "Training Video", "Audio"

    Parent value - "Product Asset":"Category Image","Energy Efficiency Label", "Exploded View", "Food Information Regulation", "Miscellaneous Document", "Product Label Image", "Product Image", "Planogram Image", "Product Offer Image", "Product Notice", "Product Refund Offer", "Product Video", "Safety Data Sheet"

    •  During search by "asset type" you can search either by parent value or by any of child values. If you search by a "Parent value", you will find all records from all child values and got that in response.
    "brand"    
    "brand id"

    allowable values is [0..231-1]

     
    "channel" "Shop" new fields instead of 'user journey'
    "color mode"    
    "composition"

    "Closeup"
    "Facing camera"
    "Horizontal"
    "Landscape"
    "Portrait"
    "Profile"
    "Square"
    "Transparent"
    "Vertical"

     
    "content id"   Obsolete: can be searched using sequence of values separated by comma and space, e.g. "content id" : "122, 2.5, 56, 100, 3,5, 98"
     "country" "Head Office", "Austria","Belgium","Bulgaria", "China","Croatia","Czech Republic","France", "France","Germany","Hong Kong","Hungary", "India","Italy","Japan","Kazakhstan", "Moldova", "Netherlands","Pakistan", "Poland","Portugal", "Romania", "Russia", "Serbia", "Slovakia", "Spain", "Turkey", "Ukraine"

    Сan be used for getting country name - "Countries endpoint"(see below paragraph "Countries endpoint").

    "country code" "at","be","bg","cn","hr","cz","fr", "de","ho","hk","hu","in","it","jp","kz", "md","nl","pk","pl","pt","ro","ru","rs", "sk","es","tr","ua"
    • Сan be used for getting country code - "Countries endpoint" (see below paragraph "Countries endpoint").

    "description"    
    "discount type" "Absolute", "Percent", "Loyalty"  
    "discount value"   Obsolete: can be searched using sequence of values separated by comma and space, e.g. "discount value" : "122, 2.5, 56, 100, 3,5, 98"
    "energy class"

    "A+"
    "A++"
    "A+++"
    "B"
    "C"
    "D"
    "E"
    "F"
    "G"

     
    "facing"

    "Back"
    "Bottom"
    "Front "
    "Left"
    "Not applicable" 
    "Right"
    "Top"

     
    "file size"   "File size" attribute is exposed in AL with Master file value in MAC. As all web files in CDN have normalized.
    "food/nonfood"  "F" "N"  
    "gtin"    
    "height"    
    "last updated on"    
    "mgb article number"    
    "main merchandise group"    
    "merchandise group"    
    "model name"    
    "original gtin"    
    "own brand"    
    "pack type"    
    "primary color"

    "black"
    "blue"
    "brown"
    "green"
    "orange"
    "purple"
    "red"
    "white"
    "yellow"

     
    "recordid" unique identifier  
    "rights management (rm)" "Creative Commons", "Public Domain", "Rights Managed", "Royalty Free", "Undefined"  
    "resolution" allowable values is [0..9999] "Resolution" attribute is exposed in AL with Master file value in MAC. As while being published, Master files with resolution more than 72dpi are normalized to 72dpi (Master files with resolution smaller than 72dpi, are published without normalization: no-upscale).
    "restaurant type" African,American,Arabic,Argentinian, Asian, Beer,Brewery,British,Burger, Cafe,Chinese,Club, Cocktail,Delifood, Disco,Fastfood,Fish,French, Fusion, German,Greek,Healthy,Indian, International, Israeli,Italian,Japanese, Karaoke,Korean,Lebanese,Mediterranean, Mexican,Mongol,Moroccan,Persian, Pizza,Pub,Schnitzel,Seafood, Southamerican,Spanish,Sportsbar, Steakhouse,Sushi,Thai,Turkish, Vegan,Vegetarian,Vietnamese,Wine Obsolete: can be searched using sequence of values separated by comma and space, e.g. "restaurant type" : "African, Arabic, Fish"
    "restricted region" "Head Office", "Austria","Belgium","Bulgaria", "China","Croatia","Czech Republic","France", "France","Germany","Hong Kong","Hungary", "India","Italy","Japan","Kazakhstan", "Moldova", "Netherlands","Pakistan", "Poland","Portugal", "Romania", "Russia", "Serbia", "Slovakia", "Spain", "Turkey", "Ukraine"  
    "rm end date"    
    "rm start date"     
    "sales bundle content"    
    "sales bundle number" allowable values is [0..999]  
    "sales unit content"    
    "sequence number" allowable values is [0..99]  
    "state"

    "Case"
    "Family"
    "Held"
    "In packaging"
    "Innerpack"
    "Open Case"
    "Out of packaging"
    "Plated"
    "Prepared"
    "Raw/uncooked"
    "Staged"
    "Styled"
    "Used"
    "Worn"

     
    "subsystem article number"    
     "title"    
    "url"    
    "url type" "master", "web", "720p", "480p","360p"
    1. Default values (if you don't specify url type, by default in response is returned):

      • for images, url with types: "web"

      • for videos, url with types: "720p", "480p","360p"

    "usage restrictions    
    "variant description"    
     "variant number" allowable values is [0..999]  
    "voucher number"   Obsolete: can be searched using sequence of values separated by comma and space, e.g. "Voucher Number" : "122, 2.5, 56, 100, 3,5, 98"
    "webshop name"    
    "width"    
  • fields - list of of property which should be returned in response;

    • angle
    • article description
    • asset type
    • brand
    • brand id
    • channel
    • color mode
    • composition
    • content id
    • classifications
    • dimensions
    • discount type
    • discount value
    • energy class
    • facing
    • file size
    • food/nonfood
    • gtin
    • height
    • last updated on
    • mgb article number
    • main merchandise group
    • merchandise group
    • model name
    • original gtin
    • own brand
    • pack type
    • primary color
    • public url
      • url
      • code
      • country
      • type
    • recordid
    • resolution
    • restaurant type
    • restricted region
    • rights management (rm)
    • rm end date
    • rm start date
    • sales bundle content
    • sales bundle number
    • sales unit content
    • sequence number
    • state
    • subsystem article number
    • title
    • url type
    • usage restrictions
    • variant description
    • variant number
    • voucher number
    • webshop name
    • width
  • pagesize - count of records which can be returned in response;
  • startFrom - defines the offset from the first result you want to fetch. 

Notes:

  •  startFrom + pagesize can not be more than 10,000. See the Search After API for more efficient ways to do deep scrolling.
  •  max count of values, which use for searching by sequence of values separated by comma and space, is 1024.

Example of query presented below: 

 
JSON
                POST hostname/api/product
                header:
                  Content-Type: application/json
                  apijwt: token
                body:
                {
                "query": {
                "country": "Belgium",
                "title": "BE PIM 886654009009 09"
                },
                "fields": "title, public url",
                "pagesize":1000,
                "startFrom": 0
                }

Response

Response consists of the following attributes:

  • count - total count of record which found by query;

  • pagesize - count of records which can be returned in response;

  • startFrom - defines the offset from the first result you want to fetch;

  • tookTime - time in milliseconds for Elasticsearch to execute the search;

  • records - list of records which is found by search request.

Example of response presented below:

JSON
                HTTPS/1.1 200 OK
                Content-Type: application/json; charset=utf-8
                {
                    "count": 2,
                    "pagesize": 1000,
                    "startFrom": 0,
                    "tookTime": 7,
                    "records":[
                        {
                            "fields":{
                                "public url":[
                                    {
                                        "url": "http://cdn-pp.metro-group.com/be/be_pim_886654009009_09",
                                        "code": "be",
                                        "country": "Belgium",
                                        "type":"web"
                                    },
                                    {
                                        "url": "http://cdn-pp.metro-group.com/be/oo2/be_pim_886654009009_09",
                                        "code": "be",
                                        "country": "Belgium",
                                        "type":"web"
                                    }
                                ],
                                "title":"BE PIM 886654009009 09",
                                "publishing status":"published"
                            }
                        }
                    ]
                }

Notes:

  • Records are sorted by text field "recordid" in response by default in ascending order

  • Publishing Status can be "published" and "depublished". Status is "depublished" when record removed from CDN.

  • If response contains special symbols this symbols will be shown with /, for example "article description": "Pipe Wrench 10//" ". Special symbols: ", /.

  • Names of fields in response is returned in lowercase.

Searching

Search by text fields

We have two types of text fields.

  • The first type of text fields can be find only using exact value. Search by this fields is case sensitive. List of this fields is presented below:

  • The second part of text fields can be find using any word from value of field. Because values for this fields are converted from the string into a list of individual terms. List of this fields is presented below:

    • article description
    • brand
    • content id
    • description
    • discount value
    • gtin
    • model name
    • original gtin
    • pack type
    • primary color
    • restaurant type
    • restricted region
    • sales unit content
    • title
    • url
    • usage restrictions
    • variant description
    • voucher number
    • webshop name

Search by multiple values

For searching by multiple values is used next type of request:

JSON
                POST hostname/api/product
                header:
                  Content-Type: application/json
                  apijwt: token
                body:
                {
                "query": {
                 "country": ["Hungary", "Head Office"],
                 "discount value":["15", "34", "50"]
                },
                "fields": "title, public url",
                "pagesize":1000,
                "startFrom": 0
                }

In response we expect to get all records, which has at least one value from array of values for search from request.

Search for date

For search by date you should use "filter" with "range" query. Example of request presented below:

JSON
                POST hostname/api/product
                header:
                  Content-Type: application/json
                  apijwt: token
                body:
                {
                "query": {
                 "country": "Hungary",
                 "filter":[
                    {
                        "range" : {
                            "last updated on" : {
                                "gte": "25/01/2017 18:40:32"
                            }
                        }
                    }
                 ]
                },
                "fields": "title, public url",
                "pagesize":1000,
                "startFrom": 0
                }

The "range" query accepts the following parameters:

gteGreater-than or equal to
gtGreater-than
lteLess-than or equal to
ltLess-than

Notes:

  • By default for fields "last updated on" is used format "dd/MM/yyyy HH:mm:ss" and for fields "rm start date" and "rm end date" are used format "dd/MM/yyyy". If you would like to search using non default format then you should include in query custom date format from table which presented below:

Possible formats

Possible formats
MM/dd/yyyy hh:mm:ss a
dd/MM/yyyy hh:mm:ss a
MM/dd/yyyy HH:mm:ss
dd/MM/yyyy HH:mm:ss
MM/dd/yyyy HH:mm
dd/MM/yyyy HH:mm
MM/dd/yyyy HH
dd/MM/yyyy HH
dd/MM/yyyy
MM/dd/yyyy
yyyy/MM/dd
SymbolMeaningPresentationExamples
yyearyear1996
Dday of yearnumber189
Mmonth of yearmonth07
dday of monthnumber10
ahalfday of daytextPM
hclockhour of halfday (1~12)number12
Hhour of day (0~23)number0
mminute of hournumber30
ssecond of minutenumber55
Sfraction of second millis978

Example of request presented below:

  1. search using format "MM/dd/yyyy HH:mm:ss" :

    JSON
                    POST hostname/api/product
                    header:
                      Content-Type: application/json
                      apijwt: token
                    body:
                    {
                    "query": {
                     "country": "Hungary",
                     "filter":[
                        {
                            "range" : {
                                "last updated on" : {
                                    "gte": "01/25/2017 18:40:32",
                                    "format": "MM/dd/yyyy HH:mm:ss"
                                }
                            }
                        }
                     ]
                    },
                    "fields": "title, public url",
                    "pagesize":1000,
                    "startFrom": 0
                    }
  2. search using format "dd/MM/yyyy" or "dd/MM/yyyy HH:mm:ss" :

    JSON
                    POST hostname/api/product
                    header:
                      Content-Type: application/json
                      apijwt: token
                    body:
                    {
                    "query": {
                     "country": "Hungary",
                     "filter":[
                        {
                            "range" : {
                                "last updated on" : {
                                    "gte": "25/01/2015",
                                    "lte": "16/02/2017 18:40:32",
                                    "format": "dd/MM/yyyy||dd/MM/yyyy HH:mm:ss"
                                }
                            }
                        }
                     ]
                    },
                    "fields": "title, public url",
                    "pagesize":1000,
                    "startFrom": 0
                    }

Search for date using "Date Math" format

When running range queries on fields of type date, ranges can be specified using "Date Math".

Most parameters which accept a formatted date value — such as gt and lt in range queries understand date maths.

The expression starts with an anchor date, which can either be now, or a date string ending with ||(e.с. 2015-01-01||). This anchor date can optionally be followed by one or more maths expressions:

  • +1h - add one hour

  • -1d - subtract one day

  • /d - round down to the nearest day

The supported time units are:

Value
Description
yyears
Mmonths
wweeks
ddays
hhours
Hhours
mminutes
sseconds

Some examples are presented below:

value
description
now+1hThe current time plus one hour, with ms resolution.
now+1h+1mThe current time plus one hour plus one minute, with ms resolution.
now+1h/dThe current time plus one hour, rounded down to the nearest day.
2015-01-01||+1M/d2015-01-01 plus one month, rounded down to the nearest day.

Example of query are presented below:

JSON
                POST hostname/api/product
                header:
                  Content-Type: application/json
                  apijwt: token
                body:
                {
                "query": {
                 "country": "Hungary",
                 "filter":[
                     {
                       "range" : {
                         "last updated on" : {
                             "gte" : "now-1d/d",
                             "lt" :  "now/d"
                         }            
                       }            
                     }
                   ]
                },
                "fields": "title, public url",
                "pagesize":1000,
                "startFrom": 0
                }

Date math and rounding

When using data math to round dates to the nearest day, month, hour, etc, the rounded dates depend on whether the ends of the ranges are inclusive or exclusive.

Rounding up moves to the last millisecond of the rounding scope, and rounding down to the first millisecond of the rounding scope. For example:

gtGreater than the date rounded up: 2014-11-18||/M becomes 2014-11-30T23:59:59.999, ie excluding the entire month.
gteGreater than or equal to the date rounded down: 2014-11-18||/M becomes 2014-11-01, ie including the entire month.
ltLess than the date rounded down: 2014-11-18||/M becomes 2014-11-01, ie excluding the entire month.
lteLess than or equal to the date rounded up: 2014-11-18||/M becomes 2014-11-30T23:59:59.999, ie including the entire month.

Search using range for numeric values

For searching numeric values is used a range query, which, unsurprisingly, can be used to find records falling inside a range. For example:

JSON
                POST hostname/api/product
                header:
                  Content-Type: application/json
                  apijwt: token
                body:
                {
                "query": {
                 "country": "Hungary",
                 "filter":[
                    {
                        "range" : {
                            "sequence number" : {
                             "gte" : 20,
                             "lt" : 40
                            }
                        }
                    }
                  ]
                },
                "fields": "title, public url, sequence number",
                "pagesize":100,
                "startFrom": 0
                }

The range query supports both inclusive and exclusive ranges, through combinations of the following options:

  • gt: > greater than

  • lt: < less than

  • gte: >= greater than or equal to

  • lte: <= less than or equal to

Below is presented list of fields with numeric values:

  • brand id

  • height

  • sales bundle number

  • sequence number

  • variant number

  • width

  • file size

  • resolution

Search using wildcard

For search using wildcard you should use "filter" with "wildcard" query. Supported wildcards are *, which matches any character sequence (including the empty one), and ?, which matches any single character. Note that this query can be slow, as it needs to iterate over many terms. In order to prevent extremely slow wildcard queries, a wildcard term should not start with one of the wildcards * or ?. We have two types of text fields, please, read the next notes before start using wildcard.

Notes:

  • For first type of text fields (for additional information go to section Search by text fields), search using wildcard is worked as case sensitive search by exact value.
  • For search by second types of text fields (for additional information go to section Search by text fields) using wildcard, we must use only lower case.

Example of query presented below:

JSON
                POST hostname/api/product
                header:
                  Content-Type: application/json
                  apijwt: token
                body:
                {
                "query": {
                 "country": "Hungary",
                 "filter":[
                    {
                        "range" : {
                            "last updated on" : {
                                "gte": "01/25/2017 6:40:32 PM",
                                "format": "MM/dd/yyyy hh:mm:ss a"
                            }
                        }
                    },
                    {"wildcard" : { "mgb article number" : "365*" }}
                  ]
                },
                "fields": "mgb article number, public url",
                "pagesize":1000,
                "startFrom": 0
                }

Search for High-res images

For searching a link to High-res images is used the additional parameter in the request "url type":"master". If "url type" isn't clarify in the request then in the response is returned by default only records with type "web". When High-res images is published to cdn, a file name of this images is changed to a unique id. Access to this files is restricted. If you would like to have access to this images you must send a request to the support team in order for you to access. Below are presented examples of requests for searching by "url type":

Request (search by "url type":"master")
                POST hostname/api/product
                headers:
                  Content-Type:     application/json
                  apijwt:    token
                body:
                {
                    "query": {
                        "asset type": "Product Image",
                        "url type":"master"
                    },
                    "fields": "title, mgb article number, variant number, public url",
                    "pagesize":10
                }
Response (search by "url type":"master")
                HTTPS/1.1 200 OK
                Content-Type: application/json; charset=utf-8
                {
                    "fields":{
                        "public url":[{
                            "country": "Germany",
                            "code": "de",
                            "type": "master",
                            "url": "https://s3-eu-west-1.amazonaws.com/mac-prod-high-res/a8c2585c-5ef7-45ab-998c-a81000a08ce3.jpg"
                        }],
                        "variant number": "1",
                        "title": "DE POG 45645001001 30",
                        "mgb article number": "45645",
                        "publishing status": "published"
                    },
                    "sort":[
                        "a8c2585c-5ef7-45ab-998c-a81000a08ce3"
                    ]
                  }
Request (search by "url type":"web")
                POST hostname/api/product
                headers:
                  Content-Type:     application/json
                  apijwt:    token
                body:
                {
                    "query": {
                        "asset type": "Product Image",
                        "url type":"web"
                    },
                    "fields": "title, mgb article number, variant number, public url",
                    "pagesize":10
                }
                
Response (search by "url type":"web")
                HTTPS/1.1 200 OK
                Content-Type: application/json; charset=utf-8
                {
                    "fields":{
                        "public url":[{
                            "country": "Head Office",
                            "code": "ho",
                            "type": "web",
                            "url": "http://cdn.metro-group.com/ho/valmarone 0,75 bianco frizzante.png"
                        }],
                        "title": "0,75l Bianco Frizzante",
                        "publishing status": "published"
                    },
                    "sort":[
                        "b2169d04-5941-4685-b450-a80200e164d2"
                    ]
                }
                

Search including related records

We can include into response "related assets", which connected with current record. For example, it can be brand images or icon images. For doing this, we need to add header "include" with value "related" to request. Example of this request presented below:

Request (search include related records)
                POST hostname/api/product
                headers:
                  Content-Type:     application/json
                  apijwt:    token
                  Include:          related  //header for search including related records
                body:
                {
                    "query": {
                        "asset type": "Product Image"
                    },
                    "fields": "title, mgb article number, variant number, public url, related assets",
                    "pagesize":10
                }
                

Example of response:

Response (search include related records)
                HTTPS/1.1 200 OK
                Content-Type: application/json; charset=utf-8
                {
                    "fields":{
                        "public url":[{
                            "country": "Czech Republic",
                            "code": "cz",
                            "type": "web",
                            "url": "http://cdn.metro-group.com/cz/cz_pim_0058005005_03.png"
                        }],
                        "title": "cz pim 0058005005 03",
                        "mgb article number":"0058",
                        "varian number":"5",
                        "asset type": [
                             "Product Asset",
                             "Product Image"
                        ],
                        "related assets":["005e762e-33ce-4cc3-bac5-f00bf5a17f63"], //list of related record ids
                        "publishing status": "published"       
                    },
                    "sort": [
                        "00008ee7-9535-47dc-8263-a7d201031fa8"
                    ],
                    "include":[
                                {
                                    "fields": {
                                        "asset type": [
                                            "Product Related Asset",
                                            "Brand Image"
                                        ],
                                        "public url": [
                                            {
                                                "country": "Czech Republic",
                                                "code": "cz",
                                                "type": "web",
                                                "url": "https://cdn-pp.metro-group.com/cz/cz_bim_6878_01.png"
                                            }
                                        ],
                                        "brand id":"6878",
                                        "publishing status": "published"
                                    },
                                    "recordid": "005e762e-33ce-4cc3-bac5-f00bf5a17f63",
                                    "sort": [
                                        "005e762e-33ce-4cc3-bac5-f00bf5a17f63"
                                    ]
                                }
                    ]
                }
                

Notes:

  • "asset type" (for product assets and related assets) is a mandatory attribute for records in response;
  • related assets has the following list of mandatory attributes in response: "asset type", "brand id", "public url", "recordid", "publishing status";
  • parent record has the field "related assets":[...] with the list of "recordid", which would be added into "include" section of response.

Sorting

For sorting we can use the "sort" parameter. Allows to add one or more sort on specific fields.

Sort Values

The sort values for each document returned are also returned as part of the response. For example:

Request with sorting
                POST hostname/api/product
                headers:
                  Content-Type:     application/json
                  apijwt:    token
                body:
                {
                    "query": {
                        "asset type": "Product Image"
                    },
                    "sort":["last updated on","mgb article number"],
                    "fields": "title, last updated on, mgb article number, variant number, public url",
                    "pagesize":10
                }
                
Response with sorting
                HTTPS/1.1 200 OK
                Content-Type: application/json; charset=utf-8
                {
                    "fields":{
                        "public url":[
                            {
                                "country": "Belgium",
                                "code": "be",
                                "url": "http://cdn-pp.metro-group.com/be/be_pim_120009001001_09",
                                "type":"web"
                            },
                            {
                                "country": "Belgium",
                                "code": "be",
                                "url": "http://cdn-pp.metro-group.com/be/oo2/be_pim_120009001001_09",
                                "type":"web"
                            }
                        ],
                        "variant number": "001",
                        "title": "BE PIM 120009001001 09",
                        "mgb article number": "120009",
                        "publishing status": "published"
                    },
                    "sort":[ 1491476380000, "120009"]
                }
                

A field with one unique value per document should be used as the tiebreaker of the sort specification. Otherwise the sort order for documents that have the same sort values would be undefined. The recommended way is to use the field "recordid" which is certain to contain one unique value for each document. Example of request with recordid is presented below:

Sort by "recordid"
                POST hostname/api/product
                headers:
                  Content-Type:     application/json
                  apijwt:    token
                body:
                {
                    "query": {
                        "asset type": "Product Image"
                    },
                    "sort":["recordid"],
                    "fields": "title, last updated on, mgb article number, variant number, public url",
                    "pagesize":10
                }
                

Notes:

  • By default records are sorted by text field "recordid" in response.
  • The value of the date field, expressed as milliseconds since the epoch, is returned in the "sort" values.
  • We have two types of text fields and sorting by second part of fields isn't possible (for getting information about text fields go to section Search by text fields).

Sort Order

The order option can have the following values:

option
description
ascSort in ascending order
descSort in descending order

The order defaults to "asc". Example of request with "sort order" parameter is presented below:

Request with "sort order"
                POST hostname/api/product
                headers:
                  Content-Type:     application/json
                  apijwt:    token
                body:
                {
                    "query": {
                        "asset type": "Product Image"
                    },
                    "sort":[{"last updated on":"asc"},{"mgb article number":"asc"}],
                    "fields": "last updated on, mgb article number, variant number, public url",
                    "pagesize":10
                } 
                

List of fields for sorting

List of fields which can use for sorting are presented below:

  • angle
  • brand id
  • color mode
  • composition
  • country
  • country code
  • discount type
  • energy class
  • enrichment status
  • facing
  • food/nonfood
  • main merchandise group
  • merchandise group
  • mgb article number
  • own brand
  • recordid
  • rm end date
  • rm start date
  • rights management (rm)
  • sales bundle content
  • sales bundle number
  • state
  • subsystem article number
  • variant number
  • width

Search After

Pagination of results can be done by using the "startFrom" and "pagesize" but the cost becomes prohibitive when the deep pagination is reached (more then 10000 records). The "search_after" parameter circumvents this problem by providing a live cursor. The idea is to use the results from the previous page to help the retrieval of the next page.

The result from the below request includes an array of "sort values" for each document. These "sort values" can be used in conjunction with the "search_after" parameter to start returning results "after" any document in the result list.

You need to use the "sort" value from response of the last document and pass it to "search_after" to retrieve the next page of results. Example is presented below:

First request with sorting
                POST hostname/api/product
                headers:
                  Content-Type:     application/json
                  apijwt:    token
                body:
                {
                    "query": {
                        "asset type": "Product Image"
                    },
                    "fields": "mgb article number, variant number",
                    "pagesize":10,
                    "sort":["last updated on","mgb article number"]
                 }
                
First response with sorting
                HTTPS/1.1 200 OK
                Content-Type: application/json; charset=utf-8
                {
                    "count": 2,
                    "pagesize": 10,
                    "startFrom": 0,
                    "tookTime": 1
                    "records:[
                        {
                            "fields":{
                                "variant number": "001",
                                "mgb article number": "120009",
                                "publishing status": "published"
                            },
                            "sort":[ 1491476380000, "120999"]
                        },
                        {
                            "fields":{
                                "variant number": "001",
                                "mgb article number": "120009",
                                "publishing status": "published"
                            },
                            "sort":[ 1491476400000, "120789"]
                        }
                    ]
                }
                
Second request with sorting and search_after
                POST hostname/api/product
                headers:
                  Content-Type:     application/json
                  apijwt:    token
                body:
                {
                    "query": {
                        "asset type": "Product Image"
                    },
                    "fields": "mgb article number, variant number",
                    "pagesize":10,
                    "sort":["last updated on","mgb article number"],
                    "search_after": [ 1491476380000, "120999"] //this value we need to get from section "sort" from first response
                 }
                
Second response with sorting and search_after
                HTTPS/1.1 200 OK
                Content-Type: application/json; charset=utf-8
                {
                    "count": 2,
                    "pagesize": 10,
                    "startFrom": 0,
                    "tookTime": 1
                    "records:[
                        {
                            "fields":{
                                "variant number": "001",
                                "mgb article number": "120009",
                                "publishing status": "published"
                            },
                            "sort":[ 1491476400000, "120789"]
                        }
                    ]
                }
                

Notes:

  • The parameter "startFrom" must be set to 0 when "search_after" is used.

Countries endpoint

Get all countries list

Get country list request
                GET hostname/api/countries
                headers:
                  Content-Type:     application/json
                  apijwt:    token
                
Get country list response
                [
                  {
                    "name": "Austria",
                    "code": "at"
                  },
                  {
                    "name": "Belgium",
                    "code": "be"
                  },
                  {
                    "name": "Bulgaria",
                    "code": "bg"
                  },
                  {
                    "name": "China",
                    "code": "cn"
                  },
                  {
                    "name": "Croatia",
                    "code": "hr"
                  },
                  {
                    "name": "Czech Republic",
                    "code": "cz"
                  },
                  {
                    "name": "France",
                    "code": "fr"
                  },
                  {
                    "name": "Germany",
                    "code": "de"
                  },
                  {
                    "name": "Head Office",
                    "code": "ho"
                  },
                  {
                    "name": "Hong Kong",
                    "code": "hk"
                  },
                  {
                    "name": "Hungary",
                    "code": "hu"
                  },
                  {
                    "name": "India",
                    "code": "in"
                  },
                  {
                    "name": "Italy",
                    "code": "it"
                  },
                  {
                    "name": "Japan",
                    "code": "jp"
                  },
                  {
                    "name": "Kazakhstan",
                    "code": "kz"
                  },
                  {
                    "name": "Moldova",
                    "code": "md"
                  },
                  {
                    "name": "Netherlands",
                    "code": "nl"
                  },
                  {
                    "name": "Pakistan",
                    "code": "pk"
                  },
                  {
                    "name": "Poland",
                    "code": "pl"
                  },
                  {
                    "name": "Portugal",
                    "code": "pt"
                  },
                  {
                    "name": "Romania",
                    "code": "ro"
                  },
                  {
                    "name": "Russian Federation",
                    "code": "ru"
                  },
                  {
                    "name": "Serbia",
                    "code": "rs"
                  },
                  {
                    "name": "Slovakia",
                    "code": "sk"
                  },
                  {
                    "name": "Spain",
                    "code": "es"
                  },
                  {
                    "name": "Turkey",
                    "code": "tr"
                  },
                  {
                    "name": "Ukraine",
                    "code": "ua"
                  }
                ]
                

Get country by country name

Find country by name request
                GET hostname/api/countries/country/{country name}
                Example: https://api.mac.metro-group.com/api/countries/country/Austria
                headers:
                  Content-Type:     application/json
                  apijwt:    token
                
Find country by name response
                {
                  "name": "Austria",
                  "code": "at"
                }
                

Get country by country code

Find country by code request
                GET hostname/api/countries/code/{country code}
                Example: https://api.mac.metro-group.com/api/countries/code/be
                headers:
                  Content-Type:     application/json
                  apijwt:    token
                
Find country by code response
                {
                  "name": "Belgium",
                  "code": "be"
                }
                

Examples

Example query:

  1. Classified directly in "Country/Hungary" and asset title is "HU 1234567001001 01"

  2. JSON
                    POST hostname/api/product
                    header:
                      Content-Type: application/json
                      apijwt: token
                    body:
                    {
                    "query": {
                     "country": "Hungary",
                     "title": "HU 1234567001001 01"
                    },
                    "fields": "title, public url",
                    "pagesize":1000,
                    "startFrom": 0
                    }
                    
  3. Classified directly in "Country/Hungary" and MGB Article Number = "1234567"

  4. JSON
                    POST hostname/api/product
                    header:
                      Content-Type: application/json
                      apijwt: token
                    body:
                    {
                    "query": {
                     "country": "Hungary",
                     "mgb article number": "1234567"
                    },
                    "fields": "title, public url",
                    "pagesize":1000,
                    "startFrom": 0
                    }
                    
  5. Classified directly in "Country/Hungary" and MGB Article Number = "1234567" and Variant Number = "1213" and Sales Bundle Number = "5654"

  6. JSON
                    POST hostname/api/product
                    header:
                      Content-Type: application/json
                      apijwt: token
                    body:
                    {
                    "query": {
                     "country": "Hungary",
                     "mgb article number": "1234567",
                     "variant number":"1213",
                     "sales bundle number":"5456"
                    },
                    "fields": "title, public url",
                    "pagesize":1000,
                    "startFrom": 0
                    }
                    
  7. Classified directly in "Country/Hungary" and "AssetType/Image/Product Image"

  8. JSON
                    POST hostname/api/product
                    header:
                      Content-Type: application/json
                      apijwt: token
                    body:
                    {
                    "query": {
                     "country": "Hungary",
                     "asset type": "Product Image"
                    },
                    "fields": "title, public url",
                    "pagesize":1000,
                    "startFrom": 0
                    }
                    
  9. Classified directly in "Country/China" and "AssetType/Image/Product Offer Image" and MGB article aumber = "1234567"

  10. JSON
                    POST hostname/api/product
                    header:
                      Content-Type: application/json
                      apijwt: token
                    body:
                    {
                    "query": {
                     "country": "China",
                     "asset type": "Product Offer Image",
                     "mgb article number": "1234567"
                    },
                    "fields": "title, public url",
                    "pagesize":1000,
                    "startFrom": 0
                    }
                    
  11. Classified directly in "Country/China" and "AssetType/Image/Product Offer Image"

  12. JSON
                    POST hostname/api/product
                    header:
                      Content-Type: application/json
                      apijwt: token
                    body:
                    {
                    "query": {
                     "country": "China",
                     "asset type": "Product Offer Image"
                    },
                    "fields": "title, public url",
                    "pagesize":1000,
                    "startFrom": 0
                    }