Skip to main content

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

HeaderValueRequired
Acceptapplication/jsonYes
AuthorizationBearer YOUR_API_TOKENYes

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

HeaderValueRequired
Acceptapplication/jsonYes
AuthorizationBearer YOUR_API_TOKENYes

URL Parameters

ParameterTypeRequiredDescription
idintegerYesID 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

  1. Get the user's API token from storage
  2. Make GET request to /api/challenges for the list
  3. 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
  4. 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