The ShopifyShop
class fully encapsulates the Shopify API. It is an R6
class, and
as such is initialized via the ‘new’ function (see the example section for details).
the URL of your shop, as in shopname.myshopify.com
a Shopify API private app password or permanent access token (see Details)
a Storefront API access token
suppress output of API announcements
ShopifyShop$new(shopURL, password, quiet = FALSE)
if successful, will return a new ShopifyShop
object.
shopInfo
information about the shop as returned by getShop
In order to access the Shopify Admin API, users will need a set of authorized API access credentials. Tthese so-called ‘private app’ credentials can be created in the Shopify store admin section. More information about how to do this can be found here. Once the credentials are created, they remain valid and can be used in subsequent R sessions.
At the moment, the ShopifyShop
class does not support OAuth authentication. It is possible that
this may be implemented in the future. Note that users who possess a valid ‘permanent access token’
from a previous OAuth Authentication (see here) may
use it as the password
field of the ShopifyShop class as the private app password is essentially
analagous to the permanent token granted through successful OAuth authentication.
# NOT RUN {
# Before you can access the API, you must create a ShopifyShop object using your credentials
shop <- ShopifyShop$new("yourstore.myshopify.com","private_app_password")
# Get all smart collections
collections <- shop$getSmartCollections()
# Search for customers named Bob from the United States
bobs <- shop$searchCustomers("Bob country:United States")
# Create a new product
product <- list(title="The R Inferno",
body="<b>The R Inferno</b><i>by Patrick Burns</i>",
vendor="Burns Statistics",
product_type="Paperback",
images=list(list(src="http://www.burns-stat.com/wp-content/
uploads/2012/12/R_inferno_cover.jpg")))
newProduct <- shop$createProduct(product)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab