Limit "GET /v2/actions" by date range?

Posted September 28, 2017 2k views

Hello, I was wondering if there was, or could be, a way to limit the returned actions from the /v2/actions endpoint, by some kind of date range. It would be nice to be able to only retrieve actions from say, the last day, or week, or something. For example:

GET /v2/actions?since=<some date string/# of seconds since epoch, etc>&until=<another date string of some kind>

would limit the results to be between the since' anduntil’ parameters.

Is something like this possible and I’m just not seeing it? Or could it easily be added?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer

As far as I’m aware there is no such option. You will have to develop it yourself.

  • I mean, I can filter the returned results by a date range, but I was hoping there would be a way to cut down on the number of requests, since I’d have to make as many requests as necessary to retrieve all the actions for an account, then do the filtering only after downloading all of them.

    • You can’t filter by a date, but if you just want to cut down number of entries in the response, you can play around with list options.

      So what you can do.. DO API supports paging. You can pass the number of entries and number of page you want to get.

      If you would execute:

      • curl -X GET -H "Content-Type: application/json" -H "Authorization: Bearer token" ""

      You would only get 10 records, instead of all records.
      However, I don’t know is it defined which 10 records you’ll get. You can get last 10 records, or first 10 records.
      As far as I tested, it returns latest records.

      If you need to obtain the last page, you would have to execute one arbitrary request to get the link of the last page, and then execute that link.

      Still, you can’t list by the date, but it could help you to cut down the number of responses.

      The following API resources could be helpful to you, if you didn’t already found them:
      DigitalOcean API — Actions
      DigitalOcean API — Meta and Links