
Teachable API: Retrieve a List of Students in Your School
Getting Started with the Teachable API: A Beginner’s Guide (With a Step-By-Step Google Sheets Example)
Want to automate student tracking in your Teachable school? The Teachable API makes it possible!
In this beginner-friendly guide, we’ll break down what an API is, how the Teachable API works, and provide a step-by-step tutorial to log student enrollments into Google Sheets automatically—without any manual data entry.
What is an API?
An API (Application Programming Interface) is like a bridge that allows two applications to communicate with each other. Think of it like a waiter in a restaurant:
- You (the user) tell the waiter (API) what you want.
- The waiter (API) goes to the kitchen (the application) to get the data.
- The waiter (API) brings back what you requested.
With the Teachable API, you can ask Teachable for information (like student enrollments), send new data (like registering a student), or perform automated tasks without needing to log into your dashboard. To learn more about the Teachable API, visit their API documentation site at https://docs.teachable.com.
What Can You Do With the Teachable API?
The Teachable API allows you to:
✅ Get a list of students in your school.
✅ Retrieve student information (name, email, enrollment data).
✅ Add or update student enrollments automatically.
✅ Pull course data (like completion percentages).
✅ Generate reporting data for progress tracking. ✅ and more…
For our example, we’ll set up a simple way to automatically record all your student in Google Sheets.
Step-By-Step: Logging Student Enrollments to Google Sheets
Prerequisites
Before we begin, make sure you have these ready:
- A Teachable account (with API access available on Pro plan and above).
- A Google Sheet where you want to log enrollments.
- Your Teachable API Key (found in your Teachable admin panel under “Settings” -> “API Keys”).
Step 1: Create a Google Sheet & Enable Google Apps Script
- Open Google Sheets.
- Create a new spreadsheet and name it something like
Teachable Enrollments
. - In row 1, add these column names:
Student ID
Student Name
Email
- Click Extensions > Apps Script. This opens a new scripting editor where we’ll write a simple script to connect Teachable to Google Sheets.
Step 2: Write the Script to Fetch Enrollments
Replace the default code (Code.gs) in the Apps Script editor with the following:
function logTeachableEnrollments() { const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); const apiKey = "YOUR_TEACHABLE_API_KEY"; let baseUrl = "https://developers.teachable.com/v1/users"; // Teachable API endpoint
let page = 1; let perPage = 50; // Adjust based on API limits or requirements let morePages = true; // Flag to indicate if more records exist
while (morePages) { let url = `${baseUrl}?page=${page}&per=${perPage}`;
let options = { "method": "GET", "headers": { "accept": "application/json", "apiKey": apiKey } };
// Fetch data from API const response = UrlFetchApp.fetch(url, options); const data = JSON.parse(response.getContentText());
if (data.users && data.users.length > 0) { data.users.forEach(user => { sheet.appendRow([user.id, user.name, user.email]); });
page++; // Move to next page } else { morePages = false; // Stop when no users exist in the response } }
Logger.log("All records have been fetched and logged.");}
Don’t forget to save the script, by clicking the save (disc) icon.
🚀 What This Script Does:
- Connects to Teachable’s API using your API key.
- Fetches a list of students (
users
). - Adds a new row to your Google Sheet for each student that is found.
- Handles pagination
💡 Why Do We Handle Pagination?
Teachable’s API returns results in pages (e.g., 50 students per request). If you have more students than the per-page limit, you need to make additional requests to fetch all students.
Our script automatically loops through pages until there are no more students left to retrieve.
Step 3: Test Your Script
🔴 Google’s Security Warning: When you run the script for the first time, Google might show a security warning:
⚠️ “This app isn’t verified”
This happens because the script hasn’t been reviewed by Google, but since you wrote it yourself, it’s completely safe.
To proceed:
- Click Advanced
- Select Go to Untitled project (unsafe)
- Grant permission for the script to access your Google Sheets
🛠 Tip: If you name your Apps Script project, the warning will display your project name instead of “Untitled project.”
- Click the Run ▶️ button in Apps Script to manually trigger it.
- Check your Google Sheet — if everything is working, your students will start to appear row-by-row
Final Thoughts
🚀 The Teachable API can save you hours of manual tracking! With just a few lines of code, you can automate student enrollments, making it effortless to manage your school.
Next Steps:
- ✅ Try running the script on your own Google Sheet
- ✅ Expand the script to pull more information on a specifc student