Errors
Every error has the same JSON shape, a stable code, and a link back to this page.
When a request fails, the API answers with an HTTP status from the 4xx or 5xx range and a JSON body with one error object. Branch on error.code, not on the message: codes are stable, messages may be reworded.
{
"error": {
"type": "authentication_error",
"code": "invalid_api_key",
"message": "The API key is not valid.",
"param": null,
"request_id": "req_6f1c2b8e3d4a4f5b9c6d7e8f",
"doc_url": "https://developers.newjune.co/errors#invalid_api_key"
}
}| Field | Description |
|---|---|
type | The broad category. See error types. |
code | A stable, specific code. Every code is listed below. |
message | A sentence for people. Safe to log, not meant for program logic. |
param | The query parameter at fault, when there is one. Otherwise null. |
request_id | The id of this request, also sent as the Request-Id header. Include it when you contact support. |
doc_url | A link to this code's entry on this page. |
Handling errors
Retry only what can succeed on retry: 429 after waiting for Retry-After, and 500 or 503 with exponential backoff. Every 400, 401, 403, and 404 needs a change to the request or the key first.
curl -s "https://data.newjune.co/v1/rounds?limit=500" \
-H "Authorization: Bearer $NEW_JUNE_API_KEY"
# {"error":{"type":"invalid_request_error","code":"invalid_query_parameter","param":"limit",...}}const response = await fetch('https://data.newjune.co/v1/rounds?limit=25', {
headers: { Authorization: `Bearer ${process.env.NEW_JUNE_API_KEY}` },
});
if (!response.ok) {
const { error } = await response.json();
switch (error.type) {
case 'rate_limit_error':
// Wait for Retry-After seconds, then retry.
break;
case 'api_error':
// Retry with exponential backoff.
break;
default:
// Fix the request or the key; retrying will fail the same way.
throw new Error(`${error.code}: ${error.message} (${error.request_id})`);
}
}import os
import requests
response = requests.get(
"https://data.newjune.co/v1/rounds",
params={"limit": 25},
headers={"Authorization": f"Bearer {os.environ['NEW_JUNE_API_KEY']}"},
timeout=30,
)
if not response.ok:
error = response.json()["error"]
if error["type"] == "rate_limit_error":
pass # Wait for Retry-After seconds, then retry.
elif error["type"] == "api_error":
pass # Retry with exponential backoff.
else:
raise RuntimeError(f"{error['code']}: {error['message']} ({error['request_id']})")A few rules hold for every endpoint:
- An id that belongs to another account returns the same
404 resource_not_foundas an id that does not exist, so ids reveal nothing about other players. - Unknown paths under
/v1return401until you send a valid key, then404 route_not_found. - Methods other than
GET,HEAD, andOPTIONSreturn405 method_not_allowedwith anAllowheader. - Internal details never appear in a response. A
500carries only arequest_id.
Error types
| Type | Meaning |
|---|---|
invalid_request_error | The request is wrong in a way you can fix before retrying. |
authentication_error | The API key is missing or cannot be used. |
permission_error | The key is valid but may not do this. |
not_found_error | Nothing exists at this id or path for your account. |
rate_limit_error | You sent too many requests. Wait, then retry. |
api_error | Something failed on our side. Retry with backoff. |
Error codes
Every code the API can return. Codes are stable: new ones may be added, existing ones are never renamed or reused.
invalid_query_parameter
400invalid_request_errorMessage: A query parameter has an invalid value.
What to do: Check param for the parameter name and fix its value. Timestamps need a Z or an offset; ids are UUIDs; limit is 1 to 100.
unknown_query_parameter
400invalid_request_errorMessage: This endpoint does not accept that query parameter.
What to do: Remove the parameter or fix its spelling. Each endpoint accepts only the parameters listed on its reference page.
invalid_cursor
400invalid_request_errorMessage: The cursor is not valid. Use the next_cursor value from a previous response.
What to do: Pass next_cursor from the previous page exactly as returned, with the same filters. Do not build or edit cursors.
method_not_allowed
405invalid_request_errorMessage: This API is read only. Use GET.
What to do: Use GET. The API is read only.
missing_api_key
401authentication_errorMessage: No API key was provided. Send it as "Authorization: Bearer <key>".
What to do: Send the key in the Authorization header as Bearer <key>.
invalid_api_key
401authentication_errorMessage: The API key is not valid.
What to do: Check that you copied the whole key, including the nj_live_ prefix. If it is lost, create a new key.
api_key_revoked
401authentication_errorMessage: This API key has been revoked. Create a new key on the Developer page at newjune.co/golf/developer.
What to do: Create a new key on the Developer page and update your secret store.
api_key_expired
401authentication_errorMessage: This API key has expired. Create a new key on the Developer page at newjune.co/golf/developer.
What to do: Create a new key on the Developer page and update your secret store.
account_suspended
403permission_errorMessage: API access is suspended for this account.
What to do: Contact New June support. Retrying will not help.
insufficient_scope
403permission_errorMessage: This API key does not have the scope this endpoint needs.
What to do: Create a key that includes the scope listed on the endpoint’s reference page. Scopes cannot be added to an existing key.
resource_not_found
404not_found_errorMessage: No such resource.
What to do: Check the id. An id that belongs to another account returns this same error, by design.
no_current_focus_set
404not_found_errorMessage: There is no current focus set for this account.
What to do: There is no focus set in use right now. List focus sets to see past ones.
route_not_found
404not_found_errorMessage: No such endpoint.
What to do: Check the path against the API reference. Paths start with /v1/.
rate_limit_exceeded
429rate_limit_errorMessage: Too many requests. Wait until the time in Retry-After, then try again.
What to do: Wait for the number of seconds in Retry-After, then retry. Spread requests out to stay under your per-minute limit.
daily_limit_exceeded
429rate_limit_errorMessage: This account has reached its daily request limit. It resets at midnight UTC.
What to do: Stop until midnight UTC, when the daily count resets. Retry-After gives the seconds until then.
too_many_failed_attempts
429rate_limit_errorMessage: Too many requests with a missing or invalid API key. Try again shortly.
What to do: Fix the key you are sending, then wait for Retry-After before trying again.
internal_error
500api_errorMessage: Something went wrong on our side. Try again later.
What to do: Retry with exponential backoff. If it persists, contact support with the request_id.
service_unavailable
503api_errorMessage: The API is temporarily unavailable. Try again later.
What to do: Retry with exponential backoff. The API is down or paused for a short time.