Headless API
Build your own storefront on Shoporama
Base URL
https://din-shop.dk/api
If the store sells in multiple countries, call the country's URL, e.g. https://din-shop.dk/en/api. Language, currency, prices, and delivery countries then follow that country.
Session and Login
The shopping cart, checkout, and customer login use cookies, just like in the online store. Make browser calls with credentials: 'include'. The customer is logged in to both the API and the store at the same time.
The shopping cart, checkout, and login only work when your storefront is running on the store’s primary domain (Webshop → Domain) or a country-specific domain. The domains listed under "Multiple domains" forward all requests to the primary domain, including calls to /api. The catalog, pages, and menus can be accessed from all domains.
Responses and errors
All responses have the same format. If there is an error, the reason is stated in error.details.reason, so you can show your own text to the customer.
{
"success": false,
"error": {
"code": 400,
"message": "Payment method not selected",
"details": { "reason": "payment_missing" }
}
}
Every error has a cause. The ones you'll typically need to handle are: empty_basket, stock, sold_out, requires_variant, product_unavailable, max_per_order, customer_input, min_order_value, delivery_country, address_missing, shipping_invalid, payment_missing, payment_not_available, payment_link_failed, order_in_progress, voucher_not_found, voucher_expired, points_invalid, login_failed, login_required and not_found.
The limit is 300 calls per minute per session. After that, the API returns a 429 response. The store also has a limit per IP address for all requests. If this limit is exceeded, the IP address is blocked for one hour with a 429 response as plain text rather than JSON, so cache the catalog and content if your server retrieves them.
The API does not include a version number in the URL. New fields may be added, so ignore any fields that your code does not recognize.
Products and Content
List products
GET /api/products?limit=20&offset=0&category_id=5
Only items that are available online and whose brand the customer is allowed to see. With category_id the products are returned in the category's own sort order. limit is at most 250; without it, the store's page size is used. ?gtin= looks up a barcode.
{
"success": true,
"data": {
"products": [
{
"id": 232167,
"name": "Terra Nova Etiopien Guji, hele bønner 1 kg",
"price": 249,
"old_price": null,
"buyable": true,
"url": "https://din-shop.dk/terra-nova-etiopien-guji-hele-boenner-1-kg",
"rewrite_url": "terra-nova-etiopien-guji-hele-boenner-1-kg",
"images": [...],
"categories": [...],
"brand": { "id": 445, "name": "Terra Nova", "url": "https://dinbutik.dk/brands/terra-nova" }
}
],
"pagination": {
"total": 32,
"limit": 20,
"offset": 0,
"pages": 2
}
}
}
Prices include VAT. Names, texts, and URLs follow the country's language.
brand.url is the brand's page (Link to or the brand's page), if the store has enabled brand pages; otherwise null.
Single product
GET /api/products/232167
{
"success": true,
"data": {
"id": 232167,
"name": "Terra Nova Etiopien Guji, hele bønner 1 kg",
"description": "<p>En let og blomstret kaffe ...</p>",
"sku": "TN-BON-01",
"price": 249,
"vat_rate": 25,
"buyable": true,
"images": [
{
"id": 63924,
"alt": "Pose med Terra Nova Etiopien Guji kaffebønner",
"formats": {
"original": "https://...",
"large": "https://...",
"medium": "https://...",
"small": "https://...",
"thumbnail": "https://..."
}
}
],
"attributes": [...],
"variants": [...],
"meta": { "title": "...", "description": "..." }
}
}
Sold-out variants are not included in variants. Each variant has options with the attribute name and value in the country's language, e.g., {"Farve": "Stål"}. Fields that the customer must fill out themselves (e.g., text for engraving) are listed in attributes with "input_mode": "customer".
Product images have full URLs. Images in categories and blog posts have relative URLs, e.g., /cache/6/5/…/kaffe-fit-800x800x90.png, so prefix the store's domain if you're displaying them from a different domain.
Look up a URL
GET /api/resolve/kaffeboenner
Tells you what a path in the store is, so your storefront can use the store's own URLs. type is home, category, product, page, blog, blog_list, landing, brand_list, brand, redirect or not_found.
{
"success": true,
"data": {
"type": "category",
"data": { "id": 19112, "name": "Kaffebønner", ... },
"products": [...],
"pagination": {...},
"blocks": {
"top": "<section ...>...</section>",
"bottom": "..."
}
}
}
brand_list and brand is available when the store has enabled brand pages and the theme has "supports_brand_pages": true. /brands provides brand_list with the brands (id, name, path, logo, product_count), the letters in letters and the brands per letter in groups. With more than 24 brands, index true, and featured has up to 12 brands with logos. If there are more than 300, paged true, and you fetch one letter at a time with ?letter=a. Without ?letter= is brands and groups empty. /brands/<adresse> provides brand with an introduction (description_a), body text (description_b), meta and breadcrumbs as well as the products in products with ?p= (0 is the first page, 1 is the second), ?sort= and ?sort_order=. /brand/<adresse> and a brand with Link to set return redirect. As in the store, /brands and an existing brand take precedence over the store's own redirects.
blocks contains the page designer's blocks for the page as finished HTML, rendered with the theme's own templates. Without blocks, the field is null. If you already have the page's blocks, add ?blocks=0.
Menus
GET /api/menus
{
"menus": [
{
"name": "Hovedmenu",
"location": "top",
"items": [
{
"title": "Kaffe",
"url": "",
"type": "menu",
"children": [
{ "title": "Kaffebønner", "url": "/kaffeboenner", "type": "category", "children": [] }
]
}
]
}
]
}
An item of type menu is a heading for a submenu and has no address.
Cart
Add to cart
POST /api/basket
attributes (attribute-id → value):{
"product_id": 232156,
"amount": 1,
"attributes": { "4301": 33385 }
}
View cart
GET /api/basket
{
"success": true,
"data": {
"items": [
{
"line_id": "232156:4301+33385",
"product_id": "232156",
"name": "Nordic Roast Stempelkande 1 liter",
"variant": "Farve: Stål",
"amount": 1,
"price": 299,
"subtotal": 299,
"in_stock": true,
"image": "https://..."
}
],
"subtotal": 299,
"shipping": 39,
"total": 338,
"vat": 67.6,
"currency": "DKK",
"shipping_chosen": false
}
}
The amounts are the store's own calculations, including campaigns, discount code, deposits, and shipping. Display them as they are so the customer sees the price they'll actually pay. Responses from checkout and discount codes include the updated cart in basket.
If a product has a deposit, the amount is listed in deposit_total (and per deposit type in deposits). The deposit is included in total, but not in subtotal, so display it as a separate line. The product lists the deposit per unit in deposit (name, amount).
Change the quantity or remove a line
PUT /api/basket/{line_id} DELETE /api/basket/{line_id}
{
"amount": 3
}
Use the line's line_id, so the correct variant is updated. Quantity 0 removes the line. A product ID targets the first line with that product.
Discount code
POST /api/voucher/apply POST /api/voucher/remove
{
"code": "SOMMER10"
}
The response contains the cart with the discount. A code that doesn't exist or has expired returns voucher_not_found or voucher_expired.
Pay with points
GET /api/points POST /api/points/apply POST /api/points/remove
{
"points": 500
}
Requires a login and a loyalty program. If the store has one, the shopping cart will have the field points:
"points": {
"balance": 1000,
"available": 1000,
"requested": 500,
"used": 500,
"discount": 50,
"earns": 1290,
"rate": { "points": 10, "amount": 1 }
}
balance is the customer's balance, and available the points the cart can take under the store's rules. For a guest, they are null. discount is deducted from the cart's total and vat, so display it as a separate line. earns are the points earned by the order, and rate how many points are worth what amount in the cart's currency. Too many points result in 400 points_invalid with available.
Points are capped at the maximum the cart can hold before the order is placed, and the order deducts them from the balance. Points are earned on the order when it is approved or shipped, depending on the store’s settings.
Checkout
Get the options available to the customer
GET /api/checkout
Returns the shopping cart, shipping methods, payment methods, and countries all at once, along with the addresses the customer has already entered. Only options the customer can actually select: online payment methods available in the customer’s country, and shipping options that match the cart’s weight and the destination country. When logged in, the customer also sees their B2B options, such as invoice.
Step 1: Address
POST /api/checkout
{
"step": "address",
"email": "kunde@example.com",
"phone": "12345678",
"name": "Karen Holm",
"company_name": "",
"address": "Vestergade 12",
"zipcode": "8000",
"city": "Aarhus C",
"country_id": 188,
"comments": "",
"newsletter": 0
}
Business customers can send vat_number and ean_number. A different shipping address is sent as delivery_name, delivery_company, delivery_address, delivery_zipcode, delivery_city and delivery_country_id. The country IDs are listed in GET /api/countries.
The response includes missing_fields (missing fields) and delivers_to_country, so you can display it right away. The order is not rejected until it is completed.
Send the full address every time. This step replaces all fields with what you send, including those you omit. If the customer is logged in, the checkout process uses the account’s address and email, and this step does not save a new address to the account until missing_fields is empty.
Step 2: Delivery
POST /api/checkout
{
"step": "shipping",
"shipping_id": 227,
"delivery_shop_id": "2386"
}
After the address step, shipping methods with parcel shops have a list in delivery_shops (number, name, street, zip, city). Send the parcel shop's number as delivery_shop_id. Any shipping method not on the list will be rejected. If you do not send a parcel shop, the store will choose the first one on the list.
Step 3: Payment Method
POST /api/checkout
{
"step": "payment",
"payment_gateway_id": 258
}
Step 4: Complete the order
POST /api/checkout
{
"step": "complete",
"payment_flow": "storefront"
}
The payment method is the one from step 3. You can also include it here as payment_id. Before the order is created, the API checks the same things as the store's own checkout process: inventory, minimum order amount, delivery country, address, shipping, and payment method. There are two types of responses.
{
"success": true,
"data": {
"payment_redirect": true,
"payment_url": "/payment",
"basket_id": 4809
}
}
Redirect the customer to payment_url. With "payment_flow": "storefront" it is the store's own payment page, which redirects to the payment window and works with all of the store's payment methods. Without it, the API provides the payment window’s address for QuickPay, OnPay, Pensopay, Flatpay, Stripe, Mollie, and Nets Easy. Other methods always go through the store’s payment page. The customer is then redirected back to the store’s /thanks.
{
"success": true,
"data": {
"redirect": "/thanks?basket_id=4809&chk=8ab02e10b1a9ec5db4f1fcee7f49fb05",
"order_id": 15505,
"webshop_order_id": 4522,
"chk": "8ab02e10b1a9ec5db4f1fcee7f49fb05",
"payment_info": "<p>Overfør beløbet til ...</p>"
}
}
payment_info is the store's own description of the payment method, such as the account number for a bank transfer. webshop_order_id is the order number that the customer sees.
Double-clicking and Payment Failures
- If the customer calls
completeagain, you get the same response as the first time. No new order is created. - If another request arrives while the order is being created, it waits up to six seconds and then receives the same response. If the order is not ready by then, the API responds
409 order_in_progress. - If the payment cannot be initiated, the API responds
502 payment_link_failed, and no order is created.
Receipt and Order
View an order
GET /api/order?basket_id=4809&chk=8ab02e10b1a9ec5db4f1fcee7f49fb05
With the receipt's basket_id or the order number (order_id). chk is an MD5 hash of the order's email address, so that only the customer can view the order. The response includes the prices the customer paid, not the current prices of the items.
{
"success": true,
"data": {
"order": {
"order_id": "4522",
"status": "new",
"paid": false,
"total": 308,
"currency": "DKK",
"customer": { "name": "Karen Holm", "email": "kunde@example.com" },
"products": [
{ "name": "Terra Nova Etiopien Guji, hele bønner 1 kg", "price": 249, "quantity": 1, "total": 249 }
],
"shipping": { "method": "Postnord omdeling", "price": 59 },
"payment": { "method": "Bankoverførsel", "info": "..." },
"totals": {
"subtotal": 249,
"shipping": 59,
"voucher_discount": 0,
"vat": 61.6,
"total": 308
}
}
}
}
Customer Account
Log In and Out
POST /api/auth POST /api/auth/logout
{
"email": "kunde@example.com",
"password": "..."
}
Use the same login as in the online store. Once logged in, the customer will see their customer group prices, payment methods, and address pre-filled. An incorrect email address or password will result in 401 login_failed.
The logged-in customer
GET /api/customer
{
"customer": {
"id": 2224,
"email": "kunde@example.com",
"name": "Karen Holm",
"address": "Vestergade 12",
"zipcode": "8000",
"city": "Aarhus C",
"country_id": 188,
"shipping_address": null,
"points": 120,
"urls": { "profile": "/user-profile", "orders": "/user-orders", "edit": "/user-edit" }
}
}
When not logged in, you get customer null. points is the customer's point balance and null, when the store doesn't have a loyalty program.
Customer Orders
GET /api/orders GET /api/orders/{ordrenummer}
The list includes the order number, date, status, total, currency, and the address of the order page. A single order has the same fields as GET /api/order. Without logging in: 401 login_required.
Account Creation and Forgotten Password
Link to the store's own pages /user-sign-up, /user-reset-password and /user-edit. Then the customer will receive a spam check, a welcome email, points for signing up, and verification of their CVR number, just like in the rest of the store.
Shop and Settings
Terms and conditions
GET /api/settings
{
"success": true,
"data": {
"terms": "<p>...</p>",
"has_terms": true
}
}
Typically used during checkout, where the customer must accept the terms and conditions before the order is completed.
Store
GET /api/shop
The store's name and URL, currency, language, default country, and the list of endpoints.
All endpoints
Products
GET /api/productsGET /api/products/{id}GET /api/categoriesGET /api/categories/{id}GET /api/frontpageGET /api/search?q={query}Cart
GET /api/basketPOST /api/basketPUT /api/basket/{line_id}DELETE /api/basket/{line_id}POST /api/voucher/applyPOST /api/voucher/removeGET /api/pointsPOST /api/points/applyPOST /api/points/removeCheckout
GET /api/checkoutPOST /api/checkoutGET /api/shippingGET /api/payment-methodsGET /api/countriesOrders and Customers
GET /api/order?basket_id={id}&chk={hash}POST /api/authPOST /api/auth/logoutGET /api/customerGET /api/ordersGET /api/orders/{ordrenummer}Content
GET /api/resolve/{sti}GET /api/menusGET /api/pagesGET /api/pages/{id}GET /api/blogGET /api/blog/{id}GET /api/landing-pagesShop
GET /api/shopGET /api/settingsA complete example
The "Washington" theme is a complete storefront built using this API, featuring the Page Designer, customer accounts, countries, and all payment methods. See Washington