Using APIs from a different origin/domain

Solved
andrewscott
Shopify Partner
4 0 0

Thanks Greg and Bill! 

I think Bill was right about that it should be easy. 

const res = await fetch(
`https://${SHOPIFY_API_KEY}:${accessToken}@${shop}/admin/api/2020-10/themes/116224032917/assets.json`
)

 

In case anyone else is wondering the full set up:

https://community.shopify.com/c/Shopify-APIs-SDKs/I-want-to-call-rest-api-in-the-shopify-embedded-ap...

0 Likes
agmiguelcalo
New Member
1 0 0

So about using the api directly on browser, you take note of the ff:

  • create a private app on your store and tick what you need on the store front api scopes
  • an access token will be generated, add that in your request header as "X-Shopify-Storefront-Access-Token"
  • your endpoint will have a '.js' suffix, ex "https://your-shop.myshopify.com/api/graphql.js"

Got to admit though, the gql documentation is not very friendly.

Here's a sample query you can try

query {
  products(first:3) {
    edges {
      node {
        id
        handle
        variants(first:3) {
          edges {
            node {
              id
            }
          }
        }
      }
    }
  }
}
0 Likes