API Requests


With PushMetrics, you can make requests to any REST API endpoint.

It can be used to both receive data and send data to the API.

API results data can be used in subsequent tasks.


Creating API Requests

To compose an API request, you can make use the following input options:

Option Description
HTTP Method

This indicates the type of action you want to perform on the resource. The supported methods are:

GET: Retrieve data
POST: Submit data to be processed
PUT: Update data
DELETE: Remove data

Endpoint (URL)

This is the URL where the API service can be accessed.

Example:
https://api.example.com/users

Headers

These provide meta-information about the request or the response.

Common headers include:
Authorization: Contains credentials for authenticating the client with the server.
Content-Type: Specifies the media type of the resource or data.
Accept: Specifies the media types that the client can process.

Params (or Query Parameters)

typically used with GET requests to filter, sort, or specify the data you're looking for. They are included in the URL after a ? and are usually key-value pairs separated by &.

Example:
parameters = {"sort": "asc","role":"admin"}

On execution, will be turned into:https://api.example.com/users?sort=asc&role=admin

Data (or Body)

This contains information you want to send to the server. In a GET request, the data is typically sent as URL parameters. In POST or PUT requests, the data is sent in the request body.

Example:
"json": {"username": "john_doe", "email": "john@doe.com"}

Further Resources

PushMetrics uses the python requests library to execute requests server-side. Refer to the library's official documentation for more information:


Using Response Data

🚧
We are currently only handling JSON responses for API tasks.

After execution of a request, the response will be displayed below the request.

You can reference this data in other tasks using the .data method.

For example:

  • Use {{ api_call_1.data }}  to retrieve the entire response JSON
  • Use {{ api_call_1.data.results[0] }}  to retrieve the first element of the results array in the example above.

Chaining Multiple Requests

If you want to create a reusable task that needs to perform a series of chained API requests (e.g. first a request to authentitcate, then the actual request to receive data), you can do this in PushMetrics using a Custom App integration.