Searching by Date

A common use case is searching for files in a specific time frame. For example, you may be interested in seeing your latest files. Or you may want to keep an eye on older files to archive or remove from the system altogether.

Searching for recent files

Let's find files that have been created since August 21, 2020. Dates in Shift are in UNIX time in milliseconds, so first we need to format our start time. For this example, the time in UNIX milliseconds is 1598019526. To find all files created since this date, we can use the following "greater than" example.

curl --request GET \
  --url https://api.shift.io/v3/assets?dateCreated={"gt":"1598019526000"} \
  --header 'accept: application/json' \
  --header 'x-key: YOUR_API_KEY' \
  --header 'x-secret: YOUR_API_SECRET'

Similarly, if we want to find all files that have been updated since this date, we can use dateModified instead of dateCreated.

curl --request GET \
  --url https://api.shift.io/v3/assets?dateModified={"gt":"1598019526000"} \
  --header 'accept: application/json' \
  --header 'x-key: YOUR_API_KEY' \
  --header 'x-secret: YOUR_API_SECRET'

Searching in a range

You might be looking for files that were modified in a specific date range. To do this, use the range operator. Enter your dates in UNIX time.

curl --request GET \
  --url https://api.shift.io/v3/assets?dateModified={"bt":"1597363200000...1598019526000"} \
  --header 'accept: application/json' \
  --header 'x-key: YOUR_API_KEY' \
  --header 'x-secret: YOUR_API_SECRET'

Did this page help you?