Headless API
REST API for modern e-commerce
Base URL
https://din-shop.dk/api
💡 Session Management
The API uses cookies to maintain cart and session. For cross-origin requests, use credentials: 'include'.
Products
List products
GET /api/products?limit=20&offset=0&category_id=5
{
"success": true,
"data": {
"products": [
{
"id": 123,
"name": "Produkt navn",
"price": 299.95,
"url": "/produkt-navn",
"images": [...]
}
],
"pagination": {
"total": 156,
"limit": 20,
"offset": 0
}
}
}
Single product
GET /api/products/123
{
"success": true,
"data": {
"id": 123,
"name": "Produkt navn",
"description": "Beskrivelse...",
"price": 299.95,
"in_stock": true,
"images": [
{
"id": 456,
"formats": {
"original": "https://...",
"thumbnail": "https://..."
}
}
]
}
}
Basket
Add to cart
POST /api/basket
{
"product_id": 123,
"amount": 2
}
Update quantity
PUT /api/basket/123
{
"amount": 5
}
Remove from cart
DELETE /api/basket/123
View cart
GET /api/basket
{
"success": true,
"data": {
"items": [
{
"product_id": 123,
"name": "Produkt navn",
"price": 299.95,
"amount": 2,
"total": 599.90
}
],
"subtotal": 599.90,
"shipping": 39.00,
"total": 638.90
}
}
Order View
View order details
GET /api/order?order_id=621&chk=aef1dab1fe24a18fdcf675c09a34bf34
Returns complete order information including products, addresses, prices and shipping.
chk parameter is MD5 hash of customer email for security.
{
"success": true,
"data": {
"order": {
"order_id": "1738",
"status": "new",
"total": "1067.59",
"currency": "DKK",
"customer": {
"name": "Morten Nielsen",
"email": "kunde@example.com"
},
"products": [
{
"name": "Kim og Tysklæreren",
"price": "129.95",
"quantity": "9",
"image": {
"url": "https://shop.dk/cache/fit-300x300x90.png"
}
}
],
"totals": {
"subtotal": "1052.59",
"shipping": "15.00",
"total": "1067.59"
}
}
}
}
💡 Security
The Order API requires the chk parameter which is the MD5 hash of the customer's email address. This ensures that only the customer can see their own order.
Settings
Get terms of trade and other settings
GET /api/settings
Returns important webshop settings, primarily terms & conditions.
{
"success": true,
"data": {
"terms": "<p>Lorem ipsum dolor sit amet...</p>",
"has_terms": true
}
}
💡 Application
Typically used to display terms and conditions in the checkout flow, where the customer must accept them before completing the purchase.
Checkout Flow
Step 1: Customer information
POST /api/checkout
{
"step": "address",
"email": "kunde@example.com",
"name": "Anders Andersen",
"address": "Vestergade 10",
"zipcode": "8000",
"city": "Aarhus",
"country": "DK",
"phone": "12345678"
}
Step 2: Shipping method
POST /api/checkout
{
"step": "shipping",
"shipping_id": 1
}
At the parcel shop:
{
"step": "shipping",
"shipping_id": 2,
"shop": "5004",
"shop_name": "Pakkeshop Føtex",
"shop_street": "Vesterbro 39",
"shop_zip": "5000",
"shop_city": "Odense C"
}
Step 3: Payment method
POST /api/checkout
{
"step": "payment",
"payment_gateway_id": 1
}
Step 4: Complete order
POST /api/checkout
{
"step": "complete"
}
{
"success": true,
"data": {
"order_id": 624,
"order_number": "ORD-2024-0624",
"total": 638.90,
"payment_redirect": "https://payment.quickpay.net/..."
}
}
All endpoints
Products
GET /api/productsGET /api/products/{id}GET /api/categoriesGET /api/categories/{id}GET /api/search?q={query}Basket
GET /api/basketPOST /api/basketPUT /api/basket/{id}DELETE /api/basket/{id}Orders
GET /api/order?order_id={id}&chk={hash}Checkout
GET /api/checkoutPOST /api/checkoutGET /api/shippingGET /api/payment-methodsGET /api/countriesContent
GET /api/pagesGET /api/pages/{id}GET /api/blogGET /api/blog/{id}GET /api/landing-pagesGET /api/menusGET /api/frontpageGET /api/resolve/{url}Settings
GET /api/settings