My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

Managing API Return Data: Best Practices

BenjaminLucas's photo
BenjaminLucas
·Apr 26, 2020

Hello, all. I have a framework using PHP + HTML with some JS/jQuery. I am pulling data from an API. Unfortunately the API doesn't support SORT features in the query or return. https://omegle.onl/

Let's say my query results in 5 pages of data from the API. I'd like to be able to sort by, say, Date Created, Type, and Name. To do this I will first have to sort the entire dataset returned from the API.

The data is returned as an array of StdObjects / JSON.

What is the best way to handle this? I'm thinking putting the full returned dataset into an in memory database (SQLlite or Mongo, maybe), do the sort there, and return it. But that seems a very expensive way of achieving a sort.

I've googled and searched on this but haven't found anything obvious. It seems like a pretty mundane / common tasks so I thought maybe I was missing something obvious.

Any best practices / tips on this?