Guide

Quickstart

The API answers JSON over HTTPS at https://api.golfdata.io. This page takes you from your first request to a full copy of a country that stays up to date.

Not writing code? You can download scorecards and whole countries as CSV for Excel or Google Sheets from your account page instead: see Download the data.

Your key

Every request needs your key in the Authorization header as Bearer <key>. Keep the key on your server: do not put it in a web page or an app that people can download. The examples read it from an environment variable.

Shell
export GOLFDATA_KEY="your-key"

Rather click than type? The playground sends real requests from your browser, no key needed.

No key yet? Create an account and get a free trial: a key that works on every endpoint, with 10 course requests in all, for any country. Lists and search are free, so you can find your courses first. More comes with a plan from $25 a month: see the pricing.

Building with an AI assistant? Your account page has a ready briefing to paste into Claude, ChatGPT or Cursor, or to save in your project's AGENTS.md.

Your first request

GET /v1/meta describes the current data release. Its data_version changes whenever any course or club changes, so it is the one value you need to store to know whether you are up to date.

curl https://api.golfdata.io/v1/meta \
  -H "Authorization: Bearer $GOLFDATA_KEY"

The later examples reuse headers (JavaScript) and session (Python) from here.

Get a course

A course is one playable layout. It holds par and stroke index per hole, and its tees with the length of each hole and the course rating and slope for men and women. Lengths are whole meters; add units=yards to also get distances_yd and total_yd on every tee.

curl "https://api.golfdata.io/v1/courses/gb-sct-kilmacolm-golf-club-kilmacolm-18?units=yards" \
  -H "Authorization: Bearer $GOLFDATA_KEY"

Missing values are null. When a value is not known, the field is null, never 0 and never estimated. A hole length can be null inside an otherwise complete list. Handle it rather than treating it as zero.

List and page

Lists are sorted by id and come in pages of up to 500. Each answer has paging.next_cursor: send it back as cursor, with the other parameters unchanged, until it is null. paging.total_count counts every match, not just the page.

curl "https://api.golfdata.io/v1/courses?country=gb-sct&limit=500" \
  -H "Authorization: Bearer $GOLFDATA_KEY"

# The next page: send paging.next_cursor from the answer as cursor
curl "https://api.golfdata.io/v1/courses?country=gb-sct&limit=500&cursor=NEXT_CURSOR" \
  -H "Authorization: Bearer $GOLFDATA_KEY"

Filter with country (for example es, or gb-eng for England), free text with q, and updated_since for courses changed after a date.

Find clubs

Search clubs by name. The search ignores case and accents and also looks in the other names a club is known by.

curl "https://api.golfdata.io/v1/clubs?q=kilmacolm" \
  -H "Authorization: Bearer $GOLFDATA_KEY"

Or give a point with lat and lng to get the clubs within radius_km (default 50), nearest first, each with its distance_km.

curl "https://api.golfdata.io/v1/clubs?lat=55.8895&lng=-4.6081&radius_km=25" \
  -H "Authorization: Bearer $GOLFDATA_KEY"

Moved and withdrawn ids

Ids are stable, but a course or club can be replaced, for example when two records turn out to be the same club. The old id then answers 301 with the new id in the Location header and in the body as alias_of. An id that is withdrawn without a replacement answers 410. fetch and requests follow redirects by default; with curl, add -L. When you store ids, update them from alias_of.

Stay up to date

A new release goes out at least once a quarter. Store data_version when you fetch. Later, ask what changed since then: you get the course and club ids that were added, changed and removed, and fetch only those again.

curl "https://api.golfdata.io/v1/changes?since=YOUR_STORED_DATA_VERSION" \
  -H "Authorization: Bearer $GOLFDATA_KEY"

A since the API does not know answers 400. Then fetch everything again, for example as a country file.

Fetch several courses at once

Get the courses that changed in one request: up to 100 ids, separated by commas. The answer lists the courses it found in the order you asked, and says which ids moved to a new id, were withdrawn or are unknown. Each course returned counts once, the same as fetching it alone.

curl "https://api.golfdata.io/v1/courses/batch?ids=gb-sct-kilmacolm-golf-club-kilmacolm-18,se-taby-banan-18" \
  -H "Authorization: Bearer $GOLFDATA_KEY"

Skip unchanged answers

Every 200 carries an ETag. Send it back in If-None-Match; when nothing changed you get 304 without a body.

curl -i https://api.golfdata.io/v1/meta \
  -H "Authorization: Bearer $GOLFDATA_KEY" \
  -H 'If-None-Match: "ETAG_FROM_THE_LAST_ANSWER"'

Download a whole country

GET /v1/export/{country} gives every course and every club of a country as one gzip-compressed JSON file, with the same objects as the single endpoints. The same release always gives the same bytes. It counts toward your quota as the number of courses in the file, the same as fetching each course.

curl -o gb-sct.json.gz https://api.golfdata.io/v1/export/gb-sct \
  -H "Authorization: Bearer $GOLFDATA_KEY"

gunzip gb-sct.json.gz

Green positions

GET /v1/courses/{id}/greens gives the position of the middle of the green for each hole of a course, as lat and lon (WGS 84), one entry per hole in playing order. A hole without a position has lat and lon null, and a course without any has greens null; a missing position is never estimated. greens_count on a course and in the course lists tells how many holes have one, so you can check before you ask. GET /v1/export/{country}/greens gives the green positions of a whole country as one gzip file.

Tees without a rating

By default a course is served with only the tees that have a course rating and slope, and a course without any such tee is left out. Add include_unrated=true to any GET to get those too. Every tee then says whether it is rated, and every course has a rating_status of rated, partial or unrated.

Errors and limits

Every error has the same shape, with a stable code and a readable message:

JSON
{
  "error": {
    "code": "bad_request",
    "message": "limit must be between 1 and 500"
  }
}

The codes are listed in the reference. Every answer has an X-Request-Id: quote it when you contact us.

What counts

You pay for course data, nothing else. A course answering 200 counts 1 toward your quota, and a country file counts the number of courses in it. Green positions count on their own, on top of the course: 1 for a course that has any, and the number of courses in the file for a country. The plans have a quota per calendar month (UTC); the free trial has 10 course requests in all. Lists, search, clubs, changes and every 304 are free. Each answer says what it counted in X-Request-Cost and how much is left in X-Quota-Remaining; a used-up quota answers 429, and a used-up trial 403 plan_limit. Free calls have a limit per minute, so page through lists rather than hammering them.

Report a mistake

If a value looks wrong, tell us through the API. Say which course or club, what is wrong and, if you know it, where the right value can be seen. The report changes nothing by itself: we check it, and a fix appears in a later release.

curl https://api.golfdata.io/v1/reports \
  -H "Authorization: Bearer $GOLFDATA_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "course_id": "gb-sct-kilmacolm-golf-club-kilmacolm-18",
    "field": "tees[2].distances_yd[7]",
    "message": "Hole 8 from the gold tee differs from the club's current scorecard."
  }'

Versioning

Inside v1, new fields can appear in existing objects, and new endpoints, countries and optional parameters can be added. Ignore fields you do not recognise. Renaming or removing a field, or changing a unit or the meaning of a value, needs v2, which will be announced in advance. Changes to the contract are listed in the changelog.

Next: read the concepts to understand clubs, layouts, loops and tees, or go straight to the API reference.