5. API Usage

5.1: Retrieve a List of Courses

In this section, we will walk you through the process of retrieving a list of golf courses using the Golfdigg OTA API.

This is a fundamental operation that will help you access information about available golf courses in Thailand.

5.1.1: Endpoint

To retrieve a list of courses, you will use the following endpoint:

  • Endpoint: /api/v1/ext/course
  • Method: GET

5.1.2: Request Parameters

You can include the following parameters in your API request:

  • Authorization (Header): Use Basic Authentication with your API credentials.
  • Content-Type (Header): Set to application/json.

5.1.3: Response Format

interface GolfClub {
  id: string;
  name: string;
  nameTH: string;
  place: string;
  status: string;
  type: string;
  timeZone: string;
  lat: string;
  lon: string;
  images: string[];
  openingHours: string;
  address: string;
  website: string;
}
FieldTypeDescription
idstringUnique identifier for the golf club.
namestringName of the golf club.
nameTHstringThai name of the golf club.
placestringLocation of the golf club.
statusstringCurrent status of the golf club (e.g., OPEN).
typestringType of the golf club (e.g., NORMAL).
timeZonestringTime zone of the golf club.
latstringLatitude of the golf club location.
lonstringLongitude of the golf club location.
imagesstring[]Array of image URLs associated with the club.
openingHoursstringOperating hours of the golf club.
addressstringAddress of the golf club.
websitestringWebsite URL of the golf club.
minPriceWeekdayintMinimum price for weekday.
minWeekendPriceintMinimum price for weekend.

5.1.4: Request Example

Here's an example of how to structure your API request to retrieve a list of golf courses:

GET /api/v1/ext/course
Host: ota-api.golfdigg.com
Authorization: Basic base64_encoded(apiKey)
Content-Type: application/json

5.1.5: Response Example

The API will respond with a list of golf courses in the specified format (e.g., JSON). Here's a sample response:

[
   {
      "id":"5c9c8252ef0ab53dcf12e8d2",
      "name":"331 GOLF CLUB-test",
      "nameTH":"สนามกอล์ฟ 331 กอล์ฟ คลับ",
      "place":"Amphoe Plaeng Yao, Chachoengsao",
      "status":"OPEN",
      "type":"NORMAL",
      "timeZone":"Asia/Bangkok",
      "lat":"13.654125",
      "lon":"101.277686",
      "images":[
         "https://storage.googleapis.com/gds/pro/co/5eae4810ef0a2b6e681b0514",
         "https://storage.googleapis.com/gds/pro/co/5e5cb2cbef0a66dd36c1788c",
         "https://storage.googleapis.com/gds/pro/co/5e5cb2cbef0a66dd36c1788f",
         "https://storage.googleapis.com/gds/pro/co/5c9c8252ef0ab53dcf12e8ce"
      ],
      "openingHours":"07:00 - 20:00",
      "address":"89 Tambon Hua Samrong, Amphoe Plaeng Yao, Chang Wat Chachoengsao 24190",
      "website":"https://www.facebook.com/pages/category/Golf-Course---Country-Club/331-Golf-Club-691075080978424/",
      "minPriceWeekday": 49900,
      "minPriceWeekend": 79900
   }
]

5.1.6: Handling Errors

In case of errors, you may receive an error response with a relevant HTTP status code and an error message. Handle errors based on the information provided in the response.