DHTask API Documentation

Working Implementation: A production implementation using this API is available at dhtask.com.

DHTask Calculator Endpoint

POST https://api.dhtask.com/dhtcalc/

Headers

Content-Type: application/json
X-API-Key: [Your API Key]
API Access: To request an API key, please send an email to nick@dhtask.com with the following information: Once approved, you'll receive an API key that you must include in all requests.

Example Request

Send a POST request with the following JSON payload:

{
    "handicaps": [0.91, 0.95, 1.01, 1.02, 1.12, 1.29],
    "task": {
        "start": {
            "name": "Start Point",
            "lat": -35.91694931657839,
            "lon": 146.3216672683199,
            "radius": 10000,
            "elev": "531ft",
            "type": "line"
        },
        "turnpoints": [
            {
                "name": "Turnpoint 1",
                "lat": -35.591384934695306,
                "lon": 146.584998381584,
                "radius": 500,
                "variable": false,
                "type": "point",
                "elev": "512ft"
            },
            {
                "name": "Turnpoint 2",
                "lat": -35.08861812498515,
                "lon": 147.1141604573383,
                "radius": 500,
                "variable": true,
                "type": "point",
                "elev": "560ft"
            },
            {
                "name": "Turnpoint 3",
                "lat": -34.9336172270555,
                "lon": 146.30000190827582,
                "radius": 500,
                "variable": true,
                "type": "point",
                "elev": "428ft"
            },
            {
                "name": "Turnpoint 4",
                "lat": -35.98083207588561,
                "lon": 146.20028114639027,
                "radius": 500,
                "variable": false,
                "type": "point",
                "elev": "435ft"
            }
        ],
        "finish": {
            "name": "Finish Point",
            "lat": -35.98971815199605,
            "lon": 146.35749844070676,
            "type": "line",
            "radius": 3000,
            "elev": "459ft"
        }
    }
}

Example Response

The API will return a JSON response with calculated distances and turnpoint coordinates for each handicap value:

{
    "h_0.91": {
        "distance": 226.939,
        "finish": {
            "elev": "459ft",
            "lat": -35.98971815199605,
            "lon": 146.35749844070676,
            "name": "Finish Point",
            "radius": 3000,
            "type": "line",
            "variable": false
        },
        "start": {
            "elev": "531ft",
            "lat": -35.91694931657839,
            "lon": 146.3216672683199,
            "name": "Start Point",
            "radius": 10000,
            "variable": false
        },
        "turnpoints": [
            {
                "elev": "512ft",
                "lat": -35.59138488474558,
                "lon": 146.5849983504985,
                "name": "Turnpoint 1",
                "radius": 500,
                "variable": false
            },
            {
                "elev": "560ft",
                "lat": -35.213646622733044,
                "lon": 146.81430775940822,
                "name": "Turnpoint 2",
                "radius": 500,
                "variable": true
            },
            {
                "elev": "428ft",
                "lat": -35.1664227049397,
                "lon": 146.47942080363043,
                "name": "Turnpoint 3",
                "radius": 500,
                "variable": true
            },
            {
                "elev": "435ft",
                "lat": -35.98083204462462,
                "lon": 146.20028119387132,
                "name": "Turnpoint 4",
                "radius": 500,
                "variable": false
            }
        ]
    },
    // ... similar structure for other handicap values
}

JavaScript Example

fetch('https://api.dhtask.com/dhtcalc/', {
    method: 'POST',
    headers: {
        'Content-Type': 'application/json',
        'X-API-Key': '[Your API Key]'
    },
    body: JSON.stringify({
        "handicaps": [0.91, 0.95, 1.01, 1.02, 1.12, 1.29],
        "task": {
            // ... task data as shown above
        }
    })
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

Error Responses

The API may return the following error responses:

JSON Data Endpoint

GET https://json.dhtask.com/fetch/

Description

This endpoint provides public access to the same JSON data available on json.dhtask.com. The endpoint supports CORS (Cross-Origin Resource Sharing), allowing it to be accessed from any domain.

Headers

Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, OPTIONS
Access-Control-Allow-Headers: Content-Type, Authorization
Public Access: This endpoint is publicly accessible and does not require an API key. It can be used directly from any web application.

Example Usage

JavaScript fetch example:

fetch('https://json.dhtask.com/fetch/')
  .then(response => response.json())
  .then(data => console.log(data));