> This page is for Documentation.

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://fiftytwo-demo.ferndocs.com/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://fiftytwo-demo.ferndocs.com/_mcp/server.

# Your first API call

The quickest way to see 52ViKING actually doing something is to price a basket.
It is one call, it is read-only, and the response shows the promotion engine at
work.

You will need a chain number, a store number, and credentials from your FiftyTwo
consultant.

#### Get an access token

```bash
export FT_TOKEN=$(curl -s -X POST https://auth.fiftytwo.com/v1/user \
  -H "Content-Type: application/json" \
  -d '{"username":"'"$FT_USER"'","password":"'"$FT_PASS"'"}' \
  | python3 -c 'import json,sys; print(json.load(sys.stdin)["access_token"])')

echo "${FT_TOKEN:0:24}..."
```

If that prints a truncated JWT, you are authenticated. If it prints nothing,
re-read [Authentication](/docs/authentication).

#### Price a basket

`CalculateBasket` takes the chain and store in the path, because promotions
are store-specific.

**`cURL`**

```bash title="cURL"
curl -X POST \
  "https://api.fiftytwo.com/basket/basket/calculatebasket/1/0142" \
  -H "Authorization: Bearer $FT_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "lines": [
      { "ean": "5701234000019", "quantity": 1 },
      { "ean": "5701234000217", "quantity": 1 }
    ]
  }'
```

**`Python`**

```python title="Python"
import os, requests

resp = requests.post(
    "https://api.fiftytwo.com/basket/basket/calculatebasket/1/0142",
    headers={"Authorization": f"Bearer {os.environ['FT_TOKEN']}"},
    json={
        "lines": [
            {"ean": "5701234000019", "quantity": 1},
            {"ean": "5701234000217", "quantity": 1},
        ]
    },
    timeout=30,
)
resp.raise_for_status()
basket = resp.json()
```

> **Note**
>
> Basket API accepts **either XML or JSON** for both request and response.
> Set `Content-Type` and `Accept` to whichever you prefer. Check the
> [request schema](/api/basket/reference) for the exact line-item field names
> your chain's configuration expects.

#### Read the discount lines

The response is **line-orientated**: each line in your request stays its own
line in the receipt. Lines are never collapsed or expanded, so a quantity of
three is one line, not three.

Discounts arrive as their own lines, referencing the rule that produced
them. That reference is the discount group or campaign ID you can look up
through [Master Data](/api/master-data/overview), which is how you explain a price back
to a customer.

#### Compare against a till

The point of Basket API is that it uses the same logic as a physical till.
Ring the same basket up on a real POS and the totals should match to the
øre. If they do not, the usual cause is the store number: promotions differ
per store.

## What to build next

#### [Sync a product catalog](/docs/guides/sync-catalog)

Get your own articles and promotions into 52ViKING.

#### [Import webshop sales](/docs/guides/import-sales)

Make online orders returnable in a store.

## Concepts worth ten minutes

These explain the model the API field names assume:

#### [Discount types](/help/concepts/discount-types)

Mix, amount, ladder, percent-of-cheapest.

#### [Discount groups](/help/store-management/discount-groups)

How a promotion is actually configured.

#### [Buy side / Get side](/help/store-management/discount-groups-buyget)

Trigger articles versus discounted articles.