Generic API icon

Generic API

Node genérico para integração com APIs REST

Overview

This node provides a generic interface to interact with any REST API by specifying the resource and operation dynamically. It supports common CRUD operations such as creating, retrieving (single or multiple), updating, and deleting records on any API endpoint.

The "Get Many" operation is designed to fetch multiple records from a specified resource. It can either return all available results or limit the number of returned items based on user input. This flexibility makes it useful for scenarios like:

  • Retrieving all users, products, or orders from an external system.
  • Fetching a subset of data when dealing with large datasets to optimize performance.
  • Integrating with APIs that support pagination or query parameters to filter results.

Practical example: You want to get up to 50 recent orders from an e-commerce platform's API. You set the resource to "orders", operation to "Get Many", enable "Return All" as false, and set the limit to 50. The node will then request the API accordingly and output the retrieved orders.

Properties

Name Meaning
Retornar Todos Boolean flag indicating whether to return all results (true) or limit the number of results (false).
Limite Maximum number of results to return when "Retornar Todos" is false. Must be at least 1.
Opções Adicionais Collection of additional options:
- Headers Customizados JSON object specifying extra HTTP headers to include in the request.
- Query Parameters JSON object with query parameters to append to the URL.
- Timeout Request timeout in milliseconds (default 30000 ms).
- Continuar Em Erro Boolean flag indicating whether to continue workflow execution if an error occurs (true) or stop (false).

Output

The node outputs an array of JSON objects representing the fetched records from the API.

  • If multiple records are returned, each record is output as a separate item in the output array.
  • Each output item contains a json field holding the data of one record.
  • The output preserves pairing information to link each output item back to its corresponding input item.

No binary data output is produced by this node.

Dependencies

  • Requires an API key credential configured in n8n to authenticate requests to the target API.
  • Uses a helper class internally to make HTTP requests with support for custom headers, query parameters, and timeouts.
  • No other external dependencies beyond standard HTTP request capabilities.

Troubleshooting

  • Common issues:

    • Incorrect resource name or operation may cause the API to return errors or empty results.
    • Invalid JSON in "Headers Customizados" or "Query Parameters" fields can cause parsing errors.
    • Network timeouts if the API is slow or unreachable; adjust the "Timeout" property accordingly.
    • API authentication failures if the provided credentials are invalid or expired.
  • Error messages:

    • "Operação desconhecida: <operation>": Indicates an unsupported operation was selected. Verify the operation name.
    • HTTP errors from the API (e.g., 401 Unauthorized, 404 Not Found) will be thrown unless "Continuar Em Erro" is enabled, in which case the error details are output as JSON.
  • Resolution tips:

    • Double-check resource and operation names match the target API's endpoints.
    • Validate JSON inputs for additional headers and query parameters.
    • Increase timeout if requests frequently time out.
    • Ensure valid API credentials are configured in n8n.

Links and References

Discussion