With PriceSpy Insights API you can access the following data for products and shops:
- Price
- Stock status
- Popularity
You can access data from all PriceSpy categories associated with your PriceSpy account.
How it works
In order to use the PriceSpy Insights API, you must:
- Have a PriceSpy account
- Purchase at least one category from <[email protected]>. See insights.prisjakt.nu. At purchase you get an API Client ID that you need to make API calls.
- Read and agree to the Terms of License.
Access the API directly and build your own insights app
The base address of the API is:
https://api.schibsted.com/prisjakt/insights
Requests
The PriceSpy Insights API is based on REST principles. Data resources are accessed via standard HTTPS requests in UTF-8 format to an API endpoint.
The following HTTP verbs are available:
- GET - Retrieve resources
- POST - Login or create resources
Rate Limiting
Rate limiting is applied as per application based on the Client ID. The returned HTTP headers of any API request show your current rate limit status:
X-RateLimit-Limit
- The maximum number of requests you're permitted to make per hour.X-RateLimit-Remaining
- The number of requests remaining in the current rate limit window.X-RateLimit-Reset
- The time in milliseconds when the current rate limit window resets.
HTTP status code 429
is used to indicate that the current rate limit has been exceeded.
Status: 429 Too Many Requests
X-RateLimit-Limit: 10000
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 600000
Responses
The PriceSpy Insights API returns all response data as a JSON object.
200 OK
- The request has succeeded. The client can read the result of the request in the body400 Bad request
- The request could not be understood by the server. See message body for more detailed information401 Unauthorized
- The request requires user credentials or the credentials have been refused by the server403 Forbidden
- The server understood the request, but refused to fulfill it404 Not Found
- The requested resource could not be found- 429 Too Many Requests - Rate limiting has been applied
500 Internal Server Error
- If you get one of those please contact our support
The PriceSpy Insights API uses one format to describe an error. The error object follows RFC7807.
$ curl -X GET https://api.schibsted.com/prisjakt/insights/user
{
"title": "Not authenticated",
"status": 401,
"detail": "Not authenticated"
}
Authorization
All requests to the API require authorization. To prove that the user has granted permission, the request header sent by the application must include a valid access token. As the first step towards authorization, you will need to register your application. This will give you a unique client ID to use in all requests.
In order to authorize, invoke the /auth
endpoint with username and password.
$ curl -X POST \ -H "x-client-id: clientId" \ -H "accept: application/json" \ -H "Content-Type: application/x-www-form-urlencoded" \ -d "username=user&password=password&grant_type=password" \ https://api.schibsted.com/prisjakt/analytics/auth
The response will contain an access token which allows you to make requests to the API on behalf of a user.
{ "access_token":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c", "expires_in":3600, "token_type":"Bearer" }
The authorization header (Authorization
) must contain the access token, and the client ID header (X-Client-Id
) must contain the client ID.
$ curl -X GET \ -H "x-client-id: clientId" \ -H "Authorization: Bearer eyJhbG..." \ https://api.schibsted.com/prisjakt/insights/user
User
The /user
endpoint will give you information about your user and which permissions and subscriptions you have.
$ curl -X GET \ -H "x-client-id: clientId" \ -H "Authorization: Bearer eyJhbG..." \ https://api.schibsted.com/prisjakt/insights/user
{ 'id': 'ca775c20-e3fe-4397-8de4-4dfa65ff5abd', 'email': '[email protected]', 'permissions': [ 'users_subscriptions:read' ], 'subscriptions': { 'offers_report': [ { 'category_ids': [ 1, 2 ], 'market': 'SE' } ] } }
Offers
The offers endpoint gives you the current offers for the products in a category. You can only fetch information for the categories included in your subscription.
$ curl -X GET \ -H "x-client-id: clientId" \ -H "Authorization: Bearer eyJhbG..." \ https://api-stage.schibsted.com/prisjakt/insights/offers?market=se&category_id=103
{ "offers": [ { "category": { "id": 103, "name": "Mobiltelefoner" }, "currency": "SEK", "name": "Apple iPhone 11 64 GB - svart", "price": 9195, "product": { "brand_name": "Apple", "id": 5172022, "name": "Apple iPhone 11 64GB", "rank_global": 1, "rank_in_category": 1 }, "shop": { "id": 259, "name": "Apple Store" }, "stock_status": "in_stock", "updated": "2020-08-18T10:05:44Z" } ] }
To get the response in text/csv
, set the Accept
header in the request.
$ curl -X GET \ -H "x-client-id: clientId" \ -H "Authorization: Bearer eyJhbG..." \ -H "Accept: text/csv" \ https://api-stage.schibsted.com/prisjakt/insights/offers?market=se&category_id=103
product_id,category_id,category_name,offer_name,product_rank_in_category,product_rank_global,product_name,shop_id,shop_name,brand_name,price,currency,stock_status,updated 5172022,103,Mobiltelefoner,Apple iPhone 11 64 GB - svart,1,1,Apple iPhone 11 64GB,259,Apple Store,Apple,9195.0,SEK,in_stock,2020-08-18T10:05:44Z
Pagination
The response could be paginated. In order to fetch the next page, use the page
query parameter. The next page reference can be found in the Link
header from the response. If there is no Link
header that means there are no more pages to fetch.
HTTP/1.1 200 OK Content-Type: text/csv; charset=utf-8 Link: <https://api.schibsted.com/prisjakt/insights/offers?market=se&category_id=103&page=2>; rel="next" ...
MuleSoft Mocking Service
If you want to get a feel for the API you can use the built-in mocking service in MuleSoft. It provides fixed data responses to each endpoint and doesn't require Prisjakt user credentials.
- Authenticate against Mulesoft's mocking service with your Mulesoft user credentials. Please note that you should not use your Prisjakt user credentials here, but your MuleSoft login.
- Copy the returned access token for use in subsequent calls. Use the header
MS2-Authorization
header to carry the token in your requests. The base URL for the mocking service ishttps://anypoint.mulesoft.com/mocking/api/v1/sources/exchange/assets/73a598fc-e854-4cb7-bea6-a4c899c8cb73/prisjakt-insights-api/0.0.4/m
. Example call to the/user
endpoint: