# How to Integrate Retool with Khan Academy API

- Tool: Retool
- Difficulty: Intermediate
- Time required: 30 minutes
- Last updated: April 2026

## TL;DR

Khan Academy's public REST API was deprecated and shut down. For organizations using Khan Academy for Teams or education programs, you can access learning progress data through exported CSV reports or Khan Academy's unofficial data endpoints. Build a student learning progress dashboard in Retool by importing exported Khan Academy data into a database or Retool Database, then querying it for custom analytics and progress tracking.

## Build a Khan Academy Learning Progress Dashboard in Retool

Khan Academy's public API (api.khanacademy.org) was officially deprecated and shut down, making direct API-based integration with Retool no longer possible for new implementations. However, organizations running education programs, corporate training, or school district tech stacks still need ways to track and report on Khan Academy learning progress alongside other operational data. Retool can serve as the analytics and reporting layer using Khan Academy's data export capabilities as the data source.

Khan Academy for Teams and Khan Academy for Schools (the enterprise tiers) provide CSV export functionality from their admin dashboards. These exports include student identifiers, exercise completion status, mastery levels, time spent, and course progress — all the data needed to build meaningful progress dashboards. By importing these exports into Retool Database (a built-in PostgreSQL-compatible database available in all Retool plans) or an existing PostgreSQL or MySQL database, you can query the data directly from Retool and build customized progress tracking panels.

For organizations in approved district partnerships, Khan Academy for Schools may provide direct data access through their district data portal or SIS (Student Information System) integrations. In those cases, a REST API Resource connection may be available using credentials provided by Khan Academy's enterprise team. This guide covers both the CSV-import path (available to all organizations) and notes the district partnership path where applicable.

## Before you start

- A Khan Academy for Teams, Khan Academy for Schools, or Khan Academy for Districts account with admin/teacher access to export progress reports
- Access to Retool Database (built into all Retool plans) or a connected PostgreSQL/MySQL database for storing imported data
- The Khan Academy progress export CSV file(s) from your admin dashboard
- A Retool account with permission to create Resources and manage Retool Database
- Basic familiarity with SQL for querying the imported data

## Step-by-step guide

### 1. Export student progress data from Khan Academy

Log in to your Khan Academy teacher or admin account. For Khan Academy for Teams, navigate to your Teacher Dashboard (khanacademy.org/teacher/dashboard) and select the class you want to report on. Click on the 'Progress' tab to see the class's exercise and mastery data. Look for an Export or Download option — Khan Academy provides CSV exports of student progress data from the progress report views. The exact export path varies by interface version: look for a download icon or 'Export to CSV' link in the top-right of the progress table. The exported CSV typically includes columns for student email or anonymized ID, exercise name, skill domain, mastery level (Not Started / Attempted / Familiar / Proficient / Mastered), number of correct answers, number of problems attempted, time spent (seconds), and last activity date. For Khan Academy for Schools with district-level access, additional data exports may be available from the district admin portal including cross-class progress and SIS-matched student identifiers. Download the CSV and open it in a spreadsheet application to verify the column structure before importing into Retool. Note the column names exactly as they will become the table schema in Retool Database.

**Expected result:** You have a CSV file with student progress data including student identifiers, exercise names, mastery levels, and time spent. You know the column names and data types.

### 2. Create a table in Retool Database and import the CSV

Navigate to your Retool workspace and click on the 'Database' section in the left sidebar (or navigate to retool.com/database). Retool Database is a managed PostgreSQL instance included in all Retool plans with 5GB of storage. Click 'Create table' and name it 'khan_progress'. You can either define the schema manually by adding columns one by one, or use Retool Database's CSV import feature to auto-detect the schema from your export file. To use CSV import: in the Retool Database interface, click Import → Upload CSV, and select your Khan Academy export file. Retool will preview the detected columns and suggest data types — review these carefully. String columns like student_email, exercise_name, skill_domain, and mastery_level should be VARCHAR or TEXT. Numeric columns like correct_count, attempted_count, and time_spent_seconds should be INTEGER or BIGINT. Date columns like last_activity should be TIMESTAMP or DATE. Click 'Import' to create the table and populate it with the CSV data. After the initial import, note the table schema so you can append future exports consistently. Consider adding an 'imported_at' column (TIMESTAMP, default CURRENT_TIMESTAMP) to track when each batch of data was imported, enabling you to filter to the most recent import when multiple exports are loaded.

```
-- SQL: Create khan_progress table in Retool Database (or your PostgreSQL)
CREATE TABLE IF NOT EXISTS khan_progress (
  id SERIAL PRIMARY KEY,
  student_email VARCHAR(255),
  student_id VARCHAR(100),
  exercise_name VARCHAR(500),
  skill_domain VARCHAR(255),
  mastery_level VARCHAR(50),
  correct_count INTEGER DEFAULT 0,
  attempted_count INTEGER DEFAULT 0,
  time_spent_seconds INTEGER DEFAULT 0,
  last_activity TIMESTAMP,
  class_name VARCHAR(255),
  course_name VARCHAR(255),
  imported_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
```

**Expected result:** The khan_progress table exists in Retool Database with imported rows visible in Retool Database's spreadsheet view.

### 3. Create a Retool Database Resource and build progress queries

In Retool's Resources tab, click Add Resource and select Retool Database from the list — it appears as a built-in resource pre-configured for your workspace's Retool Database instance. Name it 'Khan Academy Data' and click Save. If you are using an external PostgreSQL database instead, select PostgreSQL and enter your connection details (host, port, database name, username, password). Open or create a Retool app. In the Code panel, click + to create a new query named 'getStudentProgress'. Select your Retool Database resource. In the query editor, write a SQL query that fetches progress data with filters for the class and date range controls you will add in the UI. The query uses Retool's {{ }} syntax for dynamic parameterization, and Retool automatically converts these to prepared statements to prevent SQL injection. For the mastery level filter, use a CASE statement to convert the text mastery level into a numeric score (e.g., Not Started=0, Attempted=1, Familiar=2, Proficient=3, Mastered=4) for sorting and charting. Add aggregation queries for class-level summaries using GROUP BY student_email or GROUP BY skill_domain.

```
-- Query: student progress with filters
SELECT
  student_email,
  student_id,
  exercise_name,
  skill_domain,
  mastery_level,
  CASE mastery_level
    WHEN 'Mastered' THEN 4
    WHEN 'Proficient' THEN 3
    WHEN 'Familiar' THEN 2
    WHEN 'Attempted' THEN 1
    ELSE 0
  END AS mastery_score,
  correct_count,
  attempted_count,
  ROUND(time_spent_seconds / 60.0, 1) AS time_spent_minutes,
  last_activity
FROM khan_progress
WHERE
  ({{ classFilter.value }} = '' OR class_name = {{ classFilter.value }})
  AND ({{ domainFilter.value }} = '' OR skill_domain = {{ domainFilter.value }})
  AND last_activity >= {{ dateRange.start || '2020-01-01' }}
  AND last_activity <= {{ dateRange.end || 'now()' }}
ORDER BY student_email, skill_domain, mastery_score DESC;
```

**Expected result:** The getStudentProgress query returns filtered rows from the khan_progress table, visible in the Results panel with student progress data.

### 4. Build the student progress dashboard UI

In the Retool canvas, add a stat row at the top of the app with three Statistic components showing class-level summary metrics: Total Students (COUNT DISTINCT student_email), Average Mastery Score (ROUND(AVG(mastery_score), 2)), and Total Time Spent (SUM(time_spent_minutes) formatted as hours). Below the stats row, add filter controls: a Select for class_name (named 'classFilter', data from a DISTINCT class_name query), a Select for skill_domain (named 'domainFilter', data from a DISTINCT skill_domain query), and a Date Range Picker (named 'dateRange'). Add a Table component below the filters bound to {{ getStudentProgress.data }} with columns for student_email (or a display name if your data includes one), skill_domain, exercise_name, mastery_level (formatted with conditional coloring — red for Not Started, yellow for Attempted, light green for Familiar, green for Proficient, dark green for Mastered), time_spent_minutes, and last_activity. Add a Chart component below the table showing mastery distribution: a Bar chart with skill_domain on the x-axis and the count of exercises at each mastery level as stacked bars. Use a GROUP BY transformer to prepare the Chart data. Add a second Chart showing weekly activity trends — exercises completed per week over the last 8 weeks — using a DATE_TRUNC('week', last_activity) GROUP BY query.

```
// Transformer: prepare mastery distribution data for Chart component
const rows = data || [];
const domains = [...new Set(rows.map(r => r.skill_domain))];
const levels = ['Mastered', 'Proficient', 'Familiar', 'Attempted', 'Not Started'];
const colors = ['#16a34a', '#65a30d', '#ca8a04', '#f97316', '#dc2626'];

return {
  labels: domains,
  datasets: levels.map((level, i) => ({
    label: level,
    backgroundColor: colors[i],
    data: domains.map(domain =>
      rows.filter(r => r.skill_domain === domain && r.mastery_level === level).length
    )
  }))
};
```

**Expected result:** A functional student progress dashboard shows filterable data with mastery distribution charts, weekly activity trends, and individual student breakdowns.

### 5. Set up a Retool Workflow for scheduled data refresh

Rather than manually re-importing CSVs each week, you can partially automate the refresh process using Retool Workflows combined with any automated export delivery that Khan Academy may offer. Create a new Retool Workflow by navigating to Retool → Workflows → Create new Workflow. Name it 'Khan Academy Data Refresh'. For organizations where Khan Academy exports can be automatically delivered (via SFTP, Google Drive, or email attachment), configure the Workflow with a Schedule trigger (e.g., every Monday at 8 AM). Add a Resource Query block that reads from the data source where the latest export file lands (e.g., if you move the CSV to an S3 bucket via automation, use an S3 Resource Query to fetch it). Add a Code block with JavaScript that parses the CSV content into row objects. Add a second Resource Query block that performs a bulk upsert into the khan_progress table using Retool Database's INSERT ... ON CONFLICT DO UPDATE syntax to merge new progress data with existing records without creating duplicates. Add error handling with a Global Error Handler block that sends a Slack notification if the import fails. For fully manual refresh workflows, the Workflow can also serve as a reminder system — schedule it to send a Slack message to the admin each Monday asking them to run the export and upload the file. For complex multi-source education analytics pipelines integrating Khan Academy exports with your SIS, LMS, and HR data, RapidDev's team can help architect your Retool data operations solution.

```
// Retool Workflow Code block: parse CSV and upsert into Retool Database
// Assumes 'csvContent' is the raw CSV string from a previous block
const lines = csvContent.split('\n').filter(l => l.trim());
const headers = lines[0].split(',').map(h => h.trim().replace(/"/g, ''));

const rows = lines.slice(1).map(line => {
  const values = line.split(',').map(v => v.trim().replace(/"/g, ''));
  const row = {};
  headers.forEach((h, i) => row[h] = values[i] || null);
  return row;
});

// rows is now an array of objects ready for bulk upsert
return rows;
```

**Expected result:** A Retool Workflow is configured to run on a schedule, automating the data refresh process and maintaining up-to-date Khan Academy progress data in Retool Database.

## Best practices

- Document the Khan Academy CSV export column names and maintain a consistent schema version in Retool Database — when Khan Academy updates their export format, update your table schema to match before re-importing
- Add a 'data_as_of' or 'imported_at' column to your Retool dashboard UI so teachers and managers always know the date of the underlying data and can request a fresh export if needed
- Use upsert (INSERT ... ON CONFLICT DO UPDATE) rather than delete-and-re-insert when refreshing Khan Academy data to preserve the import history and enable trend analysis across multiple export snapshots
- Combine Khan Academy progress data with student roster data from your SIS (Student Information System) in a JOIN to display student names and grade levels instead of just email addresses — this makes the dashboard usable for non-technical teachers
- Build role-based access controls in Retool so teachers can only see their own class's data, while administrators can see all classes — use Retool's Groups and Permissions settings to restrict app access and add WHERE class_name IN ('{{ retoolContext.currentUser.groups }}') filters
- Cache summary/aggregation queries (class averages, mastery distribution counts) for 5-10 minutes since they are computationally expensive and change only when new data is imported, not between user interactions
- Use Retool Workflows for automated alerting — schedule a weekly Workflow that queries for students whose average mastery score has declined below a threshold and sends an alert email to the teacher with the at-risk student list

## Use cases

### Build a student progress and mastery tracking dashboard

Create a Retool panel that shows individual student progress across Khan Academy courses — displaying mastery levels (Not Started, Attempted, Familiar, Proficient, Mastered) per skill area, time spent learning, and completion percentage. Enable filtering by class, grade, date range, and skill domain so teachers can quickly identify students who are falling behind and need intervention.

Prompt example:

```
Build a Retool student progress dashboard querying the khan_progress table in Retool Database. Show a Table with student name, grade, course, mastery level, exercises completed, time spent (minutes), and last activity date. Include filters for class, mastery level threshold, and date range. Add a bar chart of mastery distribution across the class.
```

### Build a class-level learning analytics panel for teachers

Create a Retool class analytics view that aggregates Khan Academy progress data by class or cohort — showing class-average mastery per skill domain, exercises completed per week, and a comparison of current week vs previous week engagement. Display individual student standings in a ranked table so teachers can identify top performers and at-risk students in a single view.

Prompt example:

```
Build a Retool analytics panel showing aggregated Khan Academy progress for a selected class. Show Charts for average mastery by skill area, weekly exercise completion trend, and a Table of students ranked by mastery score with columns for student name, total exercises, average mastery, and last activity date.
```

### Build an HR learning progress tracker for corporate training programs

Create a Retool employee training dashboard for organizations using Khan Academy as part of their L&D programs. Show employee completion rates by department, track mandatory course completions, and generate compliance reports for HR managers. Combine Khan Academy progress data with HRIS data from another connected database to add employee department and manager information.

Prompt example:

```
Build a Retool corporate learning dashboard querying khan_progress data joined with an employees table. Show completion rates by department using a Chart, a Table of employees who haven't completed mandatory courses (filter by completion = 0 and course_id in mandatory list), and a summary metric for overall training completion percentage.
```

## Troubleshooting

### CSV import to Retool Database fails with 'column type mismatch' error

Cause: Khan Academy CSV exports may include inconsistent data formats — for example, the time_spent_seconds column may contain empty strings instead of 0 for students who haven't started, or date columns may be in a non-standard format that Retool Database rejects during import.

Solution: Before importing, open the CSV in a spreadsheet application and clean the data: replace empty cells in numeric columns with 0, ensure date columns use ISO 8601 format (YYYY-MM-DD HH:MM:SS), and remove any rows with missing required fields. Alternatively, use Retool Database's manual column definition mode to set more permissive types (TEXT instead of INTEGER) and handle type conversion in SQL queries using CAST().

```
-- Handle NULL/empty values in numeric columns during query
SELECT
  student_email,
  COALESCE(NULLIF(time_spent_seconds, '')::INTEGER, 0) AS time_spent_seconds,
  COALESCE(NULLIF(correct_count, '')::INTEGER, 0) AS correct_count
FROM khan_progress;
```

### Dashboard shows stale data — progress visible in Khan Academy but not in Retool

Cause: The Retool database still contains an older CSV import. Khan Academy data is only as current as the last exported and imported CSV file — there is no live API connection to pull real-time updates.

Solution: Re-export the progress report from Khan Academy's teacher dashboard and re-import the CSV into Retool Database. For the re-import, use a DELETE FROM khan_progress WHERE class_name = '...' statement first to clear old data for that class, then re-import. Or use the upsert pattern described in Step 5 to merge updates without deleting existing records. Add a 'last_imported' metadata display to your Retool app so teachers can see when the data was last refreshed.

```
-- Upsert pattern: update on conflict for data refresh
INSERT INTO khan_progress (student_id, exercise_name, class_name, mastery_level, correct_count, last_activity)
VALUES ({{ row.student_id }}, {{ row.exercise_name }}, {{ row.class_name }}, {{ row.mastery_level }}, {{ row.correct_count }}, {{ row.last_activity }})
ON CONFLICT (student_id, exercise_name, class_name)
DO UPDATE SET
  mastery_level = EXCLUDED.mastery_level,
  correct_count = EXCLUDED.correct_count,
  last_activity = EXCLUDED.last_activity,
  imported_at = CURRENT_TIMESTAMP;
```

### SQL query throws 'column does not exist' error for columns in the CSV

Cause: Khan Academy CSV export column names may contain spaces, special characters, or capitalization that differs from the column names created during Retool Database import. PostgreSQL is case-sensitive for quoted identifiers.

Solution: In Retool Database, open the table and inspect the actual column names — they may have been sanitized during import (spaces replaced with underscores, lowercase forced). Update your SQL queries to use the exact column names shown in the table schema. If column names are problematic, rename them using ALTER TABLE khan_progress RENAME COLUMN 'old name' TO new_name in the Retool Database SQL editor.

## Frequently asked questions

### Is Khan Academy's API still available?

Khan Academy's public REST API (api.khanacademy.org) was officially deprecated and shut down. New integrations cannot use the old public API endpoints. For organizations with Khan Academy for Schools district partnerships, a separate district data API may be available through Khan Academy's enterprise team — contact your Khan Academy account manager to request access. For all other use cases, the CSV export approach described in this guide is the primary integration path.

### How do I get student names instead of email addresses in my Retool dashboard?

Khan Academy CSV exports may include student email addresses or anonymized IDs depending on your organization's privacy settings. If your school uses a Student Information System (SIS) like PowerSchool or Infinite Campus, connect Retool to your SIS database or API as a second Resource and JOIN the student records to the khan_progress table on the email or student ID field. Retool's ability to combine data from multiple Resources is ideal for this enrichment pattern.

### Can I track which specific exercises students need help with?

Yes. The Khan Academy CSV export includes exercise-level mastery data with a mastery_level per exercise. In your SQL query, filter for rows where mastery_level is 'Not Started' or 'Attempted' (mastery score 0 or 1) to identify exercises where students are struggling. GROUP BY exercise_name and COUNT(student_id) to find exercises with the most struggling students — these are intervention priorities for teachers.

### How often should I re-import Khan Academy data?

For active classes, weekly re-imports provide a reasonable balance between data freshness and administrative overhead. For summative reporting periods (quarter end, semester end), re-import before generating final reports. For ongoing monitoring of at-risk students, consider setting up email or Slack alerts via a Retool Workflow that queries the most recently imported data and flags students whose mastery scores have not improved since the previous import.

### Can I combine Khan Academy data with other learning tools in the same Retool dashboard?

Yes, this is one of Retool's strongest use cases. Import data from Khan Academy, your LMS (Canvas, Moodle, Schoology), and reading platforms into separate tables in Retool Database or PostgreSQL. Write JOIN queries across these tables to build a unified student progress dashboard that shows performance across all learning platforms in a single view — something none of the individual platforms can do natively.

---

Source: https://www.rapidevelopers.com/retool-integrations/khan-academy-api
© RapidDev — https://www.rapidevelopers.com/retool-integrations/khan-academy-api
