Read Shopify Orders

Updated: Oct 30, 2023

This example shows how to read orders from a Shopify store and save them in a CSV file.  The target can be changed to any format DataPipeline supports (like JSON, XML, Parquet, etc.).  The pipeline's job can also include filters, transformations, and lookups to fit your use-case. 

For this example, we'll need:

  1. A Shopify custom app with read_orders Admin API access scope.
  2. An ACCESS_TOKEN and the store's DOMAIN.

For information on how to create a custom app and obtain an access key visit Shopify custom apps.

Java Code Listing

package com.northconcepts.datapipeline.examples.shopify;

import com.northconcepts.datapipeline.core.DataReader;
import com.northconcepts.datapipeline.core.DataWriter;
import com.northconcepts.datapipeline.csv.CSVWriter;
import com.northconcepts.datapipeline.job.Job;
import com.northconcepts.datapipeline.shopify.ShopifyOrderReader;
import com.northconcepts.datapipeline.shopify.client.FinancialStatus;
import com.northconcepts.datapipeline.shopify.client.FulfillmentStatus;
import com.northconcepts.datapipeline.shopify.client.OrderStatus;
import com.northconcepts.datapipeline.shopify.client.ShopifyOrder;


public class ReadShopifyOrders {

    private static final String DOMAIN = "";
    private static final String ACCESS_TOKEN = "ACCESS_TOKEN";
    public static void main(String[] args) {
        DataReader reader = new ShopifyOrderReader(DOMAIN, ACCESS_TOKEN)
            .setOrderCriteria(new ShopifyOrder()
                .setFields("id", "created_at", "checkout_id", "checkout_token"));

        DataWriter writer = new CSVWriter(new File("example/data/output/shopify-orders.csv"));
       , writer);

Code Walkthrough

  1.  An instance of ShopifyOrderReader which takes DOMAIN and ACCESS_TOKEN as arguments is created. This will be used to read a list of Shopify orders belonging to the store.
  2.  .setStatus(OrderStatus.ANY) is used to get orders based on its status.
  3.  .setFinancialStatus(FinancialStatus.PAID) is used to filter orders by its financial status.
  4.  .setFulfillmentStatus(FulfillmentStatus.ANY) is used to filter orders by its fulfillment status.
  5.  .setFields("id", "created_at", "checkout_id", "checkout_token") is used to only show fields we are interested in. For information on query parameters visit Shopify Admin API
  6. is then used to transfer data from the reader to CSVWriter.


Mobile Analytics