-
Notifications
You must be signed in to change notification settings - Fork 7
Course Endpoints
##Authentication
All routes require you to be authorized. Make a GET
request to /v1/user/authenticate
to get your token. Every authenticated route requires a x-access-token
header with your token sent.
####Available Fields
{
sections: [{
title: String,
lessons: [/* lesson objects */]
}],
template: Boolean,
term: String,
instructor: String,
description: String,
students: [/* user objects */],
title: String,
created_at: Number,
created_by: String,
updated_at: Number,
updated_by: String,
start_date: Number,
end_date: Number
}
###/v1/course/template
GET Return all course templates
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Response
{
"course": [
{
"_id": "564a44032e55ee5430afb11f",
"title": "Boot Camp",
"template": true,
"created_at": 1447707651903,
"updated_at": 1447862257479,
"sections": [
"..."
]
},
{
"_id": "564a448f2e55ee5430afb126",
"title": "Part Time HTML/CSS",
"template": true,
"created_at": 1447707791273,
"sections": [
"..."
]
},
{
"_id": "564a449a2e55ee5430afb12d",
"title": "Part Time Javascript",
"template": true,
"created_at": 1447707802957,
"sections": [
"..."
]
},
{
"_id": "564a44c22e55ee5430afb134",
"title": "Part Time Ruby on Rails",
"template": true,
"created_at": 1447707842957,
"sections": [
"..."
]
}
]
}
An array of lessons is returned as well.
###/v1/course/template
POST Create course template
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Request
{
"title": "New Template"
}
Response
{
"course": {
"__v": 0,
"title": "A new template",
"template": true,
"created_at": 1448379344940,
"_id": "565483d076099d4b1bf5163d",
"students": [],
"sections": []
}
}
###/v1/course/template/:id
GET Get specific course template
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Params | Value | Description |
---|---|---|
id : string |
565483d076099d4b1bf5163d |
ID from template. |
Response
{
"course": {
"title": "A new template",
"template": true,
"created_at": 1448379344940,
"sections": [...]
}
}
###/v1/course
GET Return all courses
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Response
{
"course": [
{
"_id": "5653952433140c7c02dda721",
"updated_at": 1448318244730,
"title": "Summer 2015 Bootcamp",
"template": false,
"created_at": 1448318244701,
"term": "Summer 2015",
"description": "Test description",
"students": [...],
"sections": [...]
}
]
}
###/v1/course
POST Create course
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Request
{
"title": "A new course",
"template": false,
"created_at": 1448379344940,
"sections": [...]
}
Response
{
"course": {
"__v": 0,
"template": false,
"title": "A new course",
"created_at": 1448380546068,
"_id": "5654888276099d4b1bf5163e",
"students": [],
"sections": []
}
}
###/v1/course/:id
GET Get specific course
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Params | Value | Description |
---|---|---|
id : string |
5654888276099d4b1bf5163e |
ID from course. |
Response
{
"course": [
{
"_id": "5654888276099d4b1bf5163e",
"title": "A new course",
"template": false,
"created_at": 1448380546068,
"students": [],
"sections": []
}
]
}
###/v1/course/:id
PUT Update specific course
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Params | Value | Description |
---|---|---|
id : string |
5654888276099d4b1bf5163e |
ID from course. |
Request
{
"_id": "5654888276099d4b1bf5163e",
"template": false,
"title": "A Updated course title",
"created_at": 1448380546068,
"students": [],
"sections": []
}
Response
{
"course": {
"_id": "5654888276099d4b1bf5163e",
"title": "A Updated course title",
"template": false,
"created_at": 1448380546068,
"__v": 0,
"updated_at": 1448381481864,
"students": [],
"sections": []
}
}
If there are sections in the course, changing the order of the section will update that order in the API.
###/v1/course/:id
DELETE Delete specific course
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Params | Value | Description |
---|---|---|
id : string |
5654888276099d4b1bf5163e |
ID from course |
Response
{
course: []
}
###/v1/course/:courseId/section
POST Add a section to a course
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Params | Value | Description |
---|---|---|
courseId : string |
5654888276099d4b1bf5163e |
ID from course |
Request
{
title: 'section title'
}
Response
{
course: {
sections: [ /* section objects */],
students: [],
description: 'Test description',
term: 'Summer 2015',
created_at: 1448987531620,
template: false,
title: 'updated',
updated_at: 1448987531635,
_id: 565dcb8bee51bf925b6d6d5e,
__v: 1
}
}
###/v1/course/section/:sectionId
GET Get a section
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Params | Value | Description |
---|---|---|
sectionId : string |
565dcb8bee51bf925b6d6d5f |
ID from section |
Response
{
section: {
lessons: [
{
topics: [],
revisions: [],
__v: 0,
created_at: 1458699468789,
title: 'Course add lesson 1',
_id: 56f1fccc5616faf91fa860c4
},
{
topics: [],
revisions: [],
__v: 0,
created_at: 1458699468658,
title: 'Course add lesson',
_id: 56f1fccc5616faf91fa860bd
}
],
updated_at: 1458699468792,
__v: 3,
title: 'New section',
_id: 56f1fccc5616faf91fa860c0
}
}
###/v1/course/section/:sectionId
PUT Update a section
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Params | Value | Description |
---|---|---|
sectionId : string |
565dcb8bee51bf925b6d6d5f |
ID from section |
Response
{
section: {
lessons: [
{
topics: [],
revisions: [],
__v: 0,
created_at: 1458699468658,
title: 'Course add lesson',
_id: 56f1fccc5616faf91fa860bd
},
{
topics: [],
revisions: [],
__v: 0,
created_at: 1458699468789,
title: 'Course add lesson 1',
_id: 56f1fccc5616faf91fa860c4
}
],
updated_at: 1458699468792,
__v: 3,
title: 'New section',
_id: 56f1fccc5616faf91fa860c0
}
}
Used to update the lessons in a section or update a section title.
###/v1/course/:courseId/section/:sectionId
DELETE Remove a section to a course
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Params | Value | Description |
---|---|---|
courseId : string |
5654888276099d4b1bf5163e |
ID from course |
sectionId : string |
565dcb8bee51bf925b6d6d5f |
ID from section |
Response
{
course: {
sections: [],
students: [],
__v: 1,
description: 'Test description',
term: 'Summer 2015',
created_at: 1448988051409,
template: false,
title: 'updated',
updated_at: 1448988051419,
_id: 565dcd933c8c90925b80f756
}
}
###/v1/course/section/:sectionId/lesson/:lessonId
PUT Add lesson to section in a course
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Params | Value | Description |
---|---|---|
sectionId : string |
5654888276099d4b1bf5163e |
ID from section |
lessonId : string |
565380b92185c27c0220a484 |
ID from lesson |
Reponse
{
lessons: [ /* Lesson Objects */ ],
__v: 1,
title: 'New section',
_id: 565e211198ff05e1617e80fb,
updated_at: 1449009425571
}
###/v1/course/section/:sectionId/lesson/:lessonId
DELETE Remove lesson from a section of a course
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Params | Value | Description |
---|---|---|
sectionId : string |
5654888276099d4b1bf5163e |
ID from section |
lessonId : string |
565380b92185c27c0220a484 |
ID from lesson |
Response
{
"course": {
"_id": "5654888276099d4b1bf5163e",
"title": "A Updated course title",
"template": false,
"created_at": 1448379344940,
"__v": 2,
"updated_at": 1448382432185,
"students": [],
"sections": []
}
}
###/v1/course/:courseId/user
POST Add users to course
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Params | Value | Description |
---|---|---|
courseId : string |
5654888276099d4b1bf5163e |
ID from course |
Query | Value | Description |
---|---|---|
emails : string |
ryan@hackeryou,[email protected] |
Comma separated list of emails |
If user already exists it will just add the course, otherwise it will create a new user and send them an email!
Response
{
"course": {
"_id": "5654888276099d4b1bf5163e",
"title": "A Updated course title",
"template": false,
"created_at": 1448379344940,
"__v": 2,
"updated_at": 1448382432185,
"students": [/* Student objects with selected fields */],
"sections": []
}
}
###/v1/course/:courseId/user/:userId
DETELE Remove users to course
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Params | Value | Description |
---|---|---|
courseId : string |
5654888276099d4b1bf5163e |
ID from course |
userId : string |
5654888276099d4b151ea163e |
ID from user |
Response
{
"course": {
"_id": "5654888276099d4b1bf5163e",
"title": "A Updated course title",
"template": false,
"created_at": 1448379344940,
"__v": 2,
"updated_at": 1448382432185,
"students": [],
"sections": []
}
}