Read Shopify Store Locations

Updated: Oct 30, 2023

This example shows how to read a Shopify store's locations 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.
  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.DataWriter;
import com.northconcepts.datapipeline.csv.CSVWriter;
import com.northconcepts.datapipeline.job.Job;
import com.northconcepts.datapipeline.shopify.ShopifyLocationReader;
import com.northconcepts.datapipeline.core.DataReader;

import java.io.File;


public class ReadShopifyLocations {

    private static final String DOMAIN = "https://your-store-domain.com";
    private static final String ACCESS_TOKEN = "ACCESS_TOKEN";
    
    public static void main(String[] args) {
        DataReader reader = new ShopifyLocationReader(DOMAIN, ACCESS_TOKEN);
        DataWriter writer = new CSVWriter(new File("data/output/orders.csv"));

        Job.run(reader, writer);
    }
    
}


Code Walkthrough

  1.  An instance of ShopifyLocationReader which takes DOMAIN and ACCESS_TOKEN as arguments is created. This will be used to read a list of Shopify locations.
  2. Job.run() is then used to transfer data from the reader to CSVWriter.

 

Mobile Analytics