Requests
Requests made to the API are made using the developers.teachable.com
base URL.
The API uses standard HTTP methods for indicating which actions to take on a resource:
Method | Action |
---|---|
GET | Retrieve a resource |
POST | Create a new resource |
PATCH | Partially modify an existing resource |
DELETE | Remove a resource |
Headers
There are several headers you may need to include in your request.
Header | Use Case |
---|---|
apikey | The apikey header authorizes your request and will include your unique API key—learn more about authentication. |
Accept | - The Accept header tells the API in which format to return the response. By default, this is set to application/json . |
Content-Type | The Content-Type header tells the API about the format of the data being sent. This is required when including a request body with a POST, PATCH, or DELETE request.This must be set to application/json . |
Example header:
cURL —-header ‘apikey: YOURAPIKEYHERE’ \
—-header 'Content-Type: application/json' \
--header `Accept: application/json'
Request bodies
When making POST, PATCH, or DELETE requests, you must add a request body (i.e., the included data) in JSON.
Example request body format:
cURL —-data '
{
"key": value
}
'
For example, if you want to use the API to create a new user in your school, you will need to make a POST request to the users
endpoint. This will require you to include a request body in your call, as you'll need to include some data about the new user (e.g., their name and email address).
For this particular example, the request body of a call to the users
endpoint is formatted as follows:
cURL --data '
{
"email": "[email protected]",
"password": "password123"
}
'
Example of a request
As mentioned above, your request might need various header and body content, depending on the request type you're making.
For example, a call to the users
endpoint requires the following:
- A request type (i.e., POST)
- A base URL where the call is made (i.e.,
developers.teachable.com
) - A header with both your API key for authorization, and an indicated
content-type
- A request body that includes data about the new user
All together, a call to the users
endpoint would be formatted as follows:
cURL --request POST \
--url https://developers.teachable.com/users \
--header 'Content-Type: application/json' \
--header 'apikey: YOURAPIKEYHERE' \
--data '
{
"email": "[email protected]",
"password": "password123",
"name": "John Doe"
}
'
You can use the "Try It!" feature in the reference documentation to make requests to the API. However, be aware that using this function makes a an actual to the API—and therefore, will get and/or post real data to/from your Teachable school.
Updated over 2 years ago