Skip to main content

Documentation

api.thepubdb.com

Everything you need to integrate with the Pub DB API — authentication, endpoints, filtering, error handling, and SDKs.

Quick start

Get your first response in under a minute. Grab an API key from the dashboard, then make a request:

curl https://api.thepubdb.com/api/v1/pubs \
  -H "X-API-Key: $PUBDB_KEY"

The API returns JSON by default. Every response wraps results in a data array with a pagination object for page metadata.

{
  "success": true,
  "data": [
    {
      "id": "pub_0f1a3b",
      "name": "The Crown & Anchor",
      "city": "London",
      "area": "Soho",
      "postcode": "W1D 3HB",
      "country": "GB",
      "hasCaskAle": true,
      "hasSundayRoast": false
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 50,
    "total": 12418,
    "pages": 249,
    "hasNext": true,
    "hasPrev": false
  }
}
Base URL — all API key endpoints are relative to https://api.thepubdb.com/api/v1.

Authentication

Pass your API key in the X-API-Key header on every request to an authenticated endpoint.

X-API-Key: pk_developer_xxxx····

Tiers

FREEpk_free_*

Access to core list and detail endpoints. Limited monthly quota.

DEVELOPERpk_developer_*

Unlocks geo search, stats, and a higher monthly quota.

Keep keys secret. Never expose API keys in client-side code or public repositories. Use environment variables or a server-side proxy.

Endpoints

The API exposes five core endpoints. All return JSON and accept query parameters for filtering and pagination.

Endpoint reference

GET/api/v1/pubsList all pubs (paginated)
GET/api/v1/pubs/:idGet a single pub by ID
GET/api/v1/pubs/nearGeo search — Developer tier+
GET/api/v1/beer-typesList tracked beer types
GET/api/v1/contributors/leaderboardContributor leaderboard
GET/api/v1/statsDatabase stats — Developer tier+

Filtering & search

Filter pubs by amenities, location, or free-text search. All filters are query parameters on GET /api/v1/pubs.

Amenity filters

Pass any amenity as a boolean query parameter to include only matching pubs. Multiple filters are AND-ed together.

curl "https://api.thepubdb.com/api/v1/pubs?hasCaskAle=true" \
  -H "X-API-Key: $PUBDB_KEY"
isIndependenthasFoodhasCaskAlehasBeerGardenhasDogisFamilyFocusedisDogFriendlyisLateNighthasLiveMusichasPoolTablehasLeaderboardhasPremierLeagueisLgbtFriendly

Pagination

All list endpoints are paginated. Use page and limit query parameters. The pagination object in every response includes total, page, pages, hasNext, and hasPrev.

GET /pubs?page=2&limit=25

Default page size is 50. Pages are 1-indexed.

Rate limits

Rate limits are applied per API key across three windows: hourly, daily, and monthly.

Hobby
20 / hour · 200 / day · 1,000 / month
Developer
1,000 / hour · 10,000 / day · 100,000 / month
Business
5,000 / hour · 50,000 / day · 500,000 / month

Exceeded limits return a 429 Too Many Requests response. Check the X-RateLimit-Remaining header on any response to see your remaining quota.

Errors

All errors return a JSON body with a code and message field.

400bad_request
Malformed request or invalid parameter
401unauthorized
Missing or invalid API key
403forbidden
Key lacks permission for this action
404not_found
Resource does not exist
429rate_limited
Hourly, daily, or monthly quota exceeded
500server_error
Something went wrong on our end