Have you ever seen a fully implemented, truly and absolutely by-the-books REST API? With all the correct HTTP methods, status codes, and the perfect design?
No? Me neither. And you might ask — why not? After all, it's supposed to be easy, right?
Well, yes — technically, it is easy. But in real life, you always run into edge cases.
Let’s take a simple example. According to REST principles, if you want to retrieve data, you should use the GET
method. Simple and elegant, and documented everywhere. But then the question arises: how do you pass parameters in a GET
request?
Answer: via URL path or query parameters.
But as you already know, there’s a limit to how much you can fit into a URL — usually around 2048 characters. That’s fine for small, basic queries. But what about advanced searches? You want to pass dozens of filters, custom ordering, maybe even a list of IDs to fetch. Sometimes it’s a list of GUIDs — and not just one or two, but hundreds.
In these cases, GET
simply doesn’t work. The URL becomes too long and breaks. So what’s the alternative?
The common solution is to switch to a POST
request. It works perfectly — you can pass a large JSON body with all your parameters.
But wait… according to REST, POST
is for creating data, not retrieving it.
So now you're stuck:
-
You can't use
GET
because of technical limitations. -
You shouldn’t use
POST
because it goes against the philosophy of REST.
What now?
This is one of those grey zones where you have to balance between theory and practicality. In my experience, I’ve had to use POST
for advanced search endpoints. I’ve seen APIs that even created a special route like /search
or /query
and used POST
there — clearly breaking REST rules, but solving real-world problems.
If you’ve faced this too, I’d love to hear how you handled it.
Do you break the rules for the sake of usability? Or do you find creative workarounds to stay within REST boundaries?
Share your thoughts and use cases — let’s talk about the real REST API, not just the one in textbooks.
Comments
Post a Comment