Get Usage
curl --request GET \
--url https://api.happenstance.ai/v1/usage \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.happenstance.ai/v1/usage"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.happenstance.ai/v1/usage', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"balance_credits": 123,
"has_credits": true,
"purchases": [
{
"id": "<string>",
"credits": 123,
"purchased_at": "<string>"
}
],
"usage": [
{
"id": "<string>",
"credit_used": 123,
"created_at": "<string>",
"resource_id": "<string>",
"resource_type": "<string>"
}
],
"auto_reload": {
"enabled": true,
"threshold_credits": 123,
"reload_credit_amount": 123,
"last_reload_at": "<string>"
}
}{
"title": "<string>",
"status": 123,
"type": "https://developer.happenstance.ai/api-reference/introduction#error-response-format",
"detail": "<string>",
"instance": "<string>"
}{
"title": "<string>",
"status": 123,
"type": "https://developer.happenstance.ai/api-reference/introduction#error-response-format",
"detail": "<string>",
"instance": "<string>"
}{
"title": "<string>",
"status": 123,
"type": "https://developer.happenstance.ai/api-reference/introduction#error-response-format",
"detail": "<string>",
"instance": "<string>"
}{
"title": "<string>",
"status": 123,
"type": "https://developer.happenstance.ai/api-reference/introduction#error-response-format",
"detail": "<string>",
"instance": "<string>"
}{
"title": "<string>",
"status": 123,
"type": "https://developer.happenstance.ai/api-reference/introduction#error-response-format",
"detail": "<string>",
"instance": "<string>"
}{
"title": "<string>",
"status": 123,
"type": "https://developer.happenstance.ai/api-reference/introduction#error-response-format",
"detail": "<string>",
"instance": "<string>"
}{
"title": "<string>",
"status": 123,
"type": "https://developer.happenstance.ai/api-reference/introduction#error-response-format",
"detail": "<string>",
"instance": "<string>"
}{
"title": "<string>",
"status": 123,
"type": "https://developer.happenstance.ai/api-reference/introduction#error-response-format",
"detail": "<string>",
"instance": "<string>"
}{
"title": "<string>",
"status": 123,
"type": "https://developer.happenstance.ai/api-reference/introduction#error-response-format",
"detail": "<string>",
"instance": "<string>"
}API Reference
Get Usage
Get credit balance, purchase history, usage history, and Auto Reload settings for the authenticated user.
GET
/
v1
/
usage
Get Usage
curl --request GET \
--url https://api.happenstance.ai/v1/usage \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.happenstance.ai/v1/usage"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://api.happenstance.ai/v1/usage', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"balance_credits": 123,
"has_credits": true,
"purchases": [
{
"id": "<string>",
"credits": 123,
"purchased_at": "<string>"
}
],
"usage": [
{
"id": "<string>",
"credit_used": 123,
"created_at": "<string>",
"resource_id": "<string>",
"resource_type": "<string>"
}
],
"auto_reload": {
"enabled": true,
"threshold_credits": 123,
"reload_credit_amount": 123,
"last_reload_at": "<string>"
}
}{
"title": "<string>",
"status": 123,
"type": "https://developer.happenstance.ai/api-reference/introduction#error-response-format",
"detail": "<string>",
"instance": "<string>"
}{
"title": "<string>",
"status": 123,
"type": "https://developer.happenstance.ai/api-reference/introduction#error-response-format",
"detail": "<string>",
"instance": "<string>"
}{
"title": "<string>",
"status": 123,
"type": "https://developer.happenstance.ai/api-reference/introduction#error-response-format",
"detail": "<string>",
"instance": "<string>"
}{
"title": "<string>",
"status": 123,
"type": "https://developer.happenstance.ai/api-reference/introduction#error-response-format",
"detail": "<string>",
"instance": "<string>"
}{
"title": "<string>",
"status": 123,
"type": "https://developer.happenstance.ai/api-reference/introduction#error-response-format",
"detail": "<string>",
"instance": "<string>"
}{
"title": "<string>",
"status": 123,
"type": "https://developer.happenstance.ai/api-reference/introduction#error-response-format",
"detail": "<string>",
"instance": "<string>"
}{
"title": "<string>",
"status": 123,
"type": "https://developer.happenstance.ai/api-reference/introduction#error-response-format",
"detail": "<string>",
"instance": "<string>"
}{
"title": "<string>",
"status": 123,
"type": "https://developer.happenstance.ai/api-reference/introduction#error-response-format",
"detail": "<string>",
"instance": "<string>"
}{
"title": "<string>",
"status": 123,
"type": "https://developer.happenstance.ai/api-reference/introduction#error-response-format",
"detail": "<string>",
"instance": "<string>"
}Authorizations
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Response
Successful Response
Response from GET /v1/usage - retrieving user's credit purchases and usage history.
Current credit balance (can be negative if credits consumed without sufficient balance)
Whether the user has credits available (balance > 0)
List of credit purchases, most recent first
Show child attributes
Show child attributes
List of credit usage records, most recent first
Show child attributes
Show child attributes
Auto Reload settings if configured
Show child attributes
Show child attributes
⌘I
