Generic API icon

Generic API

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

Overview

This node, named "Generic API," is designed to integrate with any RESTful API by allowing users to specify the resource and operation dynamically. It supports common CRUD operations such as creating, retrieving (single or multiple), updating, and deleting records on a specified API resource.

Typical use cases include:

  • Connecting to custom or third-party APIs that do not have dedicated n8n nodes.
  • Performing flexible API requests where the resource and operation can be configured at runtime.
  • Automating workflows that require interaction with various endpoints of an API without writing custom code.

For example, you could use this node to:

  • Retrieve a user record by ID from a user management API.
  • Create a new product entry in an inventory system.
  • Update order details in an e-commerce platform.
  • Delete obsolete data entries from a database via its REST API.

Properties

Name Meaning
Recurso (resource) The name of the API resource to interact with (e.g., users, products).
Operação (operation) The action to perform on the resource. Options: Atualizar (update), Criar (create), Deletar (delete), Get Many (getAll), Obter (get).
Dados (data) JSON data used when creating a new record (required for create operation).
ID The identifier of the record to get, update, or delete (required for get, update, delete).
Retornar Todos (returnAll) Whether to return all results or limit the number when fetching multiple records (getAll).
Limite (limit) Maximum number of results to return when not returning all (getAll).
Dados Para Atualizar (updateData) JSON data used to update an existing record (required for update operation).
Opções Adicionais (additionalOptions) Collection of optional settings:
• Headers Customizados: Additional HTTP headers as JSON.
• Query Parameters: Extra query parameters as JSON.
• Timeout: Request timeout in milliseconds.
• Continuar Em Erro: Whether to continue workflow execution if an error occurs.

Output

The node outputs an array of items where each item contains a json field representing the API response data:

  • For single record operations (get, create, update, delete), the output is a single JSON object corresponding to the API response.
  • For multiple records (getAll), the output is an array of JSON objects, each representing one record.
  • If the API returns an array, each element is output as a separate item in the workflow.
  • In case of errors and if "Continuar Em Erro" is enabled, the output includes an error object with message and details instead of throwing.

The node does not handle binary data output.

Dependencies

  • Requires an API key credential configured in n8n to authenticate requests.
  • Uses a helper class internally to make HTTP requests to the specified API.
  • No external libraries beyond those bundled with n8n are required.

Troubleshooting

  • Common issues:

    • Incorrect resource or operation names will cause errors.
    • Malformed JSON in "Dados" or "Dados Para Atualizar" fields will cause parsing errors.
    • Network timeouts or invalid credentials will result in request failures.
    • API endpoint may reject requests if required headers or query parameters are missing.
  • Error messages:

    • "Operação desconhecida: <operation>": Means the selected operation is not supported; verify the operation value.
    • JSON parse errors on input data: Ensure JSON strings are valid.
    • HTTP errors from the API: Check credentials, endpoint URL, and additional options like headers or query parameters.
  • To avoid workflow interruption on errors, enable "Continuar Em Erro" in additional options.

Links and References

Discussion