Skip to main content

Errors and troubleshooting

Handle API errors​

from Analog_WakaTime_SDK.exceptions import ApiException

try:
profile = await profile_api.main_api_v1_get_my_profile_info_get()
except ApiException as error:
if error.status == 401:
print("The token is missing, invalid, disabled, or expired")
elif error.status == 403:
print("The account or subscription does not allow this operation")
elif error.status == 429:
print("Rate limit reached; retry after the response window")
else:
print(error.status, error.body or error.reason)

Common statuses​

StatusMeaningAction
400invalid request model or field valuecorrect the request before retrying
401missing, invalid, disabled, or expired tokenverify or rotate the token
403account or subscription does not allow the requestuse an allowed history period or upgrade access
404resource or token UUID does not existverify the identifier
409operation conflicts with current stateinspect the response body
429gateway rate limit reachedretry after the rate-limit window
5xxtemporary gateway or service failureretry with exponential backoff

Access HTTP metadata​

Use the _with_http_info variant of a generated operation:

response = await profile_api.main_api_v1_get_my_profile_info_get_with_http_info()

print(response.status_code)
print(response.headers)
print(response.data.to_dict())

Set timeouts​

profile = await profile_api.main_api_v1_get_my_profile_info_get(
_request_timeout=(5, 30),
)

Use a single number for a total timeout or a tuple for connection and read timeouts.

The SDK requests localhost​

The installed package was generated from an older OpenAPI document. Reinstall the latest SDK with --force-reinstall --no-cache-dir. A current production package reads the server URL embedded during generation.

A documented method is missing​

The documentation and package must come from the same release. Force-reinstall the newest SDK if Python raises AttributeError for a documented operation.

403 subscription-required​

Free accounts can request no more than the latest seven days. Use period="week" where the SDK operation exposes a history-period argument.

Logging safety​

  • never log Configuration.access_token
  • never include an API token in an exception message
  • response bodies can contain private profile and activity data
  • redact authorization headers in HTTP debug logging