---
title: "code snippets for automation platforms - codefmt"
url: https://codefmt.dev/snippets
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)
