Skip to main content

GET /api/components/export/view

Retrieves paginated tracking data for viewing. This endpoint is designed for administrative interfaces and dashboards where you need to display tracking records with pagination.

Endpoint

GET /api/components/export/view
Authentication: Required (JWT token)

Headers

Authorization
string
required
Bearer token for authenticationFormat: Bearer <jwt_token>Obtain the token from /api/auth/login or /api/auth/register endpoints (see Authentication)

Query Parameters

page
number
default:"1"
Page number to retrieve
  • Minimum value: 1
  • Invalid values are coerced to 1
  • Used to navigate through paginated results
limit
number
default:"10"
Number of records per page
  • Minimum value: 1
  • Maximum value: 25
  • Default: 10
  • Values outside this range are coerced to the nearest valid value

Response Fields

success
boolean
required
Indicates if the export was retrieved successfully
data
array
required
Array of tracking records for the current page
pagination
object
required
Pagination metadata

Response Example

200 - Success
{
  "success": true,
  "data": [
    {
      "id": "507f1f77bcf86cd799439012",
      "nombre_componente": "Button",
      "accion": "click",
      "timestamp": "2025-11-27T12:00:00.000Z",
      "tipo_usuario": "anonymous",
      "nombre_usuario": null
    },
    {
      "id": "507f1f77bcf86cd799439013",
      "nombre_componente": "Modal",
      "accion": "open",
      "timestamp": "2025-11-27T12:01:00.000Z",
      "tipo_usuario": "registered",
      "nombre_usuario": "Juan Pérez"
    },
    {
      "id": "507f1f77bcf86cd799439014",
      "nombre_componente": "Card",
      "accion": "hover",
      "timestamp": "2025-11-27T12:02:00.000Z",
      "tipo_usuario": "anonymous",
      "nombre_usuario": null
    }
  ],
  "pagination": {
    "page": 1,
    "limit": 10,
    "total": 150,
    "totalPages": 15,
    "hasNextPage": true,
    "hasPrevPage": false
  }
}

Example Requests

curl "http://localhost:3001/api/components/export/view" \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

Error Codes

CodeMessageCause
401Token no proporcionadoAuthorization header is missing
401Token inválidoJWT token is expired or malformed
500Error interno del servidorDatabase error or query failure

GET /api/components/export

Retrieves all tracking data without pagination. This endpoint is designed for full data exports, analytics processing, or backup purposes.

Endpoint

GET /api/components/export
Authentication: Required (JWT token)

Headers

Authorization
string
required
Bearer token for authenticationFormat: Bearer <jwt_token>Obtain the token from /api/auth/login or /api/auth/register endpoints (see Authentication)

Response Fields

success
boolean
required
Indicates if the export was retrieved successfully
data
array
required
Array of all tracking records (sorted by timestamp, newest first)

Response Example

200 - Success
{
  "success": true,
  "data": [
    {
      "_id": "507f1f77bcf86cd799439012",
      "nombre": "Button",
      "accion": "click",
      "timestamp": "2025-11-27T12:00:00.000Z",
      "tipo_usuario": "anonymous",
      "__v": 0
    },
    {
      "_id": "507f1f77bcf86cd799439013",
      "nombre": "Modal",
      "accion": "open",
      "timestamp": "2025-11-27T12:01:00.000Z",
      "tipo_usuario": "registered",
      "usuario": {
        "_id": "507f1f77bcf86cd799439011",
        "nombre": "Juan Pérez",
        "email": "[email protected]"
      },
      "__v": 0
    },
    {
      "_id": "507f1f77bcf86cd799439014",
      "nombre": "Card",
      "accion": "hover",
      "timestamp": "2025-11-27T12:02:00.000Z",
      "tipo_usuario": "anonymous",
      "__v": 0
    }
  ]
}

Example Request

curl http://localhost:3001/api/components/export \
  -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."

Error Codes

CodeMessageCause
401Token no proporcionadoAuthorization header is missing
401Token inválidoJWT token is expired or malformed
500Error interno del servidorDatabase error or query failure

Performance Considerations

This endpoint returns all tracking records. For large datasets, this may:
  • Take significant time to process
  • Consume substantial memory
  • Transfer large amounts of data
Consider using /api/components/export/view with pagination for regular data access.

Use Cases

Export View (Paginated)

  • Admin Dashboards: Display tracking data in tables with pagination controls
  • Real-time Monitoring: View recent interactions with manageable page sizes
  • Data Exploration: Navigate through records interactively
  • UI Components: Integrate with data tables and list components

Export (Full)

  • Data Backup: Export complete dataset for archival purposes
  • Analytics Processing: Download all data for analysis in external tools
  • Reporting: Generate comprehensive reports across all tracking data
  • Data Migration: Transfer data between systems or environments
  • Machine Learning: Export datasets for training or analysis

Implementation Details

  • Records are sorted by timestamp in descending order (most recent first)
  • The paginated view populates only the user’s name (tracking.service.ts:82)
  • The full export populates user name and email (tracking.service.ts:113)
  • Maximum page size is capped at 25 records to prevent abuse (components.controller.ts:49)
  • Invalid page/limit values are automatically corrected (components.controller.ts:48-49)

Build docs developers (and LLMs) love