API call on own store

Pawel_woolet_co
New Member
21 0 0

Hi,

is it possible to make an API call to get all products in JSON on our Shopify store page ? -->  https://help.shopify.com/api/reference/product
I know that it's impossible through Public App cause the tokens are visible in JS code and it will not work.

Which steps should I make to solve this ?

0 Likes
Jamie_D_
Shopify Staff (Retired)
Shopify Staff (Retired)
531 1 99

Hi there,

I recommend taking a look at Shopify's AJAX API.

0 Likes
Pawel_woolet_co
New Member
21 0 0

Thanks but with AJAX API I can't get all the products at once on my page, I can get only that with product handle so its restricted to product page.

If I want to enlist all the product metadata on some page I must use normal Admin API :)

0 Likes
Jason
Shopify Expert
10037 119 1872

There are ajax endpoints that can return info on products such as:

  • /products.json
  • /collections/some-handle/products.json

You can also create an alternate collection template (using a layout of none) and return a JSON string for use in your code.

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
Pawel_woolet_co
New Member
21 0 0

Thanks! I will try that :)

0 Likes
Pawel_woolet_co
New Member
21 0 0

I've successfully used the Ajax API for product calls but for articles the Ajax API doesn't exist.

I've found admin API here:
https://help.shopify.com/api/reference/article#index

I'm trying to make the following request on my store:

$.get('/admin/blogs/19692355/articles/229491718.json', function(data) {
      console.log(data);
});

but the shopify tries to reach https://woolet-co.myshopify.com/admin/blogs/19692355/articles/229491718.json instead of https://woolet.co/admin/blogs/19692355/articles/229491718.json and this causes 404 error.

Which steps should I take to make this call properly ? I've tried absolute paths without results.

0 Likes
Jamie_D_
Shopify Staff (Retired)
Shopify Staff (Retired)
531 1 99

I _highly_ recommend against that. A private application key is equivalent to a password for your shop – this is not something that should be embedded in your storefront for all users to discover.

0 Likes
Pawel_woolet_co
New Member
21 0 0

Thanks for your reply Jamie although Jason has found perfect solution for my issue in this similar topic :) -->


https://ecommerce.shopify.com/c/shopify-apis-and-technology/t/admin-api-get-article-error-on-my-stor...

so problem is solved, we can close the thread :)

0 Likes
justinestrada
Tourist
3 0 0

I can't find any documentation on what parameters the: "/collections/some-handle/products.json" endpoint accepts.
Do you know where I can find a link? The docs here seem incomplete: https://shopify.dev/docs/themes/ajax-api

0 Likes