Jump to content

REST API - In what format are 'Date periods' passed?


Roboko
 Share

Go to solution Solved by IPCommerceFan,

Recommended Posts

I am trying to use the /core/search Endpoint and want to search for things starting after a certain date.

To do this, I think I should be using the start_after parameter. But the type of data passed in the documentation is just documented as string which is not very helpful at all.

What format is this expecting?

 

Link to comment
Share on other sites

I have tried using the same format as what is returned by IPS in results, eg

/api/core/search?sortby=newest&key=################################&type=forums_topic&start_after=2022-01-01T18:52:03Z

Obviously with the date being in the future, this should yield no results, but it yields results.

Weirdly, passing a nonsense parameter for start_after like sdkfljhgaskjlhf actually does yield no results which makes me question my sanity

Link to comment
Share on other sites

  • Solution

Try using a unix timestamp, like so (this one is for Oct 1st 2021):

/api/core/search?sortby=newest&key=################################&type=forums_topic&start_after=1633064400

The results that are returned are given in DateTime:

{
    "page": 1,
    "perPage": 25,
    "totalResults": 1,
    "totalPages": 1,
    "results": [
        {
            "title": "Widget",
            "content": "",
            "class": "IPS\\nexus\\Package\\Item",
            "objectId": 9999,
            "itemClass": "IPS\\nexus\\Package\\Item",
            "itemId": 9999,
            "started": "2021-11-02T08:35:52Z",
            "updated": "2021-11-02T08:38:33Z",
            "itemUrl": "https:\/\/www.yourdomain.com\/store\/product\/9999-widget\/",
            "objectUrl": "https:\/\/www.yourdomain.com\/store\/product\/9999-widget\/?do=findComment&comment=1358",
            "reputation": 0,
            "comments": null,
            "reviews": 0,
            "container": "Widgets",
            "containerUrl": "https:\/\/www.yourdomain.com\/store\/category\/1-widgets\/",
            "author": "Guest",
            "authorUrl": null,
            "authorPhoto": "https:\/\/www.yourdomain.com\/applications\/core\/dev\/resources\/global\/default_photo.png",
            "authorPhotoThumbnail": "https:\/\/www.yourdomain.com\/applications\/core\/dev\/resources\/global\/default_photo.png",
            "tags": []
        }
    ]
}

But as far as the GET request goes, its in unixtime.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...