Is there an API call to list all available product id's (ID's alone) in Shopify? - shopify

I use POSTMAN GUI for retrieving a list of items from Shopify API.
I would like to know if there exists a way to get available product id's alone, preferably as a list of values over a single api GET call. The one I know of is
/admin/api/2022-04/products.json
It returns a list of all product information, and looping over them/traversing the json is not very efficient. I hope there must be an easy way to fetch all ID's alone in one go. Should there be not?

You can add /admin/api/2022-04/products.json?fields=id to the end of your request to limit the output only for a single field or multiply.
Please note that if you have more than 250 products you will need to make more than one request, since the request is limited to 250 products.

You can make one call to the Admin API for all your product IDs using the Bulk Query. That will result in you receiving a URL where you download a file in JSONL format with every single product ID in your store, without the paging or limits of other approaches.

Related

Can podio's api filter item response with only a mini detail level for each item?

My script needs to check from time to time that all items present in an app are recorded in its own db. Indeed even when using the podio hooks, it happens that my script and podio are getting desynchronised.
It uses the filter item api call by batch of 100 of items. In this case the script doesn't need to know all the fields values, but only the basic informations: item_id, app, title, link and current_revision.
I wonder if it's possible to set a query parameter in the filter function only only get the mini view of each item. This could improve greatly performances.
You can use fields parameter for that.
More details on how it works and how else it could be used are right here: https://developers.podio.com/index/api in "Bundling responses using fields parameter" section.
Using fields to bundle objects can be a way to drastically reduce the amount of API requests you have to make.
Most likely you are looking for fields=items.view(micro) parameter. Podio API will return then only 5 values for each item:
app_item_id
item_id
title
link
revision

Retrieving list of order statuses via Magento API

I'm trying to understand if it is possible to retrieve a list of order statuses from the Magento backend via the Magento API. I'm not looking (at this point) to amend the status of an order which is the only answer I've been able to find so far.
Yes you have the sales_order.info method or you can retrieve more orders by sales_order.list.
After that you can loop in order array and create a hash map with order ids and statuses.
For array with statuses you need to write your own API method.
See here http://www.magentocommerce.com/api/soap/sales/salesOrder/sales_order.info.html and http://www.magentocommerce.com/api/soap/sales/salesOrder/sales_order.list.html

How to get /admin/products.json in a chronological order?

I need to be able to poll more than 250 products from the Shopify API. In order to do so, I need to retrieve the products from the API in a chronological order, with the oldest products first. Once I have the first 250 items, I retrieve another 250 items filtered by max_created_at.
I noticed that: GET /admin/products.json returns the products in a random order, but GET /admin/products.json?since_id=0 returns the products in a chronological order. Is this the intended behaviour? Or is there a flag that I can send with GET /admin/products.json to specify the sorting order?
Edit: I guess my question boils down to this: Is there a field that I can set that the results returned by the Shopify API will be ordered by?
Maybe the API has been updated since the last post but now you can do that like that :
https://yourshop.myshopift.com/admin/products.json?limit=50&fields=id,images,title&order=created_at+desc
Just add the query string parameter order=created_at+asc
This is an undocumented feature but it seems to work for most fields.
This is unintended behaviour, reliable sort orders for Product are limited to title and total, and then filtering options are as listed in the API docs.

How to get item in REST API by multiple item id

I have product_id and onec_id columns to get items from DB. Which API routes should I use to get items by product_id or by onec_id?
Is it right for REST routes?
GET /products/{product_id}
GET /products/get_by_onec_id/{onec_id}
The most REST solution is to fire one HTTP request for each id. For example
GET /product/736
REST is intended to represent the state of a resource. It can return a set of items, but only if these items relate to each other in some way. For example
GET /onec/492/products
Will return the set of products associated with the specified onec.
If you want to return the set of products identified by a set of IDs in a single request, you may have your shortcut syntax like
GET /products/12,768,56,086
But it's not really common because it's quite a departure from the REST objectives
To get a single Product or Onec(?), GET
/products/{id}
/onecs/{id}

WCF Service call to multiple rows. How to architecture it?

Let's say I have a scenario where I have a Service that is responsible for retrieving the price of a single product given the ID and another Service that gives me the current stock position of it.
It's okay when I'm looking only at one product, but what about a list page where I have 60 products? What should I do in this case? Call the service product by product to retrieve it's current price and stock position?
I think this would be extremely slow and cost a lot of resources. But what could I do to make it look good and at the same time have performance?
Currently we have these information in the database in a column next to the product. These price and stock columns are updated by a sql service that updates it when is necessary so when I need to grab the value for a lot of products at the same time I just need to select two columns more. It's really fast, but right now we have some more systems in need of this information and I would like to transform all these stuff in a service.
Thanks a lot!
Well, you could always have multiple service methods:
the one you already have, to retrieve a single product, and the price for a single product
create a new service method which would take a list of product ID's, and return a list of product objects - or a new DTO (data-transfer object) that holds product and price
This way, you could keep your current users happy, and also do something to make batch requests work more efficiently.
Can your service method take an array of IDs? And return an array of values? That way if you want one record your array only has 1 item, if you want more, you just populate the array with multiple values?