Python and project data
In the Python action, select the project API project-v1, the interpreter bundled, the function main and, optionally, a result variable. To use the current run's SDK, explicitly declare ctx.
def main(ctx, name="world"):
message = "Hello, " + name
ctx.variables.set("greeting", message)
ctx.log(message)
return {"message": message}The next action reads {-Variable.greeting-}. A returned dictionary is stored as one object in the result variable; its fields do not automatically become variables.
Variables
ctx.variables.get(name, default), set(name, value), delete(name), names(). The profile, project and environment are read-only.
Lists and tables
Find a resource using ctx.resources.find(name, kind). Use read(id, offset, limit), replace(id, data), append_rows(id, rows). Large resources are read in pages.
HTTP
ctx.http.request("GET", url) uses the current run's profile, proxy, cookies and traffic log. The response provides a status, headers, text and json(). Third-party clients do not automatically share this session.
Files and errors
File methods require permission and an allowed path. Variable and resource changes apply after the action succeeds. External writes and HTTP requests are not rolled back if a later error occurs.
The compatible context-free API still calls the function without ctx. Both APIs support the bundled interpreter and a configured system interpreter; third-party libraries must match the selected interpreter. See the editor's Python help for the method reference.