---
title: "code snippets for automation platforms - codefmt"
url: https://codefmt.dev/snippets
updated: 2026-10-05
sources:
  - https://codefmt.dev/snippets
licence: "© codefmt. Cite with attribution to https://codefmt.dev."
---

# code snippets for automation platforms

## snippet library

### HTTP GET with Error Handling

zapier

Fetch data from an API endpoint using inputData, with error handling and JSON response parsing.

[open in formatter](/?snippet=zapier-http-request)

### Date Formatting & Parsing

zapier

Parse a date string from inputData and reformat it for downstream steps.

[open in formatter](/?snippet=zapier-date-format)

### Map & Filter Array Data

zapier

Parse a JSON array from inputData, filter and transform each item, and return the results.

[open in formatter](/?snippet=zapier-data-transform)

### Input Validation & Sanitization

zapier

Validate required inputData fields and sanitize values before processing.

[open in formatter](/?snippet=zapier-input-validation)

### Return Multiple Output Objects

zapier

Split a comma-separated inputData field into multiple output objects for downstream steps.

[open in formatter](/?snippet=zapier-multi-output)

### Python: Contact Lookup via requests

zapier

Look up a contact in an external CRM using Zapier Python with the preinstalled requests library.

[open in formatter](/?snippet=zapier-python-contact-lookup)

### Process All Items

n8n

Loop through all input items with $input.all(), transform each, and return results.

[open in formatter](/?snippet=n8n-process-items)

### HTTP Request with Retry

n8n

Make an HTTP request with exponential backoff retry logic. fetch is available in modern n8n (Node 20+).

[open in formatter](/?snippet=n8n-http-retry)

### Date Parsing & Timezone Handling

n8n

Parse dates from input, compute differences, and format with timezone offsets.

[open in formatter](/?snippet=n8n-date-manipulation)

### Try/Catch with Structured Errors

n8n

Wrap processing in try/catch and return structured error output for the error branch.

[open in formatter](/?snippet=n8n-error-handling)

### Access Data from Previous Nodes

n8n

Reference output data from specific previous nodes using $() notation.

[open in formatter](/?snippet=n8n-node-reference)

### Python: Process All Items

n8n

Iterate \_items in n8n's Python Code node (Run Once for All Items mode), transforming each item.

[open in formatter](/?snippet=n8n-python-process-items)

### Webhook Body Validation

pipedream

Validate an incoming webhook payload from steps.trigger.event and return a structured record.

[open in formatter](/?snippet=pipedream-webhook-handler)

### HTTP Request with axios

pipedream

Make an authenticated POST using axios from npm. Pipedream code steps support require() for any npm package.

[open in formatter](/?snippet=pipedream-http-axios)

### Data Store Read/Write (full component)

pipedream

Persist state across runs with a Pipedream Data Store. Data stores must be declared as a component prop; codefmt formats this as module-style code because of the top-level export.

[open in formatter](/?snippet=pipedream-data-store)

### Environment Variable Access

pipedream

Access and validate environment variables with fallback defaults.

[open in formatter](/?snippet=pipedream-env-vars)

### Python: Webhook Handler

pipedream

Process an incoming webhook in a Pipedream Python step using the pd object.

[open in formatter](/?snippet=pipedream-python-webhook)

### Transform Input Fields

make

Transform and restructure scenario input fields for an API request.

[open in formatter](/?snippet=make-bundle-transform)

### Parse Nested JSON from Strings

make

Safely parse JSON strings from scenario input, handling nested structures.

[open in formatter](/?snippet=make-json-parse)

### Error Handling with Structured Output

make

Try/catch pattern returning structured success or error output for Make scenarios.

[open in formatter](/?snippet=make-error-pattern)

### Python: Transform Input List

make

Transform a list of items from scenario input and return a structured result.

[open in formatter](/?snippet=make-python-transform)

### Search Contacts by Email

hubspot

Look up a HubSpot contact by email address using the CRM search API via @hubspot/api-client.

[open in formatter](/?snippet=hubspot-contact-lookup)

### Custom Workflow Action with API Call

hubspot

A custom coded workflow action that calls an external API via axios and updates the contact in HubSpot.

[open in formatter](/?snippet=hubspot-custom-action)

### Process Webhook Event

hubspot

Handle an incoming webhook event, extract subscription data, and route by event type.

[open in formatter](/?snippet=hubspot-webhook-process)

### Error Handling with Callback

hubspot

Robust error handling pattern using @hubspot/api-client and callback with structured error data.

[open in formatter](/?snippet=hubspot-error-response)

### Python: Contact Lookup via REST

hubspot

Look up a HubSpot contact by object ID using the CRM REST API and a private app token.

[open in formatter](/?snippet=hubspot-python-contact)

### For Loop with Conditionals

hubl

Iterate over a list with if/else conditional rendering and loop index access.

[open in formatter](/hubl?snippet=hubl-for-loop)

### Custom Module with Parameters

hubl

A reusable custom module template that reads module parameters with defaults and renders content.

[open in formatter](/hubl?snippet=hubl-custom-module)

### Blog Post Listing

hubl

Display recent blog posts using content variables and blog\_recent\_posts.

[open in formatter](/hubl?snippet=hubl-blog-listing)

### Form Embed with Custom Styling

hubl

Embed a HubSpot form via the @hubspot/form module with custom wrapper markup and a fallback for the editor.

[open in formatter](/hubl?snippet=hubl-form-handler)

## for agents (added to every page twin, not part of the page)

- format API: POST https://codefmt.dev/api/format (OpenAPI: https://codefmt.dev/api/openapi.json, code up to 51,200 characters, 50KB of ASCII (400 above it), request body up to 100KB, counted in bytes (413 above it), no authentication)
- MCP server: POST https://codefmt.dev/api/mcp (tools: format_code, format_json, ask_codefmt; manifest: https://codefmt.dev/.well-known/mcp.json)
- rate limit: 60 requests per minute per ip across format api calls, mcp and a2a tool calls, and /ask (mcp handshakes and listings are not counted). the count is kept per server instance, so treat it as a ceiling to stay under rather than an exact budget. the format api reports where you stand in RateLimit headers and its 429 carries Retry-After; /ask answers a 429 with the message in answer, and an mcp tool call over the limit returns a tool result saying to try again in a minute
- auth statement: https://codefmt.dev/auth.md (no accounts, api keys or oauth; send no authorization header)
- site index for agents: https://codefmt.dev/llms.txt
- full reference (request bodies for every language, a copy-paste curl command, platform globals, troubleshooting): https://codefmt.dev/llms-full.txt
