All tutorials
BeginnerPricing8 min read

Compare Green Fees

Filter clubs by country and max price, then fetch the full fee breakdown per club — including 9 different fee types.

Overview

The UK Golf API stores up to 9 fee types per club, each with an amount, currency, notes, and a confidence score indicating how reliably the data was extracted from the club's website.

Available fee types

fee_typeDescription
weekdayStandard weekday round
weekendSaturday & Sunday rate
twilightLate afternoon/evening rate
day_ticketAll-day play pass
juniorUnder 18s rate
seniorOver 65s rate
societyGroup society rate
winterWinter/off-peak rate
summerSummer/peak rate

Step 1 — Filter clubs by price

Use GET /clubs with max_green_fee to limit results to clubs whose lowest green fee is at or below your threshold. Combine with country to target a specific country.

GET /clubs?country=ENG&max_green_fee=50&sort=green_fee_asc&limit=20

Filter parameters:
  country        string  ENG | SCO | WAL | NIR
  max_green_fee  number  Maximum green fee amount (GBP)
  min_rating     number  Minimum Google rating (0-5)
  course_type    string  parkland | links | heathland | moorland
  has_driving_range  bool  true | false

Step 2 — Fetch detailed fees per club

The clubs list endpoint only returns a min_green_fee summary. For the full breakdown by type, call GET /clubs/{id}/green-fees.

{
  "data": [
    {
      "fee_type": "weekday",
      "amount": 35.00,
      "currency": "GBP",
      "notes": "18 holes",
      "confidence": 0.85
    },
    {
      "fee_type": "weekend",
      "amount": 45.00,
      "currency": "GBP",
      "notes": "18 holes, booking required",
      "confidence": 0.85
    },
    {
      "fee_type": "twilight",
      "amount": 22.00,
      "currency": "GBP",
      "notes": "After 3pm",
      "confidence": 0.80
    },
    {
      "fee_type": "junior",
      "amount": 15.00,
      "currency": "GBP",
      "confidence": 0.75
    }
  ]
}

Full example

JavaScript
async function compareGreenFees({ country = 'ENG', maxFee = 50 } = {}) {
  const params = new URLSearchParams({
    country,
    max_green_fee: maxFee,
    limit: 20,
    sort: 'green_fee_asc',
  });

  const res = await fetch(
    `https://uk-golf-api.vercel.app/clubs?${params}`,
    {
      headers: {
        'X-RapidAPI-Key': process.env.RAPIDAPI_KEY,
        'X-RapidAPI-Host': 'uk-golf-course-data-api.p.rapidapi.com',
      }
    }
  );

  const { data } = await res.json();

  // For each club, fetch detailed green fees
  const enriched = await Promise.all(
    data.slice(0, 5).map(async (club) => {
      const feesRes = await fetch(
        `https://uk-golf-api.vercel.app/clubs/${club.id}/green-fees`,
        { headers: { 'X-RapidAPI-Key': process.env.RAPIDAPI_KEY } }
      );
      const { data: fees } = await feesRes.json();
      return { ...club, fees };
    })
  );

  return enriched;
}

const results = await compareGreenFees({ country: 'SCO', maxFee: 40 });
results.forEach(club => {
  const weekday = club.fees.find(f => f.fee_type === 'weekday');
  const weekend = club.fees.find(f => f.fee_type === 'weekend');
  console.log(`${club.name}`);
  console.log(`  Weekday: £${weekday?.amount ?? 'N/A'}`);
  console.log(`  Weekend: £${weekend?.amount ?? 'N/A'}`);
});
Python
import requests

API_KEY = "YOUR_API_KEY"
HEADERS = {
    "X-RapidAPI-Key": API_KEY,
    "X-RapidAPI-Host": "uk-golf-course-data-api.p.rapidapi.com",
}
BASE = "https://uk-golf-api.vercel.app"

def compare_green_fees(country="ENG", max_fee=50, limit=20):
    # Step 1: Get clubs filtered by country and max green fee
    res = requests.get(
        f"{BASE}/clubs",
        params={
            "country": country,
            "max_green_fee": max_fee,
            "limit": limit,
            "sort": "green_fee_asc",
        },
        headers=HEADERS,
    )
    clubs = res.json()["data"]

    # Step 2: Fetch detailed green fees for each club
    results = []
    for club in clubs[:5]:
        fees_res = requests.get(
            f"{BASE}/clubs/{club['id']}/green-fees",
            headers=HEADERS,
        )
        fees = fees_res.json().get("data", [])
        results.append({**club, "fees": fees})

    return results

results = compare_green_fees(country="SCO", max_fee=40)
for club in results:
    fees_by_type = {f["fee_type"]: f["amount"] for f in club["fees"]}
    print(f"{club['name']}")
    print(f"  Weekday: £{fees_by_type.get('weekday', 'N/A')}")
    print(f"  Weekend: £{fees_by_type.get('weekend', 'N/A')}")

Working with confidence scores

Each fee has a confidence value between 0 and 1. This reflects how reliably the data was extracted from the club's website:

  • ≥ 0.8 — High confidence, extracted directly from a dedicated green fees page
  • 0.6–0.8 — Medium confidence, inferred from price lists
  • < 0.6 — Low confidence, treat as approximate

Next steps