Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Retrieving shopify Shop object?

I feel like I'm missing something extremely simple here. So i have the authentication session, and I essentially want to load the current Shop object to access somethings, like the email address, shop_owner, etc. How can I retrieve that to essentially get this response?

http://api.shopify.com/shop.html#show

I tried looking at /admin/shop.json and using

ShopifyAPI::Shop.find(someidnumber)

but no go?

like image 719
agmcleod Avatar asked Aug 10 '12 02:08

agmcleod


People also ask

How do I get data from Shopify?

In your Shopify admin, go to the Orders page and click Export. If you want to export data about specific orders, select those. Then you need to select which orders you want to export, the CSV file format and whether you want to include transaction histories.

How do I find my Shopify shop ID?

Log in to a Shopify store that shares the same email address as your other stores. After you log in, you're presented with a list of stores and services that are associated with that email address. Review the stores to make sure that you want to set up a Shopify ID for all the stores. Click Set up Shopify ID.

What is storefront API in Shopify?

The Storefront API is a GraphQL API that powers customer facing experiences. It is device-agnostic and enables developers to build custom storefronts. You use the Storefront API to build API-powered commerce such as mobile apps, headless commerce web experiences, Internet of Things (IoT), voice commerce, and more.


2 Answers

The endpoint is /admin/shop.json. If you're using the ShopifyAPI gem, in resources/shop.rb you'll see there is a current function.

Calling ShopifyAPI::Shop.current will return a Shop object with the details you're looking for.

If you're not getting the correct object/response back then you must not be authenticated properly.

like image 63
DenisOdorcic Avatar answered Nov 15 '22 21:11

DenisOdorcic


You can access it with

ShopifyAPI::Shop.current

However, in order for it to work - you need your controller to inherit from ShopifyApp::AuthenticatedController

Something like:

class MyController < ShopifyApp::AuthenticatedController
like image 21
Guy Dubrovski Avatar answered Nov 15 '22 20:11

Guy Dubrovski