Dev Guide
Dev GuideUser GuideGitHubNuGetDevCommunitySubmit a ticketLog In
GitHubNuGetDevCommunitySubmit a ticket

Batcher and CSV parser utilities

Learn how to batch API calls and parse CSV files with Optimizely Connect Platform (OCP) utilities.

Optimizely Connect Platform (OCP) has utilities to help you batch API calls and parse CSV files.


Batcher makes it easy to batch API calls that support arrays of records or call structures. For more information, see the App SDK API Reference documentation.

Batcher takes a function as input that takes an array of records and returns a promise. For example, you can use the z.customer or z.event function from the OCP Node SDK to send customer updates or Optimizely Data Platform (ODP) events in batches.

Sample batcher

Below is an example of using batcher to send customer updates to ODP in bulk:

import {CustomerPayload, z} from '@zaiusinc/node-sdk';
import * as App from '@zaiusinc/app-sdk';
import {Customer} from './Customer';

export class CustomerBatchImporter {

  public async transform() {
    const customerBatch = new App.Batcher(z.customer);

    const customers = await this.getCustomers();
    for (const customer of customers) {
      await customerBatch.append(this.transformToODPCustomer(customer));

    await customerBatch.flush();

  private async getCustomers(): Promise<Customer[]> {
    // get customers from external source

  private transformToODPCustomer(customer: Customer): CustomerPayload {
    // transform customer to ODP customer payload

CSV parser

To parse CSV files, use the App SDK's CsvStream.