Spanish Total.js
English
Documentation For AI agents
Contents

Call an HTTP API

Turn an HTTP address into a reusable node with Link endpoint and send data to it.

.md GitHub
On this page

Link endpoint creates a component that calls one HTTP address. The component has two outputs: Output for a successful answer and Error for an answer with an error status, such as 400.

This example calls the endpoint from Create a POST endpoint.

Create the component

  1. Select Add (plus) in the toolbar, then Link endpoint.
  2. Set Name to Orders API, Group name to My APIs, HTTP method to POST, Data serialization to JSON and URL address to http://localhost:8000/api/orders/.
  3. Select CREATE.

The Link endpoint form

The component appears in the list on the left under My APIs. You can use it as many times as you like.

FieldWhat to enter
NameThe name of the component. Required.
Group nameThe heading it appears under in the list.
IconThe icon of the component.
HTTP methodPOST, GET, PUT, PATCH or DELETE.
Data serializationJSON or URL encode, for the body of the request.
URL addressThe address to call. Required.
Custom headersA header name and value. Press Enter to confirm each one.
Compress data via GZIPCompresses the data you send.
Read meA description, shown by Read information.

Use it

  1. Drag Trigger, Orders API and two Print nodes onto the canvas.
  2. Connect Trigger to the input of Orders API, Output to the first Print and Error to the second Print.
  3. Double-click Trigger, choose Object, clear Random data, set Data to { product: 'Demo product', quantity: 3 } and select APPLY.
  4. Select APPLY in the toolbar, then Continue.
  5. Select Run on the Trigger.

The first Print shows the answer of the API:

{"success":true,"product":"Demo product","quantity":3}

The Trigger, Orders API and Print nodes after Run

When the API answers with an error, the answer goes to the Error output. With { quantity: 1 } as Trigger data, the second Print shows:

{"error":"The product is required."}
Made in Europe