README.md

Overview

shopr is a collection of functions that make it easy to interact with the Shopify REST Admin API from R. Currently, shopr only supports read operations (i.e. HTTP GET requests).

Check out this tutorial on setting up and using shopr!

Installation

# install.packages("devtools")
devtools::install_github("ben519/shopr")

Setup

To use the Shopify API, you first need to

  1. Create a Shopify Partner Account
  2. Create a Development Store (Recommended but not necessary)
  3. Generate API credentials from the Shopify admin

It’d be wise to read Shopify’s Getting Started article before tinkering with this package.

Usage

API Credentials

The functions in this package require three parameters to connect to a shop:

  1. shopURL (e.g. “https://my-test-store.myshopify.com”)
  2. APIKey (e.g. “a1b2c3”)
  3. APIPassword (e.g. “d4e5g6”)

For many functions, these are the only required parameters, although additional parameters may be given.

Example Use

Perhaps the most useful function in this package is shopr_get_orders(). Here’s the simplest way to use it.

library(shopr)

shopr_get_orders(
  shopURL = "https://my-test-store.myshopify.com", 
  APIKey = "abc123", 
  APIPassword = "def456"
)

This returns a list of

For shops with many orders, this is a lot of data. You can filter the fields or rows using filter criteria like created_at_min, processed_at_min, fulfillment_status, and other parameters. See ?shopr_get_orders for more details.

Pagination

Some resources (e.g. orders and products) require pagination to return a large result set. As an example, suppose we have a shop with 1001 products and we want to fetch every product. Shopify allows a max return size of 250 items per query (limit_per_page = 250), so we’ll need to make 5 queries to retrieve all the products. shopr handles pagination internally so you don’t have to.

See this article for details about API rate limits.



GormAnalysis/shopr documentation built on Jan. 10, 2022, 1:42 a.m.