Alkemics

Get a product in 5 mins

First, connect on Alkemics and go to your profile, create a new access keys.

❗️

Don't forget to copy your client secret before closing the modal, you won't be able to get it later

Now we will make an http query to get an access token.

import json
import requests

# Data for authentication, update it with your own credential
authentication_payload = {
    "client_id": "{your client id}",  # replace with your client id
    "client_secret": "{your client secret}",  # replace with your client secret
    "grant_type": "client_credentials",
}

# Call the authentication API
response = requests.post(
    "https://apis.alkemics.com/auth/v2/token",
    data=json.dumps(authentication_payload)
).json()

# Response contains:
# {"access_token": "{your access token}", "type": "JWT"}

access_token = response['access_token']

# We will use this access_token to access Alkemics APIS
headers = {
    'Authorization': 'Bearer %s' % access_token
}
curl 'https://apis.alkemics.com/auth/v1/token' -XPOST \
-d'{"client_id": "{your client id}", "client_secret": "{your client secret}", "grant_type": "client_credentials"}'

>>> {"access_token": "{your access token}", "type": "JWT"}

Now that we are authenticated, let's get your first product, take one of the gtin of your Alkemics catalog.

# Get product
filter_payload = {
    "filter_gtins_in": ["03036811359935"], # update with one of your gtin
    "filter_source_include": ["gtin", "nameLegal"], # retrieve only 2 fields
}

# Call the products API
response = requests.post(
  "https://apis.alkemics.com/public/v1/products/list",
  data=json.dumps(filter_payload),
  headers=headers # previously set with authentication token
)

# Response contains:
# {"data": [{"gtin": "03036811359935", "nameLegal":[{"expressedIn": {"code": "eng-GB"}, "data": "My first product"}]}]}

# Iterate on the product list
for product in response.json()['data']:
    # Retrieve the data in english
    nameLegal = next((n['data'] for n in product.get('nameLegal', []) if n['expressedIn']['code'] == 'eng-GB'), None)
    print '%r -> %r' % (product.get('gtin'), nameLegal)

# >> '03036811359935' -> 'My first product'
>> replace 03036811359935 with your own gtin :)
>> add your access token to the HTTP header 

curl 'https://apis.alkemics.com/public/v1/products/list' -XPOST -d'{"filter_gtins_in":["03036811359935"],"filter_source_include": ["gtin", "nameLegal"]}' \
-H 'Authorization: Bearer {your access token}'

>> {
  "totalResults": 1,
  "data": [
    {
      "nameLegal": [
        {
          "expressedIn": {
            "code": "eng-GB",
          },
          "data": "My first product"
        }
      ],
      "gtin": "03036811359935",
    }
  ],
  "offset": 0
}

👍

Congratulations !

Now you should learn about, how to understand product data and what filters / parameters you can use to get your data.

Updated about a month ago

Get a product in 5 mins


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.