> For the complete documentation index, see [llms.txt](https://guide.fariaedu.com/integrations-portal/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://guide.fariaedu.com/integrations-portal/managebac/recipes/retrieving-complete-student-academic-grades-via-api.md).

# Retrieving Complete Student Academic Grades via API

### Step 1: Identify Student's Enrollments

First, you need to determine which classes the student has attended. Use the student’s unique ID to retrieve their class memberships.

* 📡 Endpoint: `GET /v2/students/{id}/memberships`
* 📘 Documentation: <https://guide.fariaedu.com/integrations-portal/managebac+/public-rest-apis/v2p2/memberships#get-v2p2-students-id-memberships>

**Response Behavior:**\
The response will return **multiple membership records**, including all classes the student is or was enrolled in across academic years.

<figure><img src="/files/TA6pqOoOWqsjuXwlyigx" alt=""><figcaption></figcaption></figure>

**Goal:** \
Extract the list of `class_id` values for all academic years associated with that student.

### Step 2: Resolve the Term Range (The "In-Between" Terms)

Once you have identified the relevant class, you need to retrieve the list of academic terms associated with that class.

* 📡 Endpoint: `GET /v2/classes/{class_id}/terms`
* 📘 Documentation: <https://guide.fariaedu.com/integrations-portal/managebac+/public-rest-apis/v2p2/classes#get-v2p2-classes-id-terms>

**The Logic:** \
You must provide a valid `class_id` The endpoint will return a list of terms that are applicable to that specific class. These terms represent the academic periods during which the class was active and for which assessments and grades may exist.

The returned `term_id` values should then be used in subsequent steps (for example, when fetching term grades or other term-based summaries). This ensures that all grade-related data is queried only for the correct academic periods linked to the class.

<figure><img src="/files/rVQ1dA2VrlDyT7mMIXkb" alt=""><figcaption></figcaption></figure>

**Goal:** \
Determine the relevant `term_id` values for each class, which will be used in subsequent steps to fetch term grades and tasks.

### Step 3: Retrieve Term Grades

Once you have the list of classes and their corresponding terms, you need to fetch the summarized (final) grades for each term.

* 📡 Endpoint: `GET /v2/classes/{class_id}/assessments/term/{term_id}/term-grades`
* 📘 Documentation: <https://guide.fariaedu.com/integrations-portal/managebac+/public-rest-apis/v2p2/coursework?ask=Retrieve+Term+Grades#get-v2p2-classes-class_id-assessments-term-term_id-grades>

**Response Behavior:**\
The response will return **multiple records**, including term grade data for **all students who are members of the class** for the given term. At this stage, the endpoint does not support filtering by `student_id`, so client-side filtering is required.

**The Logic:**\
You must iterate (loop) through every `class_id` identified in Step 1 and combine them with the relevant `term_id` values resolved earlier. From the response, filter the results by the specific `student_id` to determine the final academic standing of that student for each term.

**Goal:**\
Extract the final academic standing for the specific student in each term.

### Step 4: Drill Down into Individual Task Grades

To retrieve more granular assessment data (such as assignments, tests, and homework), you need to fetch the tasks associated with each class.&#x20;

1. **Get tasks for a class:** \
   Once you have the list of relevant classes, you need to retrieve all tasks assigned to each class.

* 📡 Endpoint: `GET /v2/classes/{class_id}/tasks`
* 📘 Documentation: <https://guide.fariaedu.com/integrations-portal/managebac+/public-rest-apis/v2p2/coursework#get-v2p2-classes-id-tasks>

{% hint style="info" %}
You can use the `term_id` query parameter to limit the results to a specific term.
{% endhint %}

**Response Behavior:**\
This endpoint returns **all tasks for the class**, regardless of student.

<figure><img src="/files/3MXVbTp3us0NZHYLo3Xw" alt=""><figcaption></figcaption></figure>

**Goal:**\
Identify all tasks that are relevant to the student’s classes and terms.

2. **Filter Task Grades by Student:**\
   For every task returned, you must fetch the list of students associated with that task.

* 📡 Endpoint: `GET /v2/classes/{class_id}/tasks/{task_id}/students`
* 📘 Documentation: <https://guide.fariaedu.com/integrations-portal/managebac+/public-rest-apis/v2p2/coursework#get-v2p2-classes-class_id-tasks-id-students>

**The Logic:**\
You must iterate through each task and filter the response by the specific `student_id` to extract the individual grade or score for that assignment.

**Response Behavior:**\
The response will include **multiple student records**, representing all students assigned to that task along with their respective grades or scores.

***

#### Best Practice: Automating Data Retrieval

Since this process involves many API calls, it is highly recommended to handle this programmatically using a script rather than manual execution. A script can automate the loops through classes and terms, merging the results into a single JSON report for the student.
