The API Node allows your pipeline to interact with external APIs by sending HTTP requests. Use an API node when you want to retrieve, send, or update data from an external service during pipeline execution.

Node Inputs

  1. Method: HTTP method for the request.
    • Type: Dropdown
    • Options: GET, POST, PUT, DELETE, PATCH
  2. URL: The URL of the API endpoint.
    • Type: Text
  3. Headers: Key-value pairs for HTTP headers.
    • Type: Table
    • Columns: Key (Text), Value (Text)
  4. Query Parameters: Key-value pairs for query parameters.
    • Type: Table
    • Columns: Key (Text), Value (Text)
  5. Body: The body of the request.
    • Type: Table
    • Columns: Key (Text), Value (Text)
  6. Content-Type: The content type for the request body.
    • Type: Radio Buttons

Node Outputs

  1. Output: The data received from the API call.
    • Type: Text
    • Example usage: {{api_0.output}}

Considerations

  • Error Handling: If the API call fails, the node can handle errors gracefully and pass error details downstream.
  • Raw JSON Body: If selected, the request body will be sent as raw JSON with Content-Type: application/json.
  • Default Headers: Automatically includes a Content-Type: application/json header for raw JSON requests if no such header is set manually.
  • Data Validation: Ensure that all required fields (e.g., URL and method) are populated before executing the node.

Examples

Example 1: Retrieving data from an API

The below example is a pipeline which uses the API Node to retrieve data from an API.

  1. Text Node: The API key .
    • Text: your_api_key
  2. API Node: Retrieves data from an API
    • Method: GET
    • URL: https://api.vectorshift.ai/v1/pipelines
    • Headers
      • Key: Authorization
      • Value: Bearer {{text_0.text}}
    • Query Parameters
      • Key: verbose
      • Value: true
  3. Output Node: Outputs the data received from the API call.
    • Output: {{api_0.output}}

Example 2: Sending data to an API

The below example is a pipeline which uses the API Node to send data like (e.g., a file or text) to an API.

  1. Text Node: The API key .
    • Text: your_api_key
  2. File Node: The file to be sent to the API.
    • File: Example File The file created in the Text to File node example.
  3. API Node: Sends the file and text to the API.
    • Method: POST
    • URL: https://api.vectorshift.ai/v1/pipeline/[pipeline_id]/run
    • Headers
      • Key: Authorization
      • Value: Bearer {{text_0.text}}
    • Body
      • Key: inputs.input_0
      • Value: Sample Text
      • Key: inputs.input_1
      • Value: {{file_0.file}}
  4. Output Node: Outputs the data received from the API call.
    • Output: {{api_0.output}}