Solved

How to get all shop pages?

YaroTheDev
Shopify Partner
1 0 0

Hello, I need some advise. I'm trying to get URLs of all the pages via any API.

 

What I've tried to do:

1. Load pages from REST.

I was able to to that, but response doesn't contain any page URLs. So - this doesn't work for me.

 

2. User GraphAPI to do that

I've used GraphAPI Explorer and this query

 

  pages(first: 10) {
    edges {
      node {
        id
        onlineStoreUrl
        title
      }
    }
  }

works for the demo site, but didn't work for me with the error:

 

Field 'pages' doesn't exist on type 'QueryRoot'

What is the difference? Is the fact that my store is in dev mode affects this query?

 

 

The same thing is for articles.

 

Scopes read_publications, read_content and read_online_store_pages  were requested

Accepted Solution (1)

ShopifyDevSup
Shopify Staff
1415 231 484

This is an accepted solution.

Hi @yarotesting,

 

The GraphQL pages and articles queries that you mentioned only exist in the Storefront API, not the Admin API. The Storefront and Admin API's look similar as they're both GraphQL and have some of the same things but do also have differences between them as far as what mutations and queries exist in each.

 

That error message that you shared is what comes up when a query that exists in one is used in the other one where it doesn't exist.

 

The endpoints, scopes, and authentication for Storefront API are a bit different than Admin API. Here's the reference docs about Storefront API:

https://shopify.dev/docs/api/storefront#authentication 

 

Here's a similar doc page for the Admin API:

https://shopify.dev/docs/api/admin-graphql#authentication 

 

Hope you have a great day

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

Reply 1 (1)

ShopifyDevSup
Shopify Staff
1415 231 484

This is an accepted solution.

Hi @yarotesting,

 

The GraphQL pages and articles queries that you mentioned only exist in the Storefront API, not the Admin API. The Storefront and Admin API's look similar as they're both GraphQL and have some of the same things but do also have differences between them as far as what mutations and queries exist in each.

 

That error message that you shared is what comes up when a query that exists in one is used in the other one where it doesn't exist.

 

The endpoints, scopes, and authentication for Storefront API are a bit different than Admin API. Here's the reference docs about Storefront API:

https://shopify.dev/docs/api/storefront#authentication 

 

Here's a similar doc page for the Admin API:

https://shopify.dev/docs/api/admin-graphql#authentication 

 

Hope you have a great day

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog