Get only latest product data from api without product id in php

Hey dear,

I need latest product data from a Shopify store with the help of API

Example: I have a [ABC] product in the store, but when I add new product like { dummy } in store, then I need to get only { dummy } product data from the API without product id

I’m using PHP curl functions

<?php $new_product = shopify_call($token,$shop_url, "/admin/api/2021-10/products.json", array(), 'GET'); $new_product_str = json_decode($new_product['response'], JSON_PRETTY_PRINT); ?>

Thanks and regard

Mohd. Shariq

Hi

Use limit = 1 and created_at_max = (current datetime) to get the newest product only

/admin/api/2021-10/products.json?limit=1&created_at_max=2022-08-25T07:48:59+00:00

You can generate the timestamp in the desired format with the following command:

date(DATE_ATOM, time());

Ref

2 Likes