An introduction
Thanks for checking out Popcorn!
Like many open source libraries, Popcorn started as a solution to a problem that came up in a few of our projects around the same time. Our team needed to be able to stitch together objects that were being returned by a .NET Core ReSTful API. At times, we had to retrieve a collection of a thousand items; then, for each item, make an identical request to the API to get a piece of dependent data.
That makes for a ton of network traffic, and it wasn’t very efficient. We could have changed the endpoint for a specific usage, or added a new endpoint… but by then you are designing the API around one particular application’s usage parameters, and if you plan to release a public API… well, that way lies madness.
A few quick googles later, we found a couple of things: There are indeed solutions for this problem; JSON API and GraphQL are two well-established players in this space. The existing solutions all require specific schemas and would require us to start over from scratch with our client API implementations, and at least partially rewrite our server code.
Well, starting over didn’t sound great, and we didn’t love the idea of handing over our schema design entirely anyway. Instead, we created our own answer that would ‘sit on top’ of an existing API and provide a pluggable mechanic so it could handle a variety of actual implementations.
Thus, Popcorn was born!
With Popcorn we could specify in our initial request what data we wanted to drill down into, so that first call that retrieved a thousand items already contained the information we needed. But if we didn’t request it, the data wasn’t included, meaning a smaller, quicker transfer and less stress on the database. Either way, this request was simply an additional query parameter that didn’t require modifying our endpoint routes.
It has grown a bit since then with some other features we found valuable along the way — server side sorting and per-object authorization calls are a couple of my favorites — and we hope others find it as quick and easy as we did. We’re still actively developing it, and already getting some great community feedback and pull requests.
Head on over to our documentation site to learn more, or visit the GitHub repo to get involved!