Welcome to the new Box Support website. Check out all the details here on what’s changed.

How to get latest 20 User Events with Box API?

Answered
New post

Comments

6 comments

  • Kourtney

    Hey , 

     

    Thanks so much for using our platform and development forum! 

     

    Have you tried setting the limit query parameter? Unfortunately, dates can only be specified with enterprise events, but not user events. 

     

    Best, 

    Kourtney

    0
    Comment actions Permalink
  • huumq00731

    Hey 

    Thanks for your support.

    I have tried limit query parameter, but result is 20 first events.

    My expect is 20 latest Events.

     

    0
    Comment actions Permalink
  • huumq00731

    Any Body can help Me? :(((((

    0
    Comment actions Permalink
  • LoCortes

    Hello ,

    I've not used this endpoint but as per documentation there are important points:

    • Because of its emphasis on returning complete results quickly, Box may return duplicate events, and events may delivered out of order.
    • "next_stream_position": 1348790499819,

    I understand from these two points that you may never be sure that the last 20 are actually the last ones. But most important, BOX shows the next stream position but not the previous one. So, you can not start from "now" and go backwards. 

     

    So I think that the approach you are using is the only option. Not the best one as it will take a lot of API calls and a lot of time to reach the last elements. 

     

    The Only option I can think of is to use the "now" value for stream_position. So, you can query the full list now till you have the 20 last. Then, you should cache the last stream position somewhere or the "now" one, and every time you run your query use that value and update it with the latest. So you can start gathering always from that point and not from the beginning. 

     

    Thanks

    0
    Comment actions Permalink
  • huumq00731

    Hi 

    Thanks for your support.

    Your solution is very good. I will implement that.

    I think the better is Box provide the function to get from now to forward, not from start point to now.

     

    Many thanks!

    0
    Comment actions Permalink
  • LoCortes

    Hello,

    glad this proposal works for you 🙂

     

    Happy to help.

     

    Best regards

     

    0
    Comment actions Permalink

Please sign in to leave a comment.