API docs
A quick introduction to the entity content API
How to get started.
We use the Postman app to test the APIs. You can use this app, or any similar app to test the APIs before you start the implementation.
Authentication (JWT)
To get access to the content, you might have to authenticate yourself. This is how.
URL: /api/auth
Method: POST
Headers: content-type: application/json
Request-body, raw:
{"username":"[email protected]","password":"MyVerySecurePassword:)"}
The response will look something like this:
{ "token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJteW5hbWVAbXlkb21haW4uY29tIiwiZXhwIjoxNTg0OTk5NDQ1NDAwLCJleHBpcmVzIjoiMjMuMDMuMjAyMCAyMTozNzoyNSIsInJvbGUiOiJhZG1pbiIsImxhbmd1YWdlIjoiZW4iLCJuYW1lIjoiRmlyc3RuYW1lIExhc3RuYW1lIiwidXNlcmlkIjoxNDQ1LCJhdXRoIjoiNjE3N2NhYjk1ZGFhNHNkZmFkc2ZhZGZkZjIifQ.NSQWsRXdnJM0f429Ize8Ms35Se66enZOznX7bpFSVXE"}
You can decode the token at https://jwt.io if you are interested in what it contains.
From now on you can use this token to authenticate your API calls by including it as a Bearer token.
Getting content(items)
To start getting some content from the webpage it is easy to just use the search function. It is quite extensive, and versatile. You can select all or some fields from the item, and get one or more items at a time.
URL: /api/itemsearch
Method: POST
Headers: content-type: application/json
Request-body, raw (example with some search parameters):
{
"ProductSKUs":["ABC123","DEF456"],
language : "en",
templatefields: ["title","author", "customfield"],
"orderby":"str05"
}
All available search parameters:
- int? CategoryId
- int? ItemId
- int? MenuItemId
- int? OriginalItemId
- int? Page (default: 1)
- int? PageSize (default: 50)
- int? ParentItemId
- int? TemplateId
- int SkipItems (default: 0)
- string CategoryName
- string Language
- string OrderBy
- string ProductSKU
- string SearchString
- string Tags
- string TemplateName
- string Where
- List<string> TemplateFields
- List<int> CategoryIds
- List<int> TemplateIds
- bool? OnlyItemIds (default: false)
- bool? SelectDisctinct (default: false)
- bool? isDebug (default: false)
When you do a search, you will also receive meta-data that gives you feedback on your query. It might help you understand, but if the query fails, you can activate the debug-mode (isDebug). Then the query is saved to the error log inside entity. You find it in the developer section at the bottom of the sidebar. Just start playing, and you will find a good solution for your project.
The meta-data will look something like this:
"meta": {
"itemcount": 1,
"page": 1,
"pagecount": 1,
"itemsperpage": 50,
"searchparameters": {
"ProductSKUs": [
"10109364"
],
"Page": 1,
"PageSize": 50,
"SkipItems": 0,
"Language": "no",
"OrderBy": "str05",
"OnlyItemIds": false,
"TemplateFields": [
"title",
"articleno",
"str05"
]
},
"querytime": 47
},
Shop product - Get price
To create and update a shop basket there are multiple endpoints. Use the JWT-token or sessionId to identify your basket. You will receive a sessionId on your first touch.
URL: /api/shopproduct/getprice
Method: GET
Parameters:
- productSKU
- language
- externalSKU
- shopproductid
Example: /api/shopproduct/getprice?productsku=WEB-302&language=en
Response:
{
"ProductSKU": "WEB-302",
"Name": "Test product",
"ItemUrl": "/products/test-product",
"Language": "en",
"ItemId": 302,
"PriceIncVat": 2134.0,
"PriceExVat": 1707.2,
"Stock": 1000.0
}
Shop product - Find product
To create and update a shop basket there are multiple endpoints. Use the JWT-token or sessionId to identify your basket. You will receive a sessionId on your first touch.
URL: /api/shopproduct/find
Method: GET
Parameters:
- productSKU (optional)
- language (optional)
- externalSKU (optional)
- shopproductid (optional)
Example: /api/shopproduct/getprice?productsku=WEB-302&language=en
Response:
{
"ProductSKU": "WEB-302",
"Name": "Test product",
"ItemUrl": "/products/test-product",
"Language": "en",
"ItemId": 302,
"PriceIncVat": 2134.0,
"PriceExVat": 1707.2,
"Stock": 0.0,
"ItemInfo": {
"shopproduct_productsku": "WEB-302",
"title": "Testproduct",
"teaser": "",
"boolcustomfield2": false,
...
},
"StockLocations": []
}
Shop basket endpoints
To create and update a shop basket there are multiple endpoints. Use the JWT-token or sessionId to identify you basket. You will receive a sessionId on your first touch.
Language is used for the return values you get back.
Get basket
URL: /api/shopbasket/get
Use the JWT-token to identify your basket. You will receive a sessionId on your first touch.
Method: GET
Headers: content-type: application/json
Parameters:
- id
- Send 0 to get the current basket or a sessionId/guid
- If you try to open an ID, the user has to be logged in with the userid that is set on the shopbasketid
- sessionId (optional)
- guid (optional)
- language (optional)
Response:
- Basketinfo in the selected language
- If no basket is found with the given id or sessionId/guid, it will return the current basket (if any)
Example: /api/shopbasket?id=0
Add product
URL: /api/shopbasket/addproduct
Use the JWT-token or sessionId to identify your basket. You will receive a sessionId on your first touch.
Method: POST
Headers: content-type: application/json
Parameters:
- quantity
- shopProductId (optional, but you need to send in this or productsku)
- productsku (optional, but you need to send in this or shopProductId)
- sessionId (optional)
- description (optional)
- language (optional)
Response:
- Basketinfo in the selected language
Set quantity
URL: /api/shopbasket/setquantity
Use the JWT-token or sessionId to identify your basket. You will receive a sessionId on your first touch.
Method: POST
Headers: content-type: application/json
Parameters:
- quantity
- sessionId
- shopProductId (optional, but you need to send in this or productsku)
- productsku (optional, but you need to send in this or shopProductId)
- language (optional)
Response:
- Basketinfo in the selected language
Remove product
URL: /api/shopbasket/removeproduct
Use the JWT-token or sessionId to identify your basket. You will receive a sessionId on your first touch.
Method: POST
Headers: content-type: application/json
Parameters:
- sessionId
- shopProductId (optional, but you need to send in this or productsku)
- productsku (optional, but you need to send in this or shopProductId)
- language (optional)
Response:
- Basketinfo in the selected language