Para obtener los detalles de un curso de una escuela de Teachlr Organizaciones se debe realizar una petición GET al API de Teachlr Organizaciones utilizando el siguiente URL:
https://api.teachlr.com/<dominio>/api/courses-online/<slug>
en donde <dominio> se debe sustituir por el dominio teachlr de la escuela (no el dominio personalizado) y <slug> por el slug del curso del cual se desea obtener los detalles.
En la petición se deben enviar las siguientes dos cabeceras:
Key | Value |
Content-Type | application/json |
Authorization | key_0123456789ABCDEFGHIJK |
Nota: El valor de Authorization mostrado arriba es ficticio. Cada escuela tendrá su propia llave (key) que debe ser solicitada por el cliente.
Adicionalmente, se pueden especificar parámetros de filtrado mediante una cadena de consulta, esto es, agregando al final del URL una estructura como la siguiente:
?reviews=true&objectives=false&requirements=false&contents=false
Los distintos parámetros que se pueden especificar y sus posibles valores se detallan a continuación:
Parámetro | reviews |
Valor | true | false |
Valor por defecto | true |
Significado | Incluir las reseñas que han escrito los estudiantes |
Ejemplo | reviews=false (no incluir las reseñas) |
Parámetro | objectives |
Valor | true | false |
Valor por defecto | true |
Significado | Incluir los objetivos del curso |
Ejemplo | objectives=false (no incluir los objetivos) |
Parámetro | requirements |
Valor | true | false |
Valor por defecto | true |
Significado | Incluir los requisitos del curso |
Ejemplo | requirements=false (no incluir los requisitos) |
Parámetro | contents |
Valor | true | false |
Valor por defecto | true |
Significado | Incluir los contenidos de cada capítulo |
Ejemplo | contents=false (no incluir los contenidos) |
Parámetro | lang |
Valor | Código ISO 639-1 (código de 2 letras que representan un idioma) |
Significado | Se establece para poder hacer uso del parámetro multi_lang |
Ejemplo | lang=es (idioma español) |
Parámetro | multi_lang |
Valor | true | false |
Valor por defecto | true (todos los idiomas) |
Significado | Mostrar el nombre de las categorías/subcategorías en todos los idiomas o únicamente en el idioma especificado en el parámetro lang |
Ejemplo | multi_lang=false (sólo en el idioma especificado en lang) |
Caso de ejemplo:
Se desea obtener la información de un curso con el slug «marketing-digital» de la escuela https://escueladeprueba.teachlr.com.
La petición al API de Teachlr Organizaciones se debe hacer al siguiente URL:
https://api.teachlr.com/escueladeprueba/api/courses-online/marketing-digital
Una implementación utilizando la función $.ajax() de jQuery sería como sigue:
$.ajax({
url:"https://api.teachlr.com/escueladeprueba/api/courses-online/marketing-digital",
dataType: "json",
type: "GET",
contentType: "application/json",
headers: {
"Authorization": "key_0123456789ABCDEFGHIJK"
},
success: function(data) {
// la petición fue exitosa
console.log('data', data);
},
error: function(xhr, status, err) {
// falló la petición
console.log('xhr', xhr);
console.log('status', status);
console.log('err', err);
}
});
Posibles respuestas del API:
Status: 200 OK
{
"id": 166,
"title": "Marketing Digital",
"language": "es",
"headline": "Lor separat existentie es un myth",
"cover": {
"thumb": "https://d2j3j1vpt.../166/covers/1496554772-118x66.jpg",
"small": "https://d2j3j1vpt.../166/covers/1496554772-222x125.jpg",
"medium": "https://d2j3j1vpt.../166/covers/1496554772-236x132.jpg",
"large": "https://d2j3j1vpt.../166/covers/1496554772-506x285.jpg"
},
"description": "<p>Li Europan lingues es membres del sam familie.</p>",
"slug": "marketing-digital",
"expired": false,
"is_public": false,
"created_at": "2017-06-01 14:55:21",
"status": "active",
"level": 3,
"visits": 7,
"views": 4,
"num_users": 8,
"num_groups": 2,
"num_sales": 0,
"total_rate": "4.25",
"price": "5.5",
"video_promo": "https://vimeo.com/03356920",
"video_promo_type": 0,
"author_about": null,
"author_picture": null,
"author_username": null,
"author_headline": null,
"author_name": null,
"author_last_name": null,
"author_country": null,
"audience": null,
"instructions": "<p>At vero eos et accusamus et iusto odio dignissimos</p>",
"url": "https://escueladeprueba.teachlr.com/#courses-online/marketing-digital",
"instructors": [
{
"username": "pedroperez",
"name": "Pedro",
"last_name": "Pérez",
"email": "pedroperez@dominio.com",
"about": "Donec quam felis, ultricies nec",
"job": "Desarrollador de software",
"department": "Informática",
"picture": {
"thumb": "https://d2j3j1vpt0andh.../avatars/D02-32x32.jpg",
"small": "https://d2j3j1vpt0andh.../avatars/D02-54x54.jpg",
"medium": "https://d2j3j1vpt0andh.../avatars/D02-64x64.jpg",
"medium_large": "https://d2j3j1vpt0andh.../avatars/D02-98x98.jpg",
"large": "https://d2j3j1vpt0andh.../avatars/D02-198x198.jpg"
}
},
{
"username": "luisvelasquez",
"name": "Luis",
"last_name": "Velásquez",
"email": "luisvelasquez@dominio.com",
"about": "Donec quam felis, ultricies nec",
"job": "Estadista",
"department": "Ciencias Aplicadas",
"picture": {
"thumb": "https://d2j3j1vpt0andh.../avatars/D03-32x32.jpg",
"small": "https://d2j3j1vpt0andh.../avatars/D03-54x54.jpg",
"medium": "https://d2j3j1vpt0andh.../avatars/D03-64x64.jpg",
"medium_large": "https://d2j3j1vpt0andh.../avatars/D03-98x98.jpg",
"large": "https://d2j3j1vpt0andh.../avatars/D03-198x198.jpg"
}
}
],
"category": {
"id": 11,
"slug": "idiomas",
"tx_name_en": "Languages",
"tx_name_es": "Idiomas",
"tx_name_fr": "Langues",
"co_parent": -1
},
"subcategory": {
"id": 13,
"slug": "ingles",
"tx_name_en": "English",
"tx_name_es": "Inglés",
"tx_name_fr": "Anglais",
"co_parent": 11
},
"currency": "USD",
"author_url": null,
"is_purchased": false,
"num_chapters": 2,
"has_coupons": true,
"chapters": [
{
"id": 147,
"title": "Capítulo 1",
"order": 0,
"course_id": 166,
"available_at": null,
"contents": [
{
"id": 414,
"order": 0,
"detail_id": 358,
"detail_type": "App\\Lecture",
"chapter_id": 147,
"created_at": "2017-06-05 02:54:13",
"updated_at": "2017-06-05 02:54:13",
"available_at": null,
"detail": {
"id": 358,
"title": "Li lingues differe solmen in li grammatica",
"number": 1,
"type": 2,
"description": "<p> Omnicos directe al desirabilite de un.</p>",
"duration": 13,
"preview": false,
"thumb": "https://embed-ssl...sized=200x120&video_still_time=6",
"attachments": [
]
}
},
{
"id": 415,
"order": 1,
"detail_id": 359,
"detail_type": "App\\Lecture",
"chapter_id": 147,
"created_at": "2017-06-05 02:55:48",
"updated_at": "2017-06-05 02:55:48",
"available_at": null,
"detail": {
"id": 359,
"title": "On refusa continuar payar",
"number": 2,
"type": 3,
"description": null,
"duration": 183,
"preview": false,
"thumb": "https://app.../img/thumb_audio_file.jpg",
"attachments": [
{
"id": 71,
"file": "https://d2j3j1vpt.../attachments/1496646011.png",
"filename": "Newton's disc 5.png",
"lecture_id": 359,
"created_at": "2017-06-05 03:00:12",
"updated_at": "2017-09-27 17:35:01",
"filesize": "634497"
}
]
}
},
{
"id": 416,
"order": 2,
"detail_id": 360,
"detail_type": "App\\Lecture",
"chapter_id": 147,
"created_at": "2017-06-05 02:58:50",
"updated_at": "2017-06-05 02:58:50",
"available_at": null,
"detail": {
"id": 360,
"title": "At solmen va esser necessi far uniform grammatica",
"number": 3,
"type": 1,
"description": "Ma quande lingues coalesce, li grammatica",
"duration": 0,
"preview": false,
"thumb": "https://app.../img/thumb_doc_file.jpg",
"attachments": [
]
}
},
{
"id": 417,
"order": 3,
"detail_id": 361,
"detail_type": "App\\Lecture",
"chapter_id": 147,
"created_at": "2017-06-05 03:00:41",
"updated_at": "2017-06-05 03:00:41",
"available_at": null,
"detail": {
"id": 361,
"title": "Li nov lingua franca va esser plu",
"number": 4,
"type": 0,
"description": null,
"duration": 670,
"preview": false,
"thumb": "https://i.ytimg.com/vi/zPCgnlhZuHA/mqdefault.jpg",
"attachments": [
{
"id": 76,
"file": "https://d2j3j1vpt.../attachments/1496646853.pdf",
"filename": "01 Facturación Precio Fijo.pdf",
"lecture_id": 361,
"created_at": "2017-06-05 03:14:13",
"updated_at": "2017-09-27 17:35:01",
"filesize": "220763"
},
{
"id": 78,
"file": "https://d2j3j1vpt.../attachments/1496646877.pdf",
"filename": "03 Facturación Pago por Uso.pdf",
"lecture_id": 361,
"created_at": "2017-06-05 03:14:37",
"updated_at": "2017-09-27 17:35:01",
"filesize": "290957"
}
]
}
},
{
"id": 418,
"order": 4,
"detail_id": 362,
"detail_type": "App\\Lecture",
"chapter_id": 147,
"created_at": "2017-06-05 03:01:35",
"updated_at": "2017-06-05 03:01:35",
"available_at": null,
"detail": {
"id": 362,
"title": "It va esser tam simplic quam",
"number": 5,
"type": 0,
"description": "<p>A un Angleso it va semblar un simplific</p>",
"duration": 62,
"preview": false,
"thumb": "https://i.vimeocdn.com/video/637668473_640.jpg",
"attachments": [
]
}
},
{
"id": 419,
"order": 5,
"detail_id": 363,
"detail_type": "App\\Lecture",
"chapter_id": 147,
"created_at": "2017-06-05 03:02:24",
"updated_at": "2017-06-05 03:02:24",
"available_at": null,
"detail": {
"id": 363,
"title": "Cambridge amico dit me que Occidental es",
"number": 6,
"type": 4,
"description": null,
"duration": 0,
"preview": false,
"thumb": "/img/thumb_doc_file.jpg",
"attachments": [
]
}
},
{
"id": 536,
"order": 6,
"detail_id": 179,
"detail_type": "App\\Assessment",
"chapter_id": 147,
"created_at": "2017-11-13 09:28:23",
"updated_at": "2017-11-13 11:23:50",
"available_at": null,
"detail": {
"id": 179,
"title": "Por scientie, musica, sport etc",
"description": "Europa usa li sam vocabular",
"course_id": 166,
"created_at": "2017-11-13 09:21:53",
"updated_at": "2018-09-14 15:37:09",
"settings_json": {
"approve": 70,
"repeat": -1,
"sort": "id",
"duration": -1,
"affects_score": "true",
"show_results": "true",
"go_previous": "true"
},
"question_count": 3
}
}
]
},
{
"id": 223,
"title": "Capítulo 2",
"order": 1,
"course_id": 166,
"available_at": null,
"contents": [
{
"id": 740,
"order": 0,
"detail_id": 20,
"detail_type": "App\\Poll",
"chapter_id": 223,
"created_at": "2019-09-17 17:00:50",
"updated_at": "2019-09-17 17:00:50",
"available_at": null,
"detail": {
"id": 20,
"title": "Li nov lingua franca",
"mandatory": false,
"course_id": 166,
"content_id": null,
"user_id": 5,
"created_at": "2019-09-17 17:00:25",
"updated_at": "2019-09-17 17:00:25"
}
},
{
"id": 741,
"order": 1,
"detail_id": 8,
"detail_type": "App\\Videoconference",
"chapter_id": 223,
"created_at": "2019-09-17 17:00:55",
"updated_at": "2019-09-17 17:00:55",
"available_at": null,
"detail": {
"id": 8,
"duration": 210,
"start_time": "2019-09-25 20:30:00",
"timezone": "America/Caracas",
"topic": "Li lingues differe",
"user_id": 5,
"gmt_time": "2019-09-25 16:30:00",
"type": "scheduled",
"offset": "-04:00",
"expired": false,
"sent": false,
"date_sent": null,
"course_id": 166,
"created_at": "2019-09-17 16:59:07",
"updated_at": "2019-09-17 16:59:07",
"deleted_at": null
}
},
{
"id": 742,
"order": 2,
"detail_id": 38,
"detail_type": "App\\Assignment",
"chapter_id": 223,
"created_at": "2019-09-17 17:00:59",
"updated_at": "2019-09-17 17:00:59",
"available_at": null,
"detail": {
"id": 38,
"course_id": 166,
"user_id": 5,
"title": "Omnicos directe al desirabilite",
"base": 100,
"due_date": null,
"allow_comments": false,
"mark_important": false,
"pin_top": false,
"affects_score": true,
"post_date": null,
"timezone": null,
"gmt_time": null,
"offset": null,
"created_at": "2019-09-17 16:58:40",
"updated_at": "2019-09-17 16:58:40"
}
}
]
}
],
"last_expirations": [
],
"settings": {
"id": 3,
"course_id": 166,
"deactivation_date": null,
"assignment_time": "",
"created_at": "2017-08-02 15:02:21",
"updated_at": "2019-09-17 17:26:04",
"completation_setting": 100,
"sequence": "None",
"price": "5.5"
},
"reviews": [
{
"id": 32,
"review": "Excelente curso, lo recomiendo.",
"score": "5",
"user_id": 20,
"course_id": 166,
"created_at": "2018-09-02 22:17:12",
"updated_at": "2018-09-02 22:17:12",
"user": {
"username": "mariaperez",
"name": "María",
"last_name": "Pérez",
"email": "mariaperez@dominio.com"
}
},
{
"id": 43,
"review": "Aprendí mucho",
"score": "3.5",
"user_id": 16,
"course_id": 166,
"created_at": "2018-09-02 22:22:09",
"updated_at": "2018-09-02 22:22:09",
"user": {
"username": "luismeza",
"name": "Luis",
"last_name": "Meza",
"email": "luismeza@dominio.com"
}
}
],
"objectives": [
{
"id": 231,
"objective": "Sed ut perspiciatis unde omnis iste natus error sit volupt",
"order": 1
},
{
"id": 232,
"objective": "Nemo enim ipsam voluptatem quia voluptas sit",
"order": 2
}
],
"requirements": [
{
"id": 173,
"requirement": "Neque porro quisquam est",
"order": 1
},
{
"id": 174,
"requirement": "Ut enim ad minima veniam, quis nostrum exercitationem",
"order": 2
}
]
}
Esta respuesta se obtiene cuando la petición fue exitosa. La respuesta de ejemplo muestra los detalles del curso con dos capítulos y diferentes tipos de lecciones.
Nota: Utilizando como ejemplo los parámetros lang=es y multi_lang=false, la estructura de las categorías y subcategorías se mostrará de la siguiente manera:
"category": {
"id": 11,
"slug": "idiomas",
"name": "Idiomas",
"co_parent": -1
},
"subcategory": {
"id": 13,
"slug": "ingles",
"name": "Inglés",
"co_parent": 11
},
Status: 400 Bad Request
[«Bad request»]
Esta respuesta se obtiene cuando la petición falla.
Status: 401 Unauthorized
[«Unauthorized»]
Esta respuesta se obtiene cuando la llave (key) enviada en la cabecera «Authorization» de la petición no es válida.
Status: 404 Not Found
[«Not Found»]
Esta respuesta se obtiene cuando el URL al cual se está haciendo la petición está incorrecto.
Leave A Comment?