Skip to main content
All endpoints are prefixed with /api/challenges. Responses use Content-Type: application/json. Creating a challenge requires an admin Bearer token.

GET /api/challenges

Return a paginated list of all challenges. Optionally filter by difficulty or search term.

Query parameters

page
integer
Page number for pagination. Defaults to 1.
limit
integer
Number of challenges per page. Defaults to 20, maximum 100.
difficulty
string
Filter by difficulty level. One of easy, medium, or hard.
Case-insensitive keyword search against challenge title and description. Maximum 100 characters.

Response — 200 OK

success
boolean
true on success.
data
array
Array of challenge objects.
pagination
object

Error responses

StatusCondition
400Invalid query parameters (e.g. unknown difficulty value)

Example

curl "http://localhost:3000/api/challenges?difficulty=easy&page=1&limit=10"

GET /api/challenges/nearby

Return challenges within a given radius of the provided GPS coordinates, sorted by distance ascending (closest first).

Query parameters

latitude
number
required
The user’s current latitude (-90 to 90).
longitude
number
required
The user’s current longitude (-180 to 180).
radius
number
Search radius in meters. Defaults to 5000. Maximum 50000.
page
integer
Page number. Defaults to 1.
limit
integer
Items per page. Defaults to 20, maximum 100.

Response — 200 OK

success
boolean
true on success.
data
array
Challenges within the specified radius, sorted by distance ascending.
pagination
object

Error responses

StatusCondition
400latitude or longitude missing, or values out of range

Example

curl "http://localhost:3000/api/challenges/nearby?latitude=35.3050&longitude=-120.6625&radius=1000"

GET /api/challenges/:id

Return a single challenge by its ID, including the total number of completions.

Path parameters

id
integer
required
The numeric ID of the challenge.

Response — 200 OK

success
boolean
true on success.
data
object

Error responses

StatusCondition
400id is not a valid integer
404No challenge found with that ID

Example

curl "http://localhost:3000/api/challenges/42"

POST /api/challenges

Create a new challenge. Returns the newly created challenge object.
Auth required: Yes, admin only — include Authorization: Bearer <accessToken>. The authenticated user must have the admin role.

Request body

title
string
required
Challenge title. 1–200 characters. Must be unique.
description
string
required
Challenge description. 1–1000 characters.
latitude
number
required
GPS latitude of the challenge location (-90 to 90).
longitude
number
required
GPS longitude of the challenge location (-180 to 180).
difficulty
string
required
One of easy, medium, or hard.
pointsReward
integer
required
Positive integer representing the aura points awarded on completion.

Response — 201 Created

success
boolean
true on success.
message
string
"Challenge created successfully"
data
object

Error responses

StatusCondition
400Validation error (missing field, out-of-range value, invalid difficulty)
401Missing or invalid Bearer token
403Authenticated user does not have the admin role
409A challenge with the same title already exists

Example

curl -X POST http://localhost:3000/api/challenges \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <accessToken>" \
  -d '{
    "title": "Sunset from the P1 Rooftop",
    "description": "Snap a photo at golden hour from the top of the P1 parking structure.",
    "latitude": 35.3005,
    "longitude": -120.6596,
    "difficulty": "medium",
    "pointsReward": 150
  }'

Build docs developers (and LLMs) love