Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/BladimirGS/judicial-backend/llms.txt

Use this file to discover all available pages before exploring further.

The statistics export endpoint accepts filter criteria in a JSON request body and responds with a binary Excel workbook (.xlsx) containing multiple sheets. Unlike the GET export endpoints in the search module, this endpoint uses a POST method so that filters are transmitted as structured JSON rather than query string parameters. The generated workbook consolidates the flat report, grouped summary, and a chart-ready data sheet into a single download.

Endpoint

POST /api/estadisticas/exportar
Authentication: Authorization: Bearer <token>

Request body

The request body must be a JSON object with a required filtros key containing the filter criteria, and an optional imagenBase64 key for embedding a chart image into the workbook. Content-Type: application/json
filtros
object
required
Filter criteria object. At least one field inside filtros must be present and non-empty. A request body with an empty filtros object — or a body that omits all filter keys inside it — will receive a 400 Bad Request response.
imagenBase64
string
Optional. A Base64-encoded PNG or JPEG image (e.g. a chart screenshot from the client) to embed in the generated workbook. When provided, the image is inserted into one of the Excel sheets alongside the statistical data.
At least one filter field inside filtros must be present and non-empty. The filter set is validated using EstadisticaFiltrosDTO.tieneFiltros().

Example request body

{
  "filtros": {
    "idSala": 1,
    "fechaInicio": "2024-01-01",
    "fechaFin": "2024-12-31"
  }
}

Example request body with chart image

{
  "filtros": {
    "idSala": 1,
    "fechaInicio": "2024-01-01",
    "fechaFin": "2024-12-31"
  },
  "imagenBase64": "iVBORw0KGgoAAAANSUhEUgAA..."
}

Response 200 — Excel workbook

The response is a binary Excel file stream. The file contains three sheets:
Sheet nameContent
planoRow-level flat statistical records equivalent to GET /api/estadisticas/plano (unpaginated).
agrupadoSummary rows grouped by sala, equivalent to the grupos array from GET /api/estadisticas/agrupado.
gráficoChart-ready data derived from the grouped data, formatted for direct use as a chart data source in Excel.
Response headers:
HeaderValue
Content-Typeapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet
Content-Dispositionattachment; filename=estadisticas.xlsx
Body: Binary .xlsx file stream. Save the response body directly to a file.
When calling this endpoint from a browser or front-end client, use the Content-Disposition header to trigger the file-download dialog. With fetch, read the response as a Blob and create an object URL.

Error responses

StatusMeaning
400 Bad RequestThe filtros object contains no valid filter fields, or all filter values are empty.
401 UnauthorizedMissing or invalid Authorization bearer token.

Examples

Export statistics for a full year

curl -X POST http://localhost:4000/api/estadisticas/exportar \
  -H 'Authorization: Bearer <token>' \
  -H 'Content-Type: application/json' \
  -d '{"filtros": {"idSala": 1, "fechaInicio": "2024-01-01", "fechaFin": "2024-12-31"}}' \
  -o estadisticas.xlsx

Export filtered by nomenclatura and appeal type

curl -X POST http://localhost:4000/api/estadisticas/exportar \
  -H 'Authorization: Bearer <token>' \
  -H 'Content-Type: application/json' \
  -d '{"filtros": {"idNomenclatura": 2, "idApelacion": 5, "fechaInicio": "2023-01-01", "fechaFin": "2023-12-31"}}' \
  -o estadisticas.xlsx

JavaScript (fetch) example

const response = await fetch('http://localhost:4000/api/estadisticas/exportar', {
  method: 'POST',
  headers: {
    'Authorization': 'Bearer <token>',
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    filtros: {
      idSala: 1,
      fechaInicio: '2024-01-01',
      fechaFin: '2024-12-31',
    },
  }),
});

if (!response.ok) {
  throw new Error(`Export failed: ${response.status}`);
}

const blob = await response.blob();
const url = URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'estadisticas.xlsx';
a.click();
URL.revokeObjectURL(url);

Build docs developers (and LLMs) love