Challenges
Endpoints for managing and viewing challenges in the application. These endpoints allow users to view available challenges and get detailed information about specific challenges.
List Challenges
Get a list of all available challenges. The list includes both active challenges and challenges the user has subscribed to, along with their subscription status and statistics.
Endpoint
- Method: GET
- URL:
/api/challenges
Request Headers
| Header | Value | Required |
|---|---|---|
| Accept | application/json | Yes |
| Authorization | Bearer YOUR_API_TOKEN | Yes |
Success Response
{
"success": true,
"message": "تم جلب البيانات بنجاح",
"data": [
{
"id": 1,
"name": "30 Days Challenge",
"description": "Challenge description",
"can_resubscribe": true,
"statistics": {
"completed": 150,
"active": 50,
"subscribed": 300
},
"subscription_status": "not_subscribed",
"subscription_id": null,
"notification_times": [],
"is_vip": true,
"can_access": false
}
],
"status_code": 200
}
Error Response
Unauthorized (401)
{
"success": false,
"message": "Unauthenticated",
"data": null,
"status_code": 401
}
View Challenge Details
Get detailed information about a specific challenge, including its subscription status and statistics.
Endpoint
- Method: GET
- URL:
/api/challenges/{id}
Request Headers
| Header | Value | Required |
|---|---|---|
| Accept | application/json | Yes |
| Authorization | Bearer YOUR_API_TOKEN | Yes |
URL Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| id | integer | Yes | ID of the challenge to view |
Success Response
{
"success": true,
"message": "تم جلب البيانات بنجاح",
"data": {
"id": 1,
"name": "30 Days Challenge",
"description": "Challenge description",
"can_resubscribe": true,
"statistics": {
"completed": 150,
"active": 50,
"subscribed": 300
},
"subscription_status": "not_subscribed",
"subscription_id": null,
"notification_times": [],
"is_vip": true,
"can_access": false
},
"status_code": 200
}
Error Responses
Unauthorized (401)
{
"success": false,
"message": "Unauthenticated",
"data": null,
"status_code": 401
}
Challenge Not Found (404)
{
"success": false,
"message": "تم جلب البيانات بنجاح",
"data": null,
"status_code": 404
}
Example Implementation Flow
Listing and Viewing Challenges
- Get the user's API token from storage
- Make GET request to
/api/challengesfor the list - Upon success:
- Display list of available challenges
- Show challenge details (name, description)
- Show subscription status for each challenge
- Display statistics if visible
- Mark VIP challenges appropriately
- For viewing specific challenge:
- Get challenge ID from route/state
- Make GET request to
/api/challenges/{id} - Display detailed challenge information
- Show subscription options if not subscribed
- Display progress if subscribed