API Reference
Explore the LearnFlow API to integrate learning management capabilities into your applications. Our RESTful API provides comprehensive access to courses, students, enrollments, and more.
Introduction
The LearnFlow API uses standard HTTP methods and returns JSON responses. All requests must be made over HTTPS. Calls made over plain HTTP will fail.
https://api.learnflow.com/v2
Example Request
curl -X GET https://api.learnflow.com/v2/courses \n -H "Authorization: Bearer YOUR_API_KEY" \n -H "Content-Type: application/json"
Authentication
LearnFlow uses API keys to authenticate requests. You can view and manage your API keys in the Developer Dashboard. API keys carry many privileges, so be sure to keep them secure.
Authenticating Requests
Include your API key in the request header using Bearer token authentication:
Authorization: Bearer sk_live_your_api_key_here
Keys are scoped to either Production (sk_live_...) or Sandbox (sk_test_...) environments. Ensure you are using the correct key for your environment.
Courses API
The Courses API allows you to manage your course catalog, including creating, updating, and retrieving course details.
Returns a list of your courses. The courses are returned sorted by creation date, with the most recently created courses appearing first.
Query Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| limit | integer | Optional | A limit on the number of objects to be returned. Limit can range between 1 and 100. |
| category | string | Optional | Filter courses by category slug (e.g., 'development', 'design'). |
| status | string | Optional | Filter by course status: 'draft', 'published', 'archived'. |
Response
{
"object": "list",
"data": [
{
"id": "crs_1MqS4eEYv4r0c9Pn2a3b4c5d",
"object": "course",
"title": "Advanced React Patterns",
"description": "Master advanced React concepts including hooks, context, and performance optimization.",
"category": "development",
"instructor": "Jane Doe",
"price": 49.99,
"currency": "USD",
"status": "published",
"enrollment_count": 1245,
"created_at": "2023-10-15T14:32:00Z"
}
],
"has_more": true,
"total_count": 156
}
Creates a new course. The course will be created in 'draft' status by default.
Request Body
| Name | Type | Required | Description |
|---|---|---|---|
| title | string | Required | The title of the course. |
| description | string | Required | A detailed description of the course content. |
| price | number | Required | The price in the specified currency. |
| currency | string | Required | Three-letter ISO currency code (e.g., 'USD', 'EUR'). |
| instructor_id | string | Optional | ID of the instructor associated with the course. |
Enrollments API
Enrolls a student in a course. This will also process payment if the course is not free.
Request Body
{
"student_id": "stu_9Z8x7Y6w5V4u3T2s1R0q",
"course_id": "crs_1MqS4eEYv4r0c9Pn2a3b4c5d",
"payment_method_id": "pm_card_visa_4242",
"send_welcome_email": true
}
Response
{
"id": "enr_3K2j1I0h9G8f7E6d5C4b",
"object": "enrollment",
"status": "active",
"student_id": "stu_9Z8x7Y6w5V4u3T2s1R0q",
"course_id": "crs_1MqS4eEYv4r0c9Pn2a3b4c5d",
"enrolled_at": "2024-03-15T10:23:45Z",
"payment": {
"status": "succeeded",
"amount": 4999,
"currency": "usd"
}
}
Errors
LearnFlow uses conventional HTTP status codes to indicate the success or failure of an API request. Codes in the 2xx range indicate success. Codes in the 4xx range indicate client errors (e.g., missing required parameter, invalid parameter). Codes in the 5xx range indicate server errors.
| Code | Meaning | Description |
|---|---|---|
| 400 | Bad Request | The request was malformed or missing required parameters. |
| 401 | Unauthorized | Your API key is missing or invalid. |
| 403 | Forbidden | Your API key does not have permission to perform the action. |
| 404 | Not Found | The requested resource does not exist. |
| 429 | Too Many Requests | Rate limit exceeded. Wait before making more requests. |
| 500 | Server Error | Something went wrong on LearnFlow's end. |
Rate Limits
To ensure fair usage and system stability, LearnFlow applies rate limits to the API:
- Standard Plan: 60 requests per minute
- Pro Plan: 300 requests per minute
- Enterprise: Custom limits based on agreement
Rate limit information is included in the response headers: X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset.