Generic API icon

Generic API

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

Overview

This node is a generic API integration tool designed to interact with any RESTful 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 a specified API resource.

Typical use cases include:

  • Integrating with custom or third-party APIs that do not have dedicated n8n nodes.
  • Quickly setting up API calls for resources like users, products, orders, or any other entity exposed by an API.
  • Automating workflows that require dynamic interaction with various endpoints without writing custom code.

For example, you can use this node to:

  • Retrieve a specific user by ID from a user management API.
  • Create a new product in an e-commerce platform.
  • Update order details based on workflow data.
  • Delete obsolete records from a database via its 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: "create", "get", "getAll", "update", "delete".
Dados (data) JSON string representing the data to create a new record (used only with "create" operation).
ID (id) The identifier of the record to get, update, or delete (required for "get", "update", "delete").
Retornar Todos (returnAll) Boolean indicating whether to return all results when fetching multiple records ("getAll" operation).
Limite (limit) Maximum number of records to return when not returning all (used with "getAll" and returnAll=false).
Dados Para Atualizar (updateData) JSON string representing the data to update an existing record (used only with "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 with the response data from the API call:

  • For single record operations (get, create, update, delete), the output is a single JSON object representing the record or the API response.
  • For multiple records retrieval (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 paired with the input item index.
  • 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 output binary data.

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.
  • The API endpoint base URL and authentication details are expected to be provided via credentials.
  • No additional external dependencies beyond standard HTTP request capabilities.

Troubleshooting

  • Common issues:

    • Incorrect resource or operation names will cause errors.
    • Malformed JSON in "Dados" or "Dados Para Atualizar" fields will cause parsing errors.
    • Missing required parameters like "ID" for certain operations will throw errors.
    • Network timeouts or invalid API credentials will result in request failures.
  • Error messages:

    • "Operação desconhecida: <operation>": Means the specified operation is not supported; verify the operation value.
    • JSON parse errors indicate invalid JSON input in data fields; ensure proper JSON formatting.
    • HTTP errors from the API will be surfaced unless "Continuar Em Erro" is enabled, which then outputs error details in the workflow.
  • Resolutions:

    • Double-check parameter values and JSON syntax.
    • Ensure API credentials are valid and have necessary permissions.
    • Adjust timeout settings if requests take longer than default.
    • Enable "Continuar Em Erro" to handle errors gracefully within workflows.

Links and References

Discussion