Skip to main content
This recipe demonstrates a complete automation workflow: uploading data, waiting for ingestion, running a query, and exporting results.

What this recipe accomplishes

  • Upload a CSV file to a dataset
  • Monitor the ingestion job until completion
  • Execute an NQL query against the ingested data
  • Export results to a local file

Prerequisites

  • Node.js 18 or later
  • TypeScript configured in your project
  • A Narrative API key with read/write permissions
  • An existing dataset to upload data to

Complete example

Create a file called data-pipeline.ts:

Running the pipeline

Set your environment variable and run:

Scheduling with cron

To run automatically, add to crontab:
Or use Node.js scheduling:

Adding error notifications

Send alerts on failure:

Parallel processing

Process multiple datasets concurrently:

Handling incremental updates

Track last run time for incremental processing:

SDK Quickstart

Get started with the SDK

Uploading Data

Detailed upload guide

Tracking Jobs

Monitor async operations

Executing Queries

Query patterns and best practices