Prisjakt Insights API icon

Prisjakt Insights API

(0 reviews)

home

Welcome to the Prisjakt Insights API! To create market analyses, retrieve data, and automate your price comparisons, use the Prisjakt Insights API.

API guide

This guide will help you get set up to use our APIs. The base address of the Prisjakt Insights API is https://api.schibsted.com/prisjakt/insights-v2.

Prisjakt Insights GraphQL API reference: https://api.schibsted.com/prisjakt/insights-v2/docs/

Authentication

All requests to the API require authentication. To prove that the user has been granted permission, the request header sent by the application must include a valid access token along with your client ID. As the first step towards authentication, you will need to register your application. This will give you a unique client ID and client secret.

To authenticate set the grant type (grant_type) to client_credentials, and set your client ID (client_id) and client secret (client_secret).

curl --request POST \
  --header 'content-type: application/x-www-form-urlencoded' \
  --header 'client-id: <client-id>' \
  --data grant_type=client_credentials \
  --data client_id=<client-id> \
  --data client_secret=<client-secret> \
   https://api.schibsted.com/prisjakt/insights-v2/auth
{
    "access_token": "eyJhbGciOiJSUzUxMiIsInR5cCI6IkpXVCIsImtpZCI6ImM1U09QVmQyS0h6VW9mVFg2L3d6ekJYWkVqaz0ifQ.eyJpc3MiOiJodHRwczovL2FwaS1zdGFnZS5zY2hpYnN0ZWQuY29tL3ByaXNqYWt0L2F1dGgiLCJzY29wZSI6InJvbGU6c2VydmljZSIsInN1YiI6IjhkYjFjMzA4MzUzYjQ0ZTY5MTE1ODFjZDZmMGRiM2JkIiwiaWF0IjoxNjIzMDQ1ODE2LCJleHAiOjE2MjMwNDY0MTZ9.RQWSrWE0uIeiKdW11Hho0yLJBM6LVJSXxIJCvy8-CNmJ4xoncAcaizqKIpN-mIL1AYQXFFDLrB_y0iZOoHBKnwjUVRt14OUhUjVuV57ntIFMAy5Xljiv5KGWkP5w0ZDuTcs72AEGd4q1BXwrEKyoT-q_F1GYkUB28E1f0LegOLH84p0VeaJ-CHbduHWXoC4J_j1yi7G1dDJu7U2rWNG7mT876b7n5S6QuV2pC3XJqzMoX2o10Kt3Zbpl9Pk1CDxDDjApntfnjeQjmwAcJAZ0MFxQWL8UHjFnzde0EI0RQWzGDFaMqC6lurEw6tuYDiJvPdSrjMcktSuF3p3g-Vs8eg",
    "expires_in": 600,
    "token_type": "Bearer"
}

Authentication Error Response

The auth API uses a single format to describe errors. The error object is RFC7807 compliant.

Here is an example request to illustrate an error response.

curl --request POST \
    --header 'content-type: application/x-www-form-urlencoded' \
    --header 'client-id: clientId' \
    --data grant_type=invalid_grant_type \
  https://api.schibsted.com/prisjakt/insights-v2/auth
{
    "title": "Unsupported grant type",
    "status": 400,
    "detail": "Unsupported grant type: invalid_grant_type"
}

Graphql API

The Insights API is a GraphQL API served over HTTPS. For more information about GraphQL visit https://graphql.org.

The Prisjakt Insights GraphQL API reference can be found here: https://api.schibsted.com/prisjakt/insights-v2/docs/

Requests

When making GraphQL queries you can use HTTP POST or GET methods. A standard POST request should use the application/json content type, and include a JSON-encoded body of the following form:

{
  "query": "...",
  "variables": { "myVariable": "someValue", ... }
}

Responses

GraphQL status codes differ from REST API status codes. A GraphQL API can return a 200 response code in cases where a REST API would return 4xx or 5xx. The response body will in that case contain some errors (see errors for more details). See the below example for the basic structure of the response.

{
  "data": { ... },
  "errors": [ ... ]
}

Errors

If there are no errors returned, the errors field will not be present in the response. The errors will have the following format with a message and an error code:

{
    "errors": [
        {
            "message": "Access denied. Missing permission CLICK_AND_COST_OVER_TIME for shop id x.",
            "path": ["..."],
            "extensions": {
                "code": "FORBIDDEN",
                ...
            }
        }
    ],
    "data": null
}

Current User

Here is an example of a request to get info about the current user.

curl --location --request POST 'https://api.schibsted.com/prisjakt/insights-v2/graphql' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer <token>' \
--header 'client-id: <client-id>' \
--data-raw '{"query":"query CurrentUser { currentUser { id shops { shop { id name } permissions } brandServices { brandService { id market brand { id name } } permissions } } }","variables":{}}'
{
  "data": {
    "currentUser": {
      "id": "9uml15zp8c6w1am2cpxln8jqx6xoyhaq",
      "shops": [
        {
          "shop": {
            "id": "1",
            "name": "Prisjakt"
          },
          "permissions": [
            "CLICK_AND_COST",
            "CLICK_AND_COST_OVER_TIME",
            "INVENTORY_ANALYSIS",
            "SHOP_MARKET_SHARE",
            "SHOP_OFFER_INVENTORY_REPORT"
          ]
        }
      ],
      "brandServices": [
        {
          "brandService": {
            "id": "GMLYsMxHKfkNFbjhPpJA",
            "market": "SE",
            "brand": {
              "id": "1",
              "name": "Prisjakt"
            }
          },
          "permissions": [
            "BRAND_MARKET_SHARE"
          ]
        }
      ]
    }
  }
}

Rate Limiting

To make the API fast for everybody, rate limiting is applied to the Client ID.

Production: 10,000 requests in 1 hour

The returned HTTP headers of any API request show your current rate limit status:

HEADERDESCRIPTION
X-RateLimit-LimitThe maximum number of requests you're permitted to make per hour.
X-RateLimit-RemainingThe number of requests remaining in the current rate limit window.
X-RateLimit-ResetThe 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

Reviews