Skip to main content
Retrieve detailed information about all students enrolled in the educator’s courses, including purchase dates and course details. This endpoint provides a complete purchase history across all courses.

Authentication

Response

Response Example

Data Collection Process

  1. Fetch Educator Courses: Retrieves all courses created by the authenticated educator
  2. Extract Course IDs: Creates an array of course IDs for purchase lookup
  3. Query Purchases:
    • Finds all purchases matching the educator’s course IDs
    • Filters for only completed purchases
    • Populates student information (name and imageUrl)
    • Populates course information (courseTitle)
  4. Transform Data: Maps purchase records to enrollment objects containing:
    • Student details
    • Course title
    • Purchase date (from createdAt field)

Key Differences from Dashboard Endpoint

While the /dashboard endpoint provides aggregated statistics, this endpoint offers:
  • Purchase timestamps: Exact date and time of each enrollment
  • Individual purchase records: Each purchase is a separate entry
  • Complete purchase history: All completed transactions, not just enrolled students
  • Chronological data: Useful for tracking enrollment trends over time

Use Cases

  • Display detailed student enrollment tables
  • Track enrollment trends and purchase history
  • Generate reports on course purchases
  • Show recent student enrollments
  • Export enrollment data for analysis
  • Identify popular courses by purchase frequency

Filtering and Sorting

The endpoint currently returns all completed purchases. To filter or sort the data:

Error Response

Notes

  • Only completed purchases are included (pending or failed purchases are excluded)
  • Students who purchased multiple courses will have multiple entries
  • The purchaseDate field uses the createdAt timestamp from the Purchase model
  • Student information is populated from the User collection via the userId reference
  • Course information is populated from the Course collection via the courseId reference

Performance Considerations

  • Uses MongoDB population to efficiently join related collections
  • Filters at the database level for optimal performance
  • Returns only necessary student fields (name, imageUrl) to reduce payload size