Techdocs
Search…
Using the API
In order to use the GraphQL endpoints, you'll need to authenticate yourself. You will need a Apps token to access this endpoint. Only a subset of the endpoints can be accessed with a public token. This makes it possible to access functionality like querying product recommendations in an environment where it's not possible to protect the token, for example in a web browser. Each publicly accessible endpoint is denoted in the embedded documentation inside the playground.
Note: Nosto does not rate-limit the API usage but follows a fair-use policy. Nosto reserves the right to revoke API access for any abusive API usage patterns.

Sending JSON GraphQL queries

You can send your GraphQL requests as JSON to our API and have it correctly interpolate variables passed into it. To do so, set the Content-Type header to application/json.
Authentication
Token
Method
Endpoint
Basic
API_APPS
POST
https://api.nosto.com/v1/graphql
1
curl -0 -v -X POST https://api.nosto.com/v1/graphql \
2
-u ":<token>" \
3
-H 'Content-Type: application/json' \
4
-d @- << EOF
5
{
6
"query": "query { recos (preview: false, image: VERSION_7_200_200) { toplist(hours: 168, sort: BUYS, params: { minProducts: 1 maxProducts: 10 } ) { primary { name productId } } } }"
7
}
8
EOF
Copied!

Sending raw GraphQL queries

If you want to send raw GraphQL queries to the API, you can still do so but you must set the Content-Type header to application/graphql.
Note: If you do not set the correct Content-Type header, the request will be interpreted as JSON and will fail.
Authentication
Token
Method
Endpoint
Basic
API_APPS
POST
https://api.nosto.com/v1/graphql
1
curl -0 -v -X POST https://api.nosto.com/v1/graphql \
2
-u ":<token>" \
3
-H 'Content-Type: application/graphql' \
4
-d @- << EOF
5
query {
6
recos (preview: false, image: VERSION_7_200_200) {
7
toplist(hours: 168, sort: BUYS, params: {
8
minProducts: 1
9
maxProducts: 10
10
}) {
11
primary {
12
name
13
productId
14
}
15
}
16
}
17
}
18
EOF
Copied!

Using Fetch

You can use the browser's fetch API to request data from GraqhQL. You will need to authenticate yourself and set the appropriate content-type headers.

Sending JSON GraphQL queries

You can send your GraphQL requests as JSON to our API and have it correctly interpolate variables passed into it. To do so, set the Content-Type header to application/json.
1
const body = JSON.stringify({
2
query: `
3
query {
4
order(id: "5192009") {
5
number
6
reference
7
items {
8
productId
9
skuId
10
unitPrice
11
priceCurrencyCode
12
quantity
13
}
14
recos(preview: true, image: VERSION_1_170_170) {
15
related(params: {
16
minProducts: 1,
17
maxProducts: 5
18
}) {
19
primary {
20
productId
21
name
22
price
23
}
24
}
25
}
26
}
27
}
28
`});
29
30
fetch('https://api.nosto.com/v1/graphql', {
31
method: 'POST',
32
headers: new Headers({
33
'Content-Type': 'application/json',
34
'Authorization': 'Basic ' + btoa(":" + "<token>")
35
}),
36
mode: 'cors',
37
body
38
})
39
.then((response) => response.json())
40
.then((json) => {
41
console.log(json);
42
});
Copied!

Sending raw GraphQL queries

If you want to send raw GraphQL queries to the API, you can still do so but you must set the Content-Type header to application/graphql.
NOTE:If you do not set the correct Content-Type header, the request will be interpreted as JSON and will fail.
1
const body = `
2
query {
3
order(id: "5192009") {
4
number
5
reference
6
items {
7
productId
8
skuId
9
unitPrice
10
priceCurrencyCode
11
quantity
12
}
13
recos(preview: true, image: VERSION_1_170_170) {
14
related(params: {
15
minProducts: 1,
16
maxProducts: 5
17
}) {
18
primary {
19
productId
20
name
21
price
22
}
23
}
24
}
25
}
26
}
27
`;
28
29
fetch('https://api.nosto.com/v1/graphql', {
30
method: 'POST',
31
headers: new Headers({
32
'Content-Type': 'application/graphql',
33
'Authorization': 'Basic ' + btoa(":" + "<token>")
34
}),
35
mode: 'cors',
36
body
37
})
38
.then((response) => response.json())
39
.then((json) => {
40
console.log(json);
41
});
Copied!
Last modified 1yr ago