Getting started

Three steps: keep your key in a variable, make a first call with GET /v1/worlds, then run the quickstart.

Before you start

  • An active plan, built on the plan page and paid in Tibia Coins.
  • Your key, shown only once in your panel. Keep it in an environment variable such as TGM_API_KEY.
  • Nothing to type for your place: the first data call made with the key defines it (Key and place).

Base URL and authentication

Every call goes to https://data.tibiaglobalmarket.com with the key in the Authorization header:

GET /v1/worlds HTTP/1.1
Host: data.tibiaglobalmarket.com
Authorization: Bearer tgm_live_<prefix>_<secret>
Never put the key in a URL: it gets 400 KEY_IN_QUERY and must be replaced. The API sends no CORS headers, so call it from your server or computer, not from a browser.

First call: set your place

Run this on the machine that will call the API. Line 1 asks for your key and keeps it in TGM_API_KEY; line 2 calls GET /v1/worlds (1 unit), which lists the worlds and, on a key without a place, sets the place to this machine.

  1. read -rsp "API key: " TGM_API_KEY && export TGM_API_KEY
  2. curl "https://data.tibiaglobalmarket.com/v1/worlds" -H "Authorization: Bearer $TGM_API_KEY"
{
  "data": [
    {
      "name": "Antica",
      "pvp_type": "open",
      "battleye": "yellow",
      "location": "EU",
      "in_plan": true,
      "world_updated_at": "2026-11-17T09:12:00Z",
      "data_version": "efd2cda81ebbb612",
      "partial": false
    }
  ],
  "meta": {
    "request_id": "req_01JD3Q6V7Y2K",
    "units": 1,
    "cached": false
  }
}

in_plan marks the worlds of your plan. If the key already has a place at another address, the call gets 403 IP_NOT_ALLOWED with the address we saw in seen_ip: run your script on the machine that holds the place, or release the place in your panel.

Quickstart

Each script downloads the whole market of one world in your plan to market-<World>.json and keeps its ETag. Run it again: if nothing changed, the answer is 304 Not Modified, for 0 units.

quickstart.sh
#!/usr/bin/env bash
# Tibia Global Market API: quickstart for bash + curl.
#
# Downloads the whole market of one world in your plan and keeps a copy in
# market-<World>.json. Run it again later: when nothing changed, the API
# answers 304 Not Modified, which costs 0 units, and the copy stays as it is.
#
#   export TGM_API_KEY='...'      # from your panel; never put it in a URL
#   bash quickstart.sh Antica
set -u

BASE="${TGM_API_BASE:-https://data.tibiaglobalmarket.com}"
MAX_ATTEMPTS=3   # first call + 2 retries, only after 429 or 503
MAX_WAIT_SECONDS=60
WORLD="${1:-Antica}"

if [ -z "${TGM_API_KEY:-}" ]; then
  echo "Set the TGM_API_KEY environment variable first." >&2
  exit 2
fi
if ! [[ "$WORLD" =~ ^[A-Za-z]{2,30}$ ]]; then
  echo "Not a world name: $WORLD" >&2
  exit 2
fi

DATA_FILE="market-$WORLD.json"
ETAG_FILE="market-$WORLD.etag"
TMP_DIR="$(mktemp -d)"
trap 'rm -rf "$TMP_DIR"' EXIT

# One response header, without the trailing CR.
header() { grep -i "^$1:" "$TMP_DIR/headers" | tail -n 1 | cut -d' ' -f2- | tr -d '\r'; }
# One string field of the JSON error body (enough for problem+json; use jq for real work).
field() { tr -d '\n' < "$TMP_DIR/body" | sed -n "s/.*\"$1\" *: *\"\\([^\"]*\\)\".*/\\1/p"; }

ETAG=""
[ -f "$ETAG_FILE" ] && ETAG="$(cat "$ETAG_FILE")"   # exactly as the last 200 sent it

for ATTEMPT in $(seq 1 "$MAX_ATTEMPTS"); do
  ARGS=(--silent --show-error --compressed --max-time 60
        --output "$TMP_DIR/body" --dump-header "$TMP_DIR/headers" --write-out '%{http_code}'
        --header 'Accept: application/json' --header @-)
  [ -n "$ETAG" ] && ARGS+=(--header "If-None-Match: $ETAG")
  # The key goes to curl on stdin, so it never shows up in the process list.
  if ! STATUS="$(printf 'Authorization: Bearer %s\n' "$TGM_API_KEY" | curl "${ARGS[@]}" "$BASE/v1/market/$WORLD")"; then
    echo "Request failed." >&2
    exit 1
  fi
  REQUEST_ID="$(header X-Request-Id)"

  if [ "$STATUS" = "304" ]; then
    echo "$WORLD: 304 not modified, 0 units. $DATA_FILE is still current."
    exit 0
  fi
  if [ "$STATUS" = "200" ]; then
    if ! header Content-Type | grep -qi json; then
      echo "HTTP 200: the answer is not the API's JSON (request ${REQUEST_ID:--}). Stopping." >&2
      exit 1
    fi
    cp "$TMP_DIR/body" "$DATA_FILE"   # curl --compressed already removed the gzip layer
    NEW_ETAG="$(header ETag)"
    [ -n "$NEW_ETAG" ] && printf '%s' "$NEW_ETAG" > "$ETAG_FILE"
    echo "$WORLD: saved $DATA_FILE ($(wc -c < "$DATA_FILE" | tr -d ' ') bytes), $(header X-Units-Charged) units, $(header X-Quota-Remaining) left today."
    exit 0
  fi

  CODE=""
  if header Content-Type | grep -qi json; then CODE="$(field code)"; fi
  if [ -z "$CODE" ]; then
    echo "HTTP $STATUS: the answer is not JSON (request ${REQUEST_ID:--}). Stopping." >&2
    exit 1
  fi
  # Only 429 and 503 are worth another try, and only after Retry-After.
  WAIT="$(header Retry-After)"
  if { [ "$STATUS" = "429" ] || [ "$STATUS" = "503" ]; } && [ "$ATTEMPT" -lt "$MAX_ATTEMPTS" ] \
     && [[ "$WAIT" =~ ^[0-9]+$ ]] && [ "$WAIT" -le "$MAX_WAIT_SECONDS" ]; then
    echo "HTTP $STATUS $CODE: waiting ${WAIT}s (attempt $ATTEMPT of $MAX_ATTEMPTS)." >&2
    sleep "$WAIT"
    continue
  fi
  # Anything else: stop and fix the cause. Never repeat a 401 or a 403.
  echo "HTTP $STATUS $CODE: $(field detail) (request $(field request_id))" >&2
  echo "See $(field docs_url)" >&2
  exit 1
done
exit 1
  • They read the key from TGM_API_KEY and never print it.
  • On 429 or 503 they wait Retry-After and retry, 3 attempts at most.
  • On any other error they print code, detail and docs_url and stop.
  • The whole-world answer is gzip: curl --compressed and Node fetch unpack it; the Python script does it by hand.

Responses

Success is JSON with data and meta: meta.units is the cost and meta.request_id identifies the call (on the whole-world answer, read the X-Request-Id header).

  • Gold values are strings of digits, such as "1450000".
  • Dates are ISO 8601 in UTC, ending in Z.
  • Unknown values are null; empty lists are [].
  • item_id is the game’s own item id.
  • Unknown query parameters get 400 VALIDATION_FAILED.
  • New fields can appear in v1: ignore the ones you do not know.

Errors are application/problem+json: read code (Errors).

Endpoints

EndpointModuleUnits
GET /v1/openapi.jsonPublic, no key0
GET /v1/worldsbase, included1
GET /v1/categoriesbase, included1
GET /v1/items?q=&category=base, included1
GET /v1/items/{item_id}base, included1
GET /v1/coins/resellersbase, included1
GET /v1/coins/p2p?side=&world=base, included1
GET /v1/market/{world}market10 (304: 0)
GET /v1/market/{world}/items/{item_id}market1
GET /v1/market/{world}/items/{item_id}/history?days=market2
GET /v1/npc-profit?world=&min_profit=npc-profit1
GET /v1/arbitrage?origin=&destination=arbitrage1
GET /v1/bazaar/auctions?world=&vocation=bazaar1
GET /v1/bazaar/auctions/{auction_id}bazaar1
GET /v1/bazaar/characters/{name}bazaar1
POST /v1/bazaar/characters/estimatebazaar1
GET /v1/highscores?category=&world=highscores1
GET /v1/highscores/characters/{name}highscores1
GET /v1/highscores/movers?category=highscores1

Every parameter and field: GET /v1/openapi.json (OpenAPI 3.1, no key).

Conditional requests

Send the ETag back in If-None-Match: if nothing changed you get 304 Not Modified, with no body, for 0 units. A W/ prefix is ignored.

GET /v1/worlds gives world_updated_at and in_plan for each world; call it at most once every 5 minutes.

Glossary

Key
The secret that identifies your account in every call, sent in Authorization: Bearer.
Prefix
The public first part of the key (8 characters), used to tell keys apart in your panel.
Place
The address the key is used from: one IPv4 address or one IPv6 /64, never both. The first data call made with the key defines it.
Module
A part of the API you subscribe to, such as market. base comes with any plan.
World in the plan
A game world chosen for your market module, marked with in_plan in GET /v1/worlds.
Unit
What a call costs against the daily quota. Most calls cost 1.
Daily quota
20,000 units per key per UTC day.
Rate limit
60 requests per key per minute.
Data version
An opaque value in data_version that identifies the version of a world’s data. partial is true when that version is incomplete for the world.
ETag
A tag for one version of an answer. Send it back in If-None-Match to get 304 when nothing has changed.
Request id
The id of one call, in X-Request-Id. Quote it when you report a problem.
Cycle
The 30 days a plan lasts. It does not renew by itself.