Prisjakt Insights News API icon

Prisjakt Insights News API

(0 reviews)

home

The Prisjakt Insights News API delivers short robot generated news items about noteworthy trends in Prisjakt's data. It might for example detect that a product is trending, or that most of the products in a category are sold out.

GraphQL

The API is based on GraphQL.

Requests

GraphQL uses a single endpoint for all interactions. POST your queries to this URL: https://api.schibsted.com/prisjakt/insights-news/graphql

Example:

$ curl -X POST \
       -H 'Content-Type: application/graphql' \
       -H 'X-Client-Id: b53f2cb6a36ab5230ee437e798c2665d' \
       https://api.schibsted.com/prisjakt/insights-news/graphql \
       --data '
{
  news {
    title
    text
    category {
      id
      name
    }
  }
}
'

In most cases, you should add constraints to your query to limit the results:

$ curl -X POST \
       -H 'Content-Type: application/graphql' \
       -H 'X-Client-Id: b53f2cb6a36ab5230ee437e798c2665d' \
       https://api.schibsted.com/prisjakt/insights-news/graphql \
       --data '
{
  news(market: "se", updatedGte: "2021-04-21T00:00:00.000Z") {
    title
    text
    category {
      id
      name
    }
  }
}
'

Errors

Unlike REST APIs, GraphQL can return HTTP 200 even on failures. The result will however contain an errors object.

{"errors":[{"message":"Error fetching data"}]}

Schema

The schema describes which fields are available for queries, and which arguments you can use.

"Robot generated news."
type Query {
    news(
        type: String,
        brand: Int,
        category: Int,
        product: Int,
        market: String,
        updatedGte: String,
        updatedLte: String,
    ): [News]
}

"Short robot generated news based on changes in Prisjakt's treasure trove of data."
type News {
    "Which market this news was generated on."
    market: String
    "When this news was first created."
    created: String
    "When this news was last updated."
    updated: String
    "What kind if news this is. Intended to be machine readable for easy querying and sorting."
    type: String
    "Human readable label of what kind of news this is, in the language of the market where the news was generated."
    localType: String
    "Snappy headline of what the news is about, in the language of the market where the news was generated."
    title: String
    "If you want to make the title into a link, then this is the URL to use."
    titleUrl: String
    "Short body text that presents the actual news in simple terms, in the language of the market where the news was generated."
    text: String
    "The product category that the news applies to, if any."
    category: Category
    "The product that the news applies to, if any."
    product: Product
    "The brand that the news applies to, if any."
    brand: Brand
}

"The brand that the news applies to."
type Brand {
    "Prisjakt's unique identifier for this brand."
    id: Int
    "The brand name."
    name: String
    "URL to the brand's overview page on Prisjakt, on the market where the news was generated."
    url: String
    "URL to an image of the brand's logotype."
    img: String
}

"The product category that the news applies to."
type Category {
    "Prisjakt's unique identifier for this category."
    id: Int
    "The category name in the language of the market where the news was generated."
    name: String
    "URL to the category's page on Prisjakt, on the market that the news was generated."
    url: String
    "URL to an icon representing the category."
    img: String
}

"The product that the news applies to."
type Product {
    "Prisjakt's unique identifier for this product."
    id: Int
    "The name of the product on the market where the news was generated."
    name: String
    "URL to the product's page on Prisjakt, on the market where the news was generated."
    url: String
    "URL to an image of the product."
    img: String
}

Subscription

The subscription API is based on REST principles. Data resources are accessed via standard HTTPS requests in UTF-8 format to an API endpoint.
Available HTTP verbs in B2B Insights News API:

METHODACTION
GETGet subscription
POSTCreate subscription
PUTUpdate subscription
DELETEDelete subscription

Authorization

In order to use the subscription api you need to send in a clientId and clientSecret. You also needs to send in the authorization header with a valid access token.

Requests

In order to fetch a subscription you can use the following request.

Example:

$ curl -X GET \
       -H 'Content-Type: application/json' \
       -H 'client-Id: clientId' \
       -H 'client-Secret: clientSecret' \
       https://api.schibsted.com/prisjakt/insights-news/subscription?shopId=1

{
    "recipients":
    [
        "test@testsson.com",
        "testsson@test.com"
    ],
    "shopId": "1"
}

You can create a new subscription with a POST request.
Example:

$ curl -X POST  \
       -H 'Content-Type: application/json' \
       -H 'client-Id: clientId' \
       -H 'client-Secret: clientSecret' \
      'https://api.schibsted.com/prisjakt/insights-news/subscription' \
      --data-raw '{ \
        "shopId": "1", \
        "recipients": ["testsson@test.com"] \
      }'
{
    "recipients":
    [
        "testsson@test.com",
    ],
    "shopId": "1"
}

You can update your recipients list with a PUT request.
Example:

$ curl -X PUT  \
       -H 'Content-Type: application/json' \
       -H 'client-Id: clientId' \
       -H 'client-Secret: clientSecret' \
      'https://api.schibsted.com/prisjakt/insights-news/subscription' \
      --data-raw '{ \
        "shopId": "1", \
        "recipients": ["testsson@test.com"] \
      }'
{
    "recipients":
    [
        "testsson@test.com",
    ],
    "shopId": "1"
}

It is possible to delete a subscription based on a shop id.

$ curl -X DELETE  \
       -H 'Content-Type: application/json' \
       -H 'client-Id: clientId' \
       -H 'client-Secret: clientSecret' \
      'https://api.schibsted.com/prisjakt/insights-news/subscription?shopId=XXX'
204 No content

Reviews