Definição da API - Privada (v1)
Introdução
Neste artigo você poderá encontrar a estrutura da API da sua plataforma disponível a partir do plano Business.
A API utiliza arquitetura RESTful (representational state transfer).
Autenticação
A autenticação deve ser feita utilizando o APP_ID e API_KEY que podem ser geradas pela página API no PAINEL DO ADMINISTRADOR ("Painel do administrador" -> "API")
Esses parâmetros devem ser informados no HEADER da requisição, no seguinte formato:
HEADER = {
Content-Type: application/json,
app-id: "LTHDT9EQIU5PXFDR2WLLER93TCISZYXR",
api-key: "ZULoIPoY9wqYV5EpuFDUfKsdGJnRyGPD"
}
Endpoints
Os endpoints da API utilizam o EAD_ID, que também pode ser encontrado na página API, junto com o APP_ID e API_KEY.
O endpoint base é: https://<EAD_ID>.ead.guru/api/v1
A API v1 possui 3 endpoints:
Usuários
https://EAD_ID.ead.guru/api/v1/users/
Cursos
https://EAD_ID.ead.guru/api/v1/courses/
Matrículas
https://EAD_ID.ead.guru/api/v1/enrols/
Usuários
Listar usuários
GET /api/v1/users/
Parâmetros:
page (opcional): integer
is_active (opcional): boolean
suspended (opcional): boolean
admin (opcional): boolean
teacher (opcional): boolean
Exemplo de requisição:
curl --request GET \
--url 'https://EAD_ID.ead.guru/api/v1/users/?page=1&is_active=true' \
--header 'api-key: ZULoIPoY9wqYV5EpuFDUfKsdGJnRyGPD' \
--header 'app-id: LTHDT9EQIU5PXFDR2WLLER93TCISZYXR'
Exemplo de resposta:
{
"success": true,
"current_page": 1,
"total_entries": 2,
"total_pages": 1,
"data": [
{
"id": 1,
"username": "joao_silva",
"first_name": "João",
"last_name": "Silva",
"email": "joao@mail.com",
"date_joined": "2020-04-01T12:30:00.00001-03:00"
},
{
"id": 2,
"username": "jose_silva",
"first_name": "José",
"last_name": "da Silva",
"email": "jose@mail.com",
"date_joined": "2020-04-02T12:30:00.00001-03:00"
}
}
Detalhes de um usuário
GET /api/v1/users/<id>/
Parâmetros PATH:
id* (obrigatório): integer
Exemplo de requisição:
curl --request GET \
--url https://EAD_ID.ead.guru/api/v1/users/2/ \
--header 'api-key: ZULoIPoY9wqYV5EpuFDUfKsdGJnRyGPD' \
--header 'app-id: LTHDT9EQIU5PXFDR2WLLER93TCISZYXR'
Exemplo de resposta:
{
"success": true,
"data": {
"id": 2,
"username": "jose_silva",
"first_name": "José",
"last_name": "da Silva",
"email": "jose@mail.com",
"last_login": "2020-04-10T13:38:21.29377-03:00",
"date_joined": "2020-04-02T12:30:00.00001-03:00",
"is_active": true,
"profile": {
"suspended": false,
"admin": false,
"teacher": true,
"last_active": "2020-04-10T18:21:13.83761-03:00",
"phone": "+55 (11) 99999-9999",
"sex": "M",
"birth_date": "1990-01-01",
"bio": null,
"person_type": "F",
"cpf_cnpj": "17091605004",
"corporate_name": null,
"country": "br",
"zip_code": "01311-922",
"state": "SP",
"city": "São Paulo",
"district": "Bela Vista",
"street": "Av. Paulista",
"house_number": "1000",
"complement": "Ap 101",
"facebook": null,
"instagram": null,
"twitter": null,
"linkedin": null,
"github": null,
"youtube": null
}
}
}
Detalhes de um usuário buscando por email
GET /api/v1/users/<email>/search-email/
Parâmetros PATH:
email* (obrigatório): string
Exemplo de requisição:
curl --request GET \
--url https://EAD_ID.ead.guru/api/v1/users/jose@mail.com/search-email/ \
--header 'api-key: ZULoIPoY9wqYV5EpuFDUfKsdGJnRyGPD' \
--header 'app-id: LTHDT9EQIU5PXFDR2WLLER93TCISZYXR'
Exemplo de resposta:
{
"success": true,
"data": {
"id": 2,
"username": "jose_silva",
"first_name": "José",
"last_name": "da Silva",
"email": "jose@mail.com",
"last_login": "2020-04-10T13:38:21.29377-03:00",
"date_joined": "2020-04-02T12:30:00.00001-03:00",
"is_active": true,
"profile": {
"suspended": false,
"admin": false,
"teacher": true,
"last_active": "2020-04-10T18:21:13.83761-03:00",
"phone": "+55 (11) 99999-9999",
"sex": "M",
"birth_date": "1990-01-01",
"bio": null,
"person_type": "F",
"cpf_cnpj": "17091605004",
"corporate_name": null,
"country": "br",
"zip_code": "01311-922",
"state": "SP",
"city": "São Paulo",
"district": "Bela Vista",
"street": "Av. Paulista",
"house_number": "1000",
"complement": "Ap 101",
"facebook": null,
"instagram": null,
"twitter": null,
"linkedin": null,
"github": null,
"youtube": null
}
}
}
Criar usuário
POST /api/v1/users/
Parâmetros:
email* (obrigatório): string (max 250 chars)
first_name* (obrigatório): string (max 30 chars)
last_name* (obrigatório): string (max 30 chars)
username (opcional): string (max 150 chars)
password (opcional): string (max 250 chars)
date_joined (opcional): date (ISO 8601)
teacher (opcional): boolean (default false)
admin (opcional): boolean (default false)
suspended (opcional): boolean (default false)
sex (opcional): string ("M" ou "F")
phone (opcional): string (max 50 chars)
birth_date (opcional): date (ISO 8601)
bio (opcional): string
person_type (opcional): string ("F" - Pessoa física ou "J" - Pessoa jurídica)
cpf_cnpj (opcional): string (11 chars para CPF ou 14 chars para CNPJ)
corporate_name (opcional): string (max 250 chars)
country (opcional): string (Código de 2 chars ISO 3166)
zip_code (opcional): string (8 chars)
state (opcional): string (Código de 2 chars)
city (opcional): string (max 100 chars)
district (opcional): string (max 100 chars)
street (opcional): string (max 100 chars)
house_number (opcional): string (max 10 chars)
complement (opcional): string (max 100 chars)
Exemplo de requisição:
curl --request POST \
--url https://EAD_ID.ead.guru/api/v1/users/ \
--header 'api-key: ZULoIPoY9wqYV5EpuFDUfKsdGJnRyGPD' \
--header 'app-id: LTHDT9EQIU5PXFDR2WLLER93TCISZYXR' \
--header 'content-type: application/json' \
--data '{
"username": "maria_silva",
"email": "maria@mail.com",
"first_name": "Maria",
"last_name": "Silva",
"date_joined": "2020-04-10T10:40:55.623312-03:00",
"teacher": true,
"admin": false,
"suspended": false,
"sex": "F",
"phone": "+55 (11) 99999-9999"
}
Exemplo de resposta:
{
"success": true,
"data": {
"id": 2,
"username": "maria_silva",
"first_name": "Maria",
"last_name": "Silva",
"email": "maria@mail.com",
"last_login": null,
"date_joined": "2020-04-10T10:40:55.623312-03:00",
"is_active": true,
"profile": {
"suspended": false,
"admin": false,
"teacher": true,
"last_active": null,
"phone": "+55 (11) 99999-9999",
"sex": "F",
"birth_date": null,
"bio": null,
"person_type": "F",
"cpf_cnpj": null,
"corporate_name": null,
"country": null,
"zip_code": null,
"state": null,
"city": null,
"district": null,
"street": null,
"house_number": null,
"complement": null,
"facebook": null,
"instagram": null,
"twitter": null,
"linkedin": null,
"github": null,
"youtube": null
}
}
}
Editar usuário
PUT /api/v1/users/<id>/
Parâmetros PATH:
id* (obrigatório): integer
Parâmetros:
email (opcional): string (max 250 chars)
first_name (opcional): string (max 30 chars)
last_name (opcional): string (max 30 chars)
username (opcional): string (max 150 chars)
teacher (opcional): boolean (default false)
admin (opcional): boolean (default false)
suspended (opcional): boolean (default false)
sex (opcional): string ("M" ou "F")
phone (opcional): string (max 50 chars)
birth_date (opcional): date (ISO 8601)
bio (opcional): string
person_type (opcional): string ("F" - Pessoa física ou "J" - Pessoa jurídica)
cpf_cnpj (opcional): string (11 chars para CPF ou 14 chars para CNPJ)
corporate_name (opcional): string (max 250 chars)
country (opcional): string (Código de 2 chars ISO 3166)
zip_code (opcional): string (8 chars)
state (opcional): string (Código de 2 chars)
city (opcional): string (max 100 chars)
district (opcional): string (max 100 chars)
street (opcional): string (max 100 chars)
house_number (opcional): string (max 10 chars)
complement (opcional): string (max 100 chars)
Exemplo de requisição:
curl --request PUT \
--url https://EAD_ID.ead.guru/api/v1/users/3/ \
--header 'api-key: ZULoIPoY9wqYV5EpuFDUfKsdGJnRyGPD' \
--header 'app-id: LTHDT9EQIU5PXFDR2WLLER93TCISZYXR' \
--header 'content-type: application/json' \
--data '{
"teacher": false,
"admin": false,
"suspended": true,
"country": "br",
"zip_code": "22041-001",
"state": "RJ",
"city": "Rio de Janeiro",
"district": "Copacabana",
"street": "Avenida Atlântica",
"house_number": "2000",
"complement": null
}'
Exemplo de resposta:
{
"success": true,
"data": {
"id": 2,
"username": "maria_silva",
"first_name": "Maria",
"last_name": "Silva",
"email": "maria@mail.com",
"last_login": null,
"date_joined": "2020-04-10T10:40:55.623312-03:00",
"is_active": true,
"profile": {
"suspended": true,
"admin": false,
"teacher": false,
"last_active": null,
"phone": "+55 (11) 99999-9999",
"sex": "F",
"birth_date": null,
"bio": null,
"person_type": "F",
"cpf_cnpj": null,
"corporate_name": null,
"country": br,
"zip_code": "22041-001",
"state": "RJ",
"city": "Rio de Janeiro",
"district": "Copacabana",
"street": "Avenida Atlântica",
"house_number": "2000",
"complement": null,
"facebook": null,
"instagram": null,
"twitter": null,
"linkedin": null,
"github": null,
"youtube": null
}
}
}
Excluir usuário
DELETE /api/v1/users/<id>/
Parâmetros PATH:
id* (obrigatório): integer
Exemplo de requisição:
curl --request DELETE \
--url https://EAD_ID.ead.guru/api/v1/users/3/ \
--header 'api-key: ZULoIPoY9wqYV5EpuFDUfKsdGJnRyGPD' \
--header 'app-id: LTHDT9EQIU5PXFDR2WLLER93TCISZYXR'
Exemplo de resposta:
{
"success": true,
"user_id": 3
}
Cursos
Listar cursos
GET /api/v1/courses/
Parâmetros:
page (opcional): integer
open_to_enroll (opcional): boolean
active (opcional): boolean
Exemplo de requisição:
curl --request GET \
--url 'https://EAD_ID.ead.guru/api/v1/courses/?page=1&active=true' \
--header 'api-key: ZULoIPoY9wqYV5EpuFDUfKsdGJnRyGPD' \
--header 'app-id: LTHDT9EQIU5PXFDR2WLLER93TCISZYXR'
Exemplo de resposta:
{
"success": true,
"current_page": 1,
"total_pages": 1,
"total_entries": 2,
"data": [
{
"id": 1,
"name": "Curso de Teste",
"open_to_enroll": false,
"active": true,
"slug": "curso-de-teste",
"price": "100.00",
"created": "2020-02-04T09:45:40.499802-03:00"
},
{
"id": 2,
"name": "Curso preparatório",
"open_to_enroll": true,
"active": true,
"slug": "curso-preparatorio",
"price": "50.00",
"created": "2020-02-04T09:55:50.088000-03:00"
}
]
}
Detalhes de um curso
GET /api/v1/courses/<id>/
Parâmetros PATH:
id* (obrigatório): integer
Exemplo de requisição:
curl --request GET \
--url https://EAD_ID.ead.guru/api/v1/courses/2/ \
--header 'api-key: ZULoIPoY9wqYV5EpuFDUfKsdGJnRyGPD' \
--header 'app-id: LTHDT9EQIU5PXFDR2WLLER93TCISZYXR'
Exemplo de resposta:
{
"success": true,
"data": {
"id": 2,
"name": "Curso preparatório",
"open_to_enroll": true,
"active": true,
"slug": "curso-preparatorio",
"created": "2020-02-04T09:55:50.088000-03:00",
"category": null,
"description": null,
"short_description": null,
"launch_date": null,
"syllabus": null,
"upgrade_to": null,
"upgrade_price": null,
"workload": 1,
"forum_enabled": true,
"show_score": false,
"active_comments": false,
"show_enrols_count": false,
"expiry_date": null,
"price": "50.00",
"number_of_installments": 1,
"installment_interest": "1.9",
"teachers": [
{
"teacher_id": 2
}
]
}
}
Criar curso
POST /api/v1/courses/
Parâmetros:
teachers_ids* (obrigatório): list of integers (max 5 teachers)
name* (obrigatório): string (max 100chars)
description (opcional): string
short_description (opcional): string (max 140 chars)
launch_date (opcional): date (ISO 8601)
syllabus (opcional): string
open_to_enroll (opcional): boolean (default false)
active (opcional): boolean (default true)
price (opcional): float (default 0.00)
slug (opcional): string (Apenas letras minúsculas e o caracter "-" como espaço)
workload (opcional): integer (default 1)
forum_enabled (opcional): boolean (default true)
show_score (opcional): boolean (default false)
active_comments (opcional): boolean (default false)
show_enrols_count (opcional): boolean (default false)
grade_certificate (opcional): integer (_deprecated_)
show_grade_certificate (opcional): boolean (default false) (_deprecated_)
expiry_date (opcional): integer (Número de meses até o vencimento da matrícula)
number_of_installments (opcional): integer (min 1, max 12)
Exemplo de requisição:
curl --request POST \
--url https://EAD_ID.ead.guru/api/v1/courses/ \
--header 'api-key: ZULoIPoY9wqYV5EpuFDUfKsdGJnRyGPD' \
--header 'app-id: LTHDT9EQIU5PXFDR2WLLER93TCISZYXR' \
--header 'content-type: application/json' \
--data '{
"teachers_ids": [2, 3],
"name": "Curso API",
"description": "Descrição teste",
"short_description": "Descrição resumida teste",
"launch_date": "2020-12-01T12:00:00.000000-03:00",
"syllabus": "Ementa teste",
"open_to_enroll": false,
"active": true,
"price": 49.99,
"slug": "curso-api",
"workload": 10,
"expiry_date": null
}'
Exemplo de resposta:
{
"success": true,
"data": {
"id": 3,
"name": "Curso API",
"open_to_enroll": false,
"active": true,
"slug": "curso-api",
"created": "2020-10-04T10:30:25.589061-03:00",
"category": null, "description": "Descrição teste",
"short_description": "Descrição resumida teste",
"launch_date": "2020-12-01T12:00:00.000000-03:00",
"syllabus": "Ementa teste",
"upgrade_to": null,
"upgrade_price": null,
"workload": 10,
"forum_enabled": true,
"show_score": false,
"active_comments": false,
"show_enrols_count": false,
"expiry_date": null,
"price": "49.99",
"number_of_installments": 1,
"installment_interest": "1.9",
"teachers": [
{
"teacher_id": 2
},
{
"teacher_id": 3
}
]
}
}
Editar curso
PUT /api/v1/courses/<id>/
Parâmetros PATH:
id* (obrigatório): integer
Parâmetros:
teachers_ids (opcional): list of integers (max 5 teachers)
name (opcional): string (max 100chars)
description (opcional): string
short_description (opcional): string (max 140 chars)
launch_date (opcional): date (ISO 8601)
syllabus (opcional): string
open_to_enroll (opcional): boolean
active (opcional): boolean
price (opcional): float
slug (opcional): string (Apenas letras minúsculas e o caracter "-" como espaço)
workload (opcional): integer
forum_enabled (opcional): boolean
show_score (opcional): boolean
active_comments (opcional): boolean
show_enrols_count (opcional): boolean
grade_certificate (opcional): integer (_deprecated_)
show_grade_certificate (opcional): boolean (_deprecated_)
expiry_date (opcional): integer (Número de meses até o vencimento da matrícula)
number_of_installments (opcional): integer (min 1, max 12)
installment_interest (opcional): float (min 0, max 99. Obrigatório caso number_of_installments seja informado)
Exemplo de requisição:
curl --request PUT \
--url https://EAD_ID.ead.guru/api/v1/courses/3/ \
--header 'api-key: ZULoIPoY9wqYV5EpuFDUfKsdGJnRyGPD' \
--header 'app-id: LTHDT9EQIU5PXFDR2WLLER93TCISZYXR' \
--header 'content-type: application/json' \
--data '{
"teachers_ids": [2, 4],
"open_to_enroll": true,
"description": "Nova descrição"
}'
Exemplo de resposta:
{
"success": true,
"data": {
"id": 3,
"name": "Curso API",
"open_to_enroll": true,
"active": true,
"slug": "curso-api",
"created": "2020-10-04T10:30:25.589061-03:00",
"category": null,
"description": "Nova descrição",
"short_description": "Descrição resumida teste",
"launch_date": "2020-12-01T12:00:00.000000-03:00",
"syllabus": "Ementa teste",
"upgrade_to": null,
"upgrade_price": null,
"workload": 10,
"forum_enabled": true,
"show_score": false,
"active_comments": false,
"show_enrols_count": false,
"expiry_date": null,
"price": "49.99",
"number_of_installments": 1,
"installment_interest": "1.9",
"teachers": [
{
"teacher_id": 2
},
{
"teacher_id": 4
}
]
}
}
Excluir curso
DELETE /api/v1/courses/<id>/
Parâmetros PATH:
id* (obrigatório): integer
Exemplo de requisição:
curl --request DELETE \
--url https://EAD_ID.ead.guru/api/v1/courses/1/ \
--header 'api-key: ZULoIPoY9wqYV5EpuFDUfKsdGJnRyGPD' \
--header 'app-id: LTHDT9EQIU5PXFDR2WLLER93TCISZYXR'
Exemplo de resposta:
{
"success": true,
"course_id": 1
}
Matrículas
Listar matrículas
GET /api/v1/enrols/
Parâmetros:
page (opcional): integer
course (opcional): integer
user (opcional): integer
Exemplo de requisição:
curl --request GET \
--url 'https://EAD_ID.ead.guru/api/v1/enrols/?page=1&course=2' \
--header 'api-key: ZULoIPoY9wqYV5EpuFDUfKsdGJnRyGPD' \
--header 'app-id: LTHDT9EQIU5PXFDR2WLLER93TCISZYXR'
Exemplo de resposta:
{
"success": true,
"current_page": 1,
"total_pages": 1,
"total_entries": 2,
"data": [
{
"id": 1,
"student": 1,
"course": 2,
"active": true
},
{
"id": 4,
"student": 2,
"course": 2,
"active": true
}
}
Detalhes de uma matrícula
GET /api/v1/enrols/<id>/
Parâmetros PATH:
id* (obrigatório): integer
Exemplo de requisição:
curl --request GET \
--url https://EAD_ID.ead.guru/api/secure/enrols/4/ \
--header 'api-key: ZULoIPoY9wqYV5EpuFDUfKsdGJnRyGPD' \
--header 'app-id: LTHDT9EQIU5PXFDR2WLLER93TCISZYXR'
Exemplo de resposta:
{
"success": true,
"data": {
"id": 4,
"student": 2,
"course": 2,
"expiry_date": null,
"active": true,
"created": "2020-02-04T12:30:00.247000-03:00",
"updated": "2020-02-10T16:35:10.338758-03:00"
}
}
Criar matrícula
POST /api/v1/enrols/
Parâmetros:
user* (obrigatório): integer
course* (obrigatório): integer
expiry_date (opcional): date (ISO 8601)
active (opcional): boolean (default true)
send_email (opcional): boolean (default false)
*Atenção: Utilize a opção send_email=true apenas se tiver certeza que o email do aluno é válido. Caso ocorram muitos erros de envio de email por causa de email inválido, o seu EAD poderá ser suspenso.
Exemplo de requisição:
curl --request POST \
--url https://EAD_ID.ead.guru/api/v1/enrols/ \
--header 'api-key: ZULoIPoY9wqYV5EpuFDUfKsdGJnRyGPD' \
--header 'app-id: LTHDT9EQIU5PXFDR2WLLER93TCISZYXR' \
--header 'content-type: application/json' \
--data '{
"user": "3",
"course": "2"
}'
Exemplo de resposta:
{
"success": true,
"data": {
"id": 5,
"student": 3,
"course": 2,
"expiry_date": null,
"active": true,
"created": "2020-04-02T20:20:50.708849-03:00",
"updated": "2020-04-10T12:40:50.179511-03:00"
}
}
Editar matrícula
PUT /api/v1/enrols/<id>/
Parâmetros PATH:
id* (obrigatório): integer
Parâmetros:
expiry_date (opcional): date (ISO 8601)
active (opcional): boolean
Exemplo de requisição:
curl --request PUT \
--url https://EAD_ID.ead.guru/api/v1/enrols/5/ \
--header 'api-key: ZULoIPoY9wqYV5EpuFDUfKsdGJnRyGPD' \
--header 'app-id: LTHDT9EQIU5PXFDR2WLLER93TCISZYXR' \
--header 'content-type: application/json' \
--data '{
"expiry_date": "2020-06-10",
"active": true
}'
Exemplo de resposta:
{
"success": true,
"data": {
"id": 5,
"student": 3,
"course": 2,
"expiry_date": "2020-06-10",
"active": true,
"created": "2020-04-02T20:20:50.708849-03:00",
"updated": "2020-04-10T18:00:00.753982-03:00"
}
}
Atualizado em: 31/05/2024
Obrigado!