Single Requests

Single requests in PulsePI allow you to call a specific module and action with parameters.

Single Request Structure

A single request has three main components:

  • module: The module you want to interact with (string)
  • action: The specific action to perform (string)
  • params: Parameters for the action (object)

Basic Example

json
{
  "module": "posts",
  "action": "getPosts",
  "params": {}
}

This request calls the getPosts action in the posts module with no parameters.

Example with Parameters

json
{
  "module": "user",
  "action": "getByEmail",
  "params": {
    "email": "john.doe@example.com"
  }
}

This request calls the getByEmail action in the user module, passing an email parameter.

Response Format

A successful single request returns a response with this structure:

json
{
  "status": "success",
  "data": [
    // The returned data from the action
  ],
  "meta": {
    "executedAt": "2025-04-17T14:00:00.000Z"
  }
}
  • status: Always "success" for successful requests
  • data: The data returned by the action (array or object)
  • meta: Metadata about the request execution

Advanced Parameters

You can include special parameters in the params object:

json
{
  "module": "posts",
  "action": "getPosts",
  "params": {
    "_fields": ["title", "content", "author"],
    "filters": [
      { "published": true },
      { "category": "technology" }
    ]
  }
}
  • _fields: Specifies which fields to include in the response
  • filters: Filters the data based on specified conditions

Best Practices

  • Always specify only the fields you need using _fields to optimize response size
  • Use specific filters to reduce the amount of data transferred
  • Handle potential errors by checking for the error property in responses