sellytics Blog

First steps using the sellytics DATA API

Important: This article refers to sellytics DATA API. This API uses different grant_type(s) than the other sellytics APIs and you need special scopes and resource rights to use this api. If you’re interested to get such an API access or extend your existing API access just contact us.

 

Getting access using OAuth 2.0 and client_credentials

After receiving your sellytics OAuth2 client_id and client_secret you are able to start using the sellytics DATA API. Because the DATA API is a sub-product of sellytics where no user data is involved everything happens behalf of your own client and that’s why you have to use the client_credentials grant. We follow the OAuth2 specification and RFC6749 so the POST request to get your JWT Bearer access token should look like this one:

curl -X "POST" "https://auth.sellytics.com/uaa/oauth/token" \
     -H 'Content-Type: application/x-www-form-urlencoded; charset=utf-8' \
     -u 'client_id:client_secret' \
     --data-urlencode "grant_type=client_credentials"

If everything worked you should get a response with content-type “application/json” like this:

{
"access_token": "eyJhbGh56od8ahsuUJOIasfohuasdfa.eyJhdWQiOlsiYW1hem9uLWpvYnMiLCJhbWF6b24tc2VsbGVycyIsImFtYXpvbi1wcm9kdWN0cyIsImFtYXpvbi1vZmZlcmxpc3RpbmdzIiwiY2FsbGJhY2tzIiwiYW1hem9uLXRhc2tzIiwic2NoZWR1bGluZ3MiXSwic2NvcGUiOlsiYW1hem9uLXByb2R1Y3RzOnJlYWQiLCJhbWF6b24tcHJvZHVjdHMucmVzZWFyY2giLCJhbWF6b24tb2ZmZXJsaXN0aW5nczpyZWFkIl0sImV4cCI6MTU1NjMzMTgwNywianRpIjoiMGJhZGQ5NjQtNDliZC00ZTJjLTgzODYtMzQyYWMwZWQ1Yzk1IiwiY2xpZW50X2lkIjoic2VsbHl0aWNzLWludGVybmFsIn0.UF8mPfjBl5U97xpcuLDEPvIw4yzixE8f6sp3c5uAUcrfVSiuOQvnguLIpoqY2x6V1uIn_89234ß120ßdfgk4HbGkvlxfDAzO3sa9kydywAK05tdQFsAt6K8Jg-Mb44lAJbJMmVpNpslTmONCQM3GMktBWsTecLmbKElMZ6tyU-jvJc2D8mYYtYkUmuKsldqCE9nBdwN6dmkKp3rgt8Euu4tEs8ig6l_wWbsuGpeV-oinBU8hDJiTRwZENRC5xjbfkaIWdcT6T46D6aebN-hf9UUfwSI1W3KrQYQ23bj-tkplhNsQH0tnllt1EGGH-Z1uqTMdOtasdsgy_8BRAiihZbw",
"token_type": "bearer",
"expires_in": 35999,
"scope": "amazon-products:read amazon-products.research amazon-offerlistings:read",
"jti": "0badd964-4965-4e2c-8386-342ac0ed5c95"
}

 

Using your access token to request data and get access to REST API endpoints

Now you can use this access_token to get access to the sellytics DATA API endpoints. You can find most of them in our apidocs.
In every case, not only accessing sellytics DATA API you’ve to provide the access_token as Authorization http header.
An example how to retrieve an amazon product with it’s attributes from our database using Authorization header:

curl "https://api.sellytics.com/amazon/products/DE/B07CNFV32C/v1" \
     -H 'Authorization: Bearer YOUR-ACCESS-TOKEN-HERE' \
     -H 'Content-Type: application/json'

 

How to interpret a response

The response should be the requested product as json document and http status code 200 (OK).
If you get a 401 http status code (Unauthorized) something didn’t work and you should check wether your token is correct and valid.
Don’t forget to obtain a new access_token after your token has expired. You can find the expiration time in expires_in within the auth response you could see above.

 

Related Entries

Top