Call an API or run code

Reach any service with a REST or GraphQL API, or compute something no built-in step covers. Use them when nothing else fits.

Two built-in steps can do almost anything: Call an API reaches any web API, and Run Python code runs a short script. Every other step shows its app and labeled fields, which anyone on your team can read and change. These two show a URL and headers, or a block of code. Reach for them when no app action or built-in step does the job.

Call an API

Call an API calls a REST or GraphQL endpoint that Lodol has no app for, and hands the response to later steps.

FieldWhat it's for
URLThe full address, starting with https://. It can include workspace values, such as @values.BASE_URL followed by a path.
MethodGET unless you choose another
HeadersSuch as an Authorization header, using a secret for the token
Query parametersAdded to the end of the URL
BodyWhat to send, as JSON or a value from an earlier step. GraphQL queries go here too.
Body formatjson (the default), form, text or none
Response formatauto (the default) follows the response's content type, so JSON becomes an object and a download becomes a file
If the call failsFail the run (the default), or continue so later steps can check the status

The step returns the response's status, ok (true for a success status), headers, body and url.

Only for services Lodol doesn't connect to

A Call an API step can't use an app's connection; it only has the secrets you give it. Calling Google's or Slack's API with it goes out without your account. For any app in the directory, use its actions.

Run Python code

Run Python code runs a short script, for the rare reshaping or calculation no built-in step covers.

  • Inputs maps names to values from earlier steps; the script reads them by those names.
  • The script's result is whatever it assigns to a variable named output.
  • Output type checks the result before later steps use it: auto (the default), text, number, boolean, list or object.
Python code: check an IBAN
# Inputs: iban (text). Output type: boolean.
iban = iban.replace(" ", "").upper()
rearranged = iban[4:] + iban[:4]
digits = "".join(str(int(char, 36)) for char in rearranged)
output = int(digits) % 97 == 1

The script runs in a secure sandbox with limits on time and memory. It has no internet or file access: use Call an API or an app's action to reach a service, and Read a file to get what's inside a file.

Before writing code, check the built-in steps: most text, list, number and date work, such as grouping records by a field, totalling a column or formatting a date, already has a step.

Reference

Every field is on the HTTP and Code reference pages.

On this page