knitr::opts_chunk$set( collapse = TRUE, fig.path = "man/figures/README-" )
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!
# install.packages("devtools") devtools::install_github("GormAnalysis/shopr")
To use the Shopify API, you first need to
It'd be wise to read Shopify's Getting Started article before tinkering with this package.
The functions in this package require three parameters to connect to a shop:
For many functions, these are the only required parameters, although additional parameters may be given.
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.
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.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.