Transform any pipeline into a high-performance API endpoint that supports low latency and high concurrency, ready for integration.

Each API comes with Swagger documentation for standardized usage and can be accessed as a shareable REST endpoint.

UI

Create an Endpoint

To publish a query as an endpoint:

  1. Click the publish button:

  1. Select “View endpoint”:

The dashboard displays key metrics including request count, data processed, latency, and error rate.

Use the Endpoint

Copy the API endpoint directly from the code block to use in your application:

Access additional options through the three-dot menu in the top right corner:

  • Share Swagger: Opens the Swagger documentation page for API exploration and testing
  • Add Parameter: Define custom parameters for your API calls
  • Duplicate: Create a copy of the endpoint
  • Discard changes: Revert parameter modifications
  • Delete: Remove the endpoint

Parameters

Endpoints support Jinja2 syntax for parameter templating.

Example of a parameterized endpoint:

Expressions

Use {{ param_name }} syntax for expressions.

Example: SELECT * FROM t LIMIT {{ limit }}

The internal Jinja engine handles parameter substitution automatically. No need to escape parameters - WHERE name = {{ name }} works correctly for string values.

Supported data types:

  • String
  • Int
  • Float
  • Boolean
  • Date
  • Datetime

For other data types, use String and parse within your SQL. For example, create an array from a comma-separated string:

SELECT * FROM t WHERE group IN splitByChar(',', {{ groups }})

All parameters are passed as query strings in the HTTP API:

https://api.us.airfold.co/v1/pipes/endpoint1?param1=10&param2=foo&param3=c1,c2

For additional syntax options, refer to the Jinja2 documentation.

Statements

Use {% if condition %}...{% endif %} syntax for conditional statements.

Example:

SELECT
{% if start_time is defined %}
    toStartOfInterval({{ start_time }}:: DateTime, INTERVAL {{ interval }} SECONDS)
{% else %}
    toStartOfInterval(now() - INTERVAL 1 DAY, INTERVAL {{ interval }} SECONDS)
{% endif %}

For additional statement options, refer to the Jinja2 documentation.

CLI

Edit YAML file

Simply add a name to the publish parameter:

insights.yaml
nodes:
  - node1:
      sql: |
        WITH
          arrayJoin(features_mentioned) AS feature
        SELECT
          count() AS num_successful_calls,
          topK(2)(feature) AS top_features
        FROM
          analysis
        WHERE
          successful = true
publish: insights

Push

Push this update by running:

af push insights.yaml

Params

In YAML params are placed in the params property:

params:
  - name: start_time
    type: datetime
  - name: end_time
    type: datetime
  - name: groups
    type: string
  - name: models
    type: string
  - name: interval
    type: int
    default: 300

Params can be used in endpoints and draft pipes.

Params cannot be used in materialized pipes.