Skip to main content

Overview

Topics represent individual subjects or themes within a unit. Each topic belongs to a specific unit and includes a difficulty level, description, and customizable order. Topics are the most granular level of academic content organization in the system.

Endpoints

List All Topics

curl -X GET "https://api.example.com/api/topics" \
  -H "Accept: application/json"

Response

success
boolean
Indicates if the request was successful
message
string
Response message: “Temas listado con éxito”
data
array
Array of topic objects
{
  "success": true,
  "message": "Temas listado con éxito",
  "data": [
    {
      "id": 1,
      "units_id": 1,
      "tema": "Propiedades de los Números Naturales",
      "descripcion": "Estudio de las propiedades fundamentales de los números naturales",
      "orden": 1,
      "nivel_dificultad": "Básico",
      "created_at": "2026-03-05T10:30:00.000000Z",
      "updated_at": "2026-03-05T10:30:00.000000Z"
    },
    {
      "id": 2,
      "units_id": 1,
      "tema": "Operaciones con Números Naturales",
      "descripcion": "Suma, resta, multiplicación y división de números naturales",
      "orden": 2,
      "nivel_dificultad": "Intermedio",
      "created_at": "2026-03-05T10:31:00.000000Z",
      "updated_at": "2026-03-05T10:31:00.000000Z"
    }
  ]
}

Create a Topic

curl -X POST "https://api.example.com/api/topics" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "units_id": 1,
    "tema": "Números Primos",
    "descripcion": "Identificación y propiedades de los números primos",
    "orden": 3,
    "nivel_dificultad": "Avanzado"
  }'

Request Body

Response

success
boolean
Indicates if the request was successful
message
string
Response message: “Tema creado con éxito”
data
object
The created topic object
{
  "success": true,
  "message": "Tema creado con éxito",
  "data": {
    "id": 3,
    "units_id": 1,
    "tema": "Números Primos",
    "descripcion": "Identificación y propiedades de los números primos",
    "orden": 3,
    "nivel_dificultad": "Avanzado",
    "created_at": "2026-03-05T10:35:00.000000Z",
    "updated_at": "2026-03-05T10:35:00.000000Z"
  }
}

Get a Topic

curl -X GET "https://api.example.com/api/topics/1" \
  -H "Accept: application/json"

Path Parameters

Response

success
boolean
Indicates if the request was successful
message
string
Response message: “Tema obtenido con éxito”
data
object
The topic object
{
  "success": true,
  "message": "Tema obtenido con éxito",
  "data": {
    "id": 1,
    "units_id": 1,
    "tema": "Propiedades de los Números Naturales",
    "descripcion": "Estudio de las propiedades fundamentales de los números naturales",
    "orden": 1,
    "nivel_dificultad": "Básico",
    "created_at": "2026-03-05T10:30:00.000000Z",
    "updated_at": "2026-03-05T10:30:00.000000Z"
  }
}

Update a Topic

curl -X PUT "https://api.example.com/api/topics/1" \
  -H "Accept: application/json" \
  -H "Content-Type: application/json" \
  -d '{
    "units_id": 1,
    "tema": "Propiedades y Clasificación de Números Naturales",
    "descripcion": "Estudio completo de las propiedades fundamentales y clasificación de los números naturales",
    "orden": 1,
    "nivel_dificultad": "Intermedio"
  }'

Path Parameters

Request Body

Response

success
boolean
Indicates if the request was successful
message
string
Response message: “Tema actualizado con éxito”
data
object
The updated topic object
{
  "success": true,
  "message": "Tema actualizado con éxito",
  "data": {
    "id": 1,
    "units_id": 1,
    "tema": "Propiedades y Clasificación de Números Naturales",
    "descripcion": "Estudio completo de las propiedades fundamentales y clasificación de los números naturales",
    "orden": 1,
    "nivel_dificultad": "Intermedio",
    "created_at": "2026-03-05T10:30:00.000000Z",
    "updated_at": "2026-03-05T11:45:00.000000Z"
  }
}

Delete a Topic

curl -X DELETE "https://api.example.com/api/topics/1" \
  -H "Accept: application/json"

Path Parameters

Response

success
boolean
Indicates if the request was successful
message
string
Response message: “Tema eliminado con éxito”
data
null
Returns null for successful deletions
{
  "success": true,
  "message": "Tema eliminado con éxito",
  "data": null
}

Relationships

Unit (Parent)

Each topic must belong to a unit. The units_id field is a foreign key that references the units table. When a unit is deleted, all its topics are automatically deleted (cascade delete).

Database Schema

The topics table includes:
  • id - Primary key (auto-increment)
  • units_id - Foreign key to units table (cascade delete)
  • tema - String field for topic name (max 200 characters)
  • descripcion - Text field for description (nullable)
  • orden - Integer field for display order (default: 1)
  • nivel_dificultad - String field for difficulty level (default: “Básico”)
  • created_at - Timestamp for creation
  • updated_at - Timestamp for last update

Build docs developers (and LLMs) love