Searching by Date

It's common to want to see files based on some time criteria. For example, you may be interested in see the lates files. Or, you may want to keep an eye on aging files that you want to archive or remove from the system altogether.

Searching for recent files

Let's find files that have been created in the last week. Dates in SHIFT are in UNIX time in milliseconds. So, to first we need to get our start time formatted to UNIX time. For this example, last weeks time in UNIX milliseconds is 1598019526. To find all files created since that 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 last week 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 accomplish this we can use the range operator. Choose your dates in UNIX time milliseconds.

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?