Skip to content

Ingesting Data into Shaper

You can ingest data into Shaper’s database through the HTTP API or via NATS. Since DuckDB is not optimized for write operations, we store data in a NATS Jetstream and then write it to DuckDB in batches using DuckDB’s Appender API. We create tables and add columns automatically based on the data ingested.

  1. To ingest data you first need to create an API Key with “Ingest Data” permission in the “Admin” settings of the Shaper UI.

  2. Then you can write JSON data to the HTTP API or NATS directly:

    Endpoint:

    POST http://localhost:5454/api/data/:tablename

    Authentication is done through Bearer token in the Authorization header.

    You can pass a single JSON object or an array of objects.

    Example:

    Terminal window
    curl -X POST http://localhost:5454/api/data/my_table \
    -H "Authorization: Bearer <your-api-key>" \
    -H "Content-Type: application/json" \
    -d '{"col1": "value1", "col2": 124}'
  3. If you click on “New” in the sidebar now, you can run the following query:

    DESC my_table;
    SELECT * FROM my_table;
    column_namecolumn_typenullkeydefaultextra
    _idVARCHARYES
    _tsTIMESTAMPYES
    col1VARCHARYES
    col2DOUBLEYES

    You can see that Shaper auto-creates columns with appropriate data types, and we always add _id and _ts columns. You can override the default values by passing data in the JSON object for them. If using NATS directly and you set the Nats-Msg-Id header it will be used as the _id column value (if not set in data itself).

    Shaper detects boolean and numbers in JSON. We also detect date and timestamp strings in various formats. If any data is a complex data type such as an array or object, we store them as JSON column in DuckDB.

Shaper supports tasks to automatically run SQL scripts in the background similar to CRON jobs.

Tasks are especially helpful to routinely load and cleanup data.

Learn more in the Tasks Documentation.