Skip to content

Data Access API

The API provides a powerful and generic endpoint for performing CRUD (Create, Read, Update, Delete) operations on all core data models. This approach simplifies client-side code by providing a consistent interface for data interaction.

  • Endpoint: /api/v1/data
  • Authentication: Required (Bearer Token) for all methods.

Every request to this endpoint must include a model query parameter to specify which data collection you are targeting.

  • Example: GET /api/v1/data?model=headline

The following model names are supported:

  • headline
  • topic
  • source
  • country (supports specialized filtering by usage for ‘eventCountry’ or ‘headquarters’)
  • language
  • user
  • user_app_settings
  • user_content_preferences
  • remote_config
  • dashboard_summary

Retrieves a paginated list of items for a specific model.

  • Method: GET
  • Path: /api/v1/data?model=<model_name>
  • filter (string, optional): A URL-encoded JSON string representing a MongoDB-style query.

  • sort (string, optional): A comma-separated list of fields to sort by (e.g., createdAt:desc,title:asc).

  • limit (integer, optional): The maximum number of items to return.

  • cursor (string, optional): The pagination cursor from a previous response to fetch the next page.

Request:

GET /api/v1/data?model=headline&filter={"status":"active"}

This fetches all headlines where the status field is "active".

  • Success Response:
    • 200 OK: Returns a standard success response with a PaginatedResponse<T> object as the data payload.

Creates a new item for a specific model.

  • Method: POST

  • Path: /api/v1/data?model=<model_name>

  • Body (JSON): The JSON representation of the model to create. The id, createdAt, and updatedAt fields will be automatically generated by the server and should be omitted from the request body.

  • Success Response:

    • 201 Created: Returns a standard success response with the newly created item object as the data payload.

Retrieves a single item by its unique ID.

  • Method: GET

  • Path: /api/v1/data/<item_id>?model=<model_name>

  • Success Response:

    • 200 OK: Returns a standard success response with the requested item object as the data payload.
  • Error Responses:

    • 404 Not Found: The item with the specified ID does not exist.

Updates an existing item by its unique ID.

  • Method: PUT
  • Path: /api/v1/data/<item_id>?model=<model_name>
  • Body (JSON): The full JSON representation of the model with the updated fields.
  • Success Response:

    • 200 OK: Returns a standard success response with the updated item object as the data payload.
  • Error Responses:

    • 404 Not Found: The item with the specified ID does not exist.

Deletes an item by its unique ID.

  • Method: DELETE

  • Path: /api/v1/data/<item_id>?model=<model_name>

  • Success Response:

    • 204 No Content: The item was successfully deleted.
  • Error Responses:

    • 404 Not Found: The item with the specified ID does not exist.