Skip to main content

Overview

This example shows how to export analytics data from Grain using the Query API. We’ll build a Node.js application that can export data to CSV, JSON, and other formats, with support for large datasets, scheduled exports, and data transformation.
This example assumes you have a Builder plan or higher and have created an API key with Query API permissions.

Project Setup

1. Create Node.js Project

2. Install Dependencies

3. TypeScript Configuration

Create tsconfig.json:

4. Environment Variables

Create .env:

Core Export Client

CSV Export

JSON Export

Data Transformers

Export Scripts

1. Basic Export Script

2. Event-Specific Export

3. User Journey Export

Scheduled Exports

CLI Tool

Package.json Scripts

Usage Examples

Command Line Usage

Programmatic Usage

Error Handling and Retry Logic

Custom Plans

Need higher rate limits for large data exports? We offer custom plans with:
  • Higher rate limits: Custom requests per minute/day limits for bulk exports
  • Dedicated support: Priority support and SLA guarantees
  • Volume discounts: Competitive pricing for high-volume usage
  • Custom features: Tailored export features and integrations
Contact us at support@grainql.com to discuss your export requirements.

Next Steps

Custom Dashboard

Build a custom analytics dashboard

Query API Reference

Complete API documentation

Filter Reference

All filter operators and examples

Grain Dashboard

Built-in analytics dashboard