-
Notifications
You must be signed in to change notification settings - Fork 7
Topics 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
{
title: String,
exercises: [/* exercise objects */],
lessons: [/* lesson objects */],
revisions: [/* array of previous revisions */],
body: String,
description: String,
category: String,
time: Number,
created_at: Number,
created_by: String,
updated_at: Number,
updated_by: String
}
###/v1/topic
GET Get all topics
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Query | Value | Description |
---|---|---|
limit : number |
default is all | Number of topics you want to return. |
offset : number |
default is 0 | Number of topics you would like to skip. |
Response
{
"totalCount": 3,
"topic": [
{
"_id": "565380b92185c27c0220a488",
"title": "Intro to HTML",
"created_at": 1448313017881,
"revisions": [],
"lessons": [
"5654974676099d4b1bf51641"
],
"exercises": [],
"time": 30
},
{
"_id": "56538143c5c8307c02de3028",
"title": "Semantic Elements",
"created_at": 1448313155600,
"revisions": [],
"lessons": [],
"exercises": [],
"time": 10
},
{
"_id": "5653817dec65cc7c028075be",
"title": "CSS Selectors",
"created_at": 1448313213192,
"revisions": [],
"lessons": [],
"exercises": [],
"time": 4
}
]
}
###/v1/topic
POST Create topic
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Request
{
"title" : "jQuery"
}
Response
{
"topic": {
"__v": 0,
"title": "jQuery",
"created_at": 1448393146034,
"_id": "5654b9ba3cf39ed12dc04942",
"revisions": [],
"lessons": [],
"exercises": [],
"time": 14
}
}
###/v1/topic/:id
GET Get specific topic
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Params | Value | Description |
---|---|---|
id : string |
token |
ID of topic. |
Response
{
"topic": {
"_id": "5654b9ba3cf39ed12dc04942",
"title": "jQuery",
"created_at": 1448393146034,
"revisions": [],
"lessons": [],
"exercises": [],
"time": 45
}
}
###/v1/topic/:id
PUT Update specific topic
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Params | Value | Description |
---|---|---|
id : string |
5654b9ba3cf39ed12dc04942 |
ID of topic. |
Request
}
"topic": {
"_id": "5654b9ba3cf39ed12dc04942",
"title": "jQuery",
"created_at": 1448393146034,
"__v": 0,
"updated_at": 1448395427011,
"description": "A look at the jQuery Javascript library",
"body": "Lessons content goes here",
"revisions": [],
"lessons": [],
"exercises": [],
"time": 25
}
}
Response
}
"topic": {
"_id": "5654b9ba3cf39ed12dc04942",
"title": "jQuery",
"created_at": 1448393146034,
"__v": 0,
"updated_at": 1448395427011,
"description": "A look at the jQuery Javascript library",
"body": "Lessons content goes here",
"revisions": [
{
"_id": "5654b9ba3cf39ed12dc04942",
"title": "jQuery",
"created_at": 1448393146034,
"__v": 0,
"updated_at": 1448395373197,
"revisions": [],
"lessons": [],
"exercises": []
}
],
"lessons": [],
"exercises": [],
"time": 25
}
}
###/v1/topic/:id
DELETE Delete specific topic
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Params | Value | Description |
---|---|---|
id : string |
5654b9ba3cf39ed12dc04942 |
ID of topic. |
Response
{
"topic" : []
}
###/v1/topic/:topicId/exercise/:exerciseId
PUT Add an exercise to a topic
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Params | Value | Description |
---|---|---|
topicId : string |
5654b9ba3cf39ed12dc04942 |
ID of topic. |
exerciseId : string |
5653873d33140c7c02dda5a1 |
ID of exercise. |
Response
{
"topic": {
"_id": "5654b9ba3cf39ed12dc04942",
"title": "jQuery",
"created_at": 1448393146034,
"__v": 1,
"updated_at": 1448403525689,
"description": "A look at the jQuery Javascript library",
"body": "Lessons content goes here",
"revisions": [
{
"_id": "5654b9ba3cf39ed12dc04942",
"title": "jQuery",
"created_at": 1448393146034,
"__v": 0,
"updated_at": 1448395373197,
"revisions": [],
"lessons": [],
"exercises": []
}
],
"lessons": [],
"time": 25,
"exercises": [
"5653873d33140c7c02dda5a1"
]
}
}
###/v1/topic/:topicId/exercise/:exerciseId
Delete Remove an exercise to a topic
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Params | Value | Description |
---|---|---|
topicId : string |
5654b9ba3cf39ed12dc04942 |
ID of topic. |
exerciseId : string |
5653873d33140c7c02dda5a1 |
ID of exercise. |
Response
{
"topic": {
"_id": "5654b9ba3cf39ed12dc04942",
"title": "jQuery",
"created_at": 1448393146034,
"__v": 1,
"updated_at": 1448403525689,
"description": "A look at the jQuery Javascript library",
"body": "Lessons content goes here",
"revisions": [
{
"_id": "5654b9ba3cf39ed12dc04942",
"title": "jQuery",
"created_at": 1448393146034,
"__v": 0,
"updated_at": 1448395373197,
"revisions": [],
"lessons": [],
"exercises": []
}
],
"lessons": [],
"time": 25,
"exercises": []
}
}
###/v1/topic/search
GET Search topics based on title
Headers | Value | Description |
---|---|---|
x-access-token : string |
token |
Token received from authentication. |
Query | Value | Description |
---|---|---|
term : string |
Navigation |
Term you are looking for in the title. |
Performs a simple, case insensitive, search based on the title
key in the topics.
Response
{
topics:
[
{
exercises: [ '56f1b08c2c8c3a9e1889f5d1' ],
lessons: [],
revisions:
[
{ exercises: [],
lessons: [],
revisions: [],
__v: 0,
created_at: 1458679948489,
title: 'Navigation',
_id: 56f1b08c2c8c3a9e1889f5d2
}
],
updated_at: 1458679948698,
__v: 1,
created_at: 1458679948489,
title: 'List Navigation',
_id: 56f1b08c2c8c3a9e1889f5d2 },
{
exercises: [],
lessons: [],
revisions:
[
{
exercises: [],
lessons: [],
revisions: [],
__v: 0,
created_at: 1458831108103,
title: 'Navigation',
_id: 56f3ff04cea086d13adb211c
}
],
updated_at: 1458831108405,
__v: 0,
created_at: 1458831108103,
title: 'Wordpress Navigation',
_id: 56f3ff04cea086d13adb211c
}
]
}