Skip to main content

Overview

The Noticias API allows you to manage news articles in the MTB Backend system. Each article includes a title, slug, main image, summary, content, publication date, author, and publication status.
This endpoint supports draft and publish functionality. Use the publishedAt field to control publication status.

List All Noticias

Retrieve a list of all news articles with optional filtering, sorting, and pagination.

Query Parameters

filters
object
Filter articles by field values. Example: filters[publicado][$eq]=true
sort
string
Sort articles by field(s). Example: fecha:desc for newest first
pagination[page]
number
default:"1"
Page number for pagination
pagination[pageSize]
number
default:"25"
Number of items per page
populate
string
Populate relations. Use * for all relations or specify fields like imagenPrincipal

Response

data
array
Array of noticia objects
meta
object
Pagination metadata

Example Request

curl -X GET "https://api.example.com/api/noticias?populate=*&sort=fecha:desc&filters[publicado][$eq]=true" \
  -H "Content-Type: application/json"

Example Response

{
  "data": [
    {
      "id": 1,
      "attributes": {
        "titulo": "Gran Evento de MTB 2024",
        "slug": "gran-evento-de-mtb-2024",
        "resumen": "Se anuncia el evento más importante del año en el mundo del mountain bike.",
        "contenido": [
          {
            "type": "paragraph",
            "children": [
              {"type": "text", "text": "El próximo mes se llevará a cabo..."}
            ]
          }
        ],
        "fecha": "2024-01-20",
        "autor": "Juan Pérez",
        "publicado": true,
        "imagenPrincipal": {
          "data": {
            "id": 1,
            "attributes": {
              "url": "/uploads/evento_mtb.jpg",
              "alternativeText": "Evento MTB"
            }
          }
        },
        "publishedAt": "2024-01-20T10:00:00.000Z",
        "createdAt": "2024-01-15T10:00:00.000Z",
        "updatedAt": "2024-01-20T10:00:00.000Z"
      }
    }
  ],
  "meta": {
    "pagination": {
      "page": 1,
      "pageSize": 25,
      "pageCount": 1,
      "total": 1
    }
  }
}

Get a Single Noticia

Retrieve a specific news article by its ID.

Path Parameters

id
number
required
The unique identifier of the article

Query Parameters

populate
string
Populate relations. Use * for all relations or specify fields like imagenPrincipal

Response

data
object
The noticia object (see List All Noticias for structure)

Example Request

curl -X GET "https://api.example.com/api/noticias/1?populate=*" \
  -H "Content-Type: application/json"

Example Response

{
  "data": {
    "id": 1,
    "attributes": {
      "titulo": "Gran Evento de MTB 2024",
      "slug": "gran-evento-de-mtb-2024",
      "resumen": "Se anuncia el evento más importante del año en el mundo del mountain bike.",
      "contenido": [...],
      "fecha": "2024-01-20",
      "autor": "Juan Pérez",
      "publicado": true,
      "imagenPrincipal": {...},
      "publishedAt": "2024-01-20T10:00:00.000Z",
      "createdAt": "2024-01-15T10:00:00.000Z",
      "updatedAt": "2024-01-20T10:00:00.000Z"
    }
  }
}

Create a Noticia

Create a new news article.

Request Body

data
object
required

Response

data
object
The created noticia object

Example Request

curl -X POST "https://api.example.com/api/noticias" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{
    "data": {
      "titulo": "Nueva Ruta de MTB Inaugurada",
      "resumen": "Se inaugura una nueva ruta de mountain bike en la región.",
      "contenido": [
        {
          "type": "paragraph",
          "children": [{"type": "text", "text": "La nueva ruta ofrece 15 km de pistas..."}]
        }
      ],
      "fecha": "2024-01-25",
      "autor": "María González",
      "publicado": true
    }
  }'

Example Response

{
  "data": {
    "id": 2,
    "attributes": {
      "titulo": "Nueva Ruta de MTB Inaugurada",
      "slug": "nueva-ruta-de-mtb-inaugurada",
      "resumen": "Se inaugura una nueva ruta de mountain bike en la región.",
      "contenido": [...],
      "fecha": "2024-01-25",
      "autor": "María González",
      "publicado": true,
      "imagenPrincipal": {"data": null},
      "publishedAt": "2024-01-25T10:00:00.000Z",
      "createdAt": "2024-01-25T10:00:00.000Z",
      "updatedAt": "2024-01-25T10:00:00.000Z"
    }
  }
}

Update a Noticia

Update an existing news article by its ID.

Path Parameters

id
number
required
The unique identifier of the article to update

Request Body

data
object
required
Noticia fields to update (same structure as Create)

Response

data
object
The updated noticia object

Example Request

curl -X PUT "https://api.example.com/api/noticias/1" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{
    "data": {
      "titulo": "Gran Evento de MTB 2024 - Actualizado",
      "publicado": false
    }
  }'

Example Response

{
  "data": {
    "id": 1,
    "attributes": {
      "titulo": "Gran Evento de MTB 2024 - Actualizado",
      "slug": "gran-evento-de-mtb-2024",
      "resumen": "Se anuncia el evento más importante del año en el mundo del mountain bike.",
      "contenido": [...],
      "fecha": "2024-01-20",
      "autor": "Juan Pérez",
      "publicado": false,
      "imagenPrincipal": {...},
      "publishedAt": "2024-01-20T10:00:00.000Z",
      "createdAt": "2024-01-15T10:00:00.000Z",
      "updatedAt": "2024-01-25T11:00:00.000Z"
    }
  }
}

Delete a Noticia

Delete a news article by its ID.

Path Parameters

id
number
required
The unique identifier of the article to delete

Response

data
object
The deleted noticia object

Example Request

curl -X DELETE "https://api.example.com/api/noticias/1" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN"

Example Response

{
  "data": {
    "id": 1,
    "attributes": {
      "titulo": "Gran Evento de MTB 2024 - Actualizado",
      "slug": "gran-evento-de-mtb-2024",
      "resumen": "Se anuncia el evento más importante del año en el mundo del mountain bike.",
      "contenido": [...],
      "fecha": "2024-01-20",
      "autor": "Juan Pérez",
      "publicado": false,
      "imagenPrincipal": {...},
      "publishedAt": "2024-01-20T10:00:00.000Z",
      "createdAt": "2024-01-15T10:00:00.000Z",
      "updatedAt": "2024-01-25T11:00:00.000Z"
    }
  }
}
Important: Deleting a news article is permanent and cannot be undone. Consider unpublishing articles instead by setting publicado to false.

Build docs developers (and LLMs) love