News for hackers. Stuff that matters.
Re:The right way to turn off your old APIs by nexuist on Saturday January 23, 2021 @03:52AM (#25880757)
I don't understand, what use is a REST API with no state? Who is making remote HTTP calls for calculating e.g. math equations or unit conversions? A stateless REST API is completely useless; just do everything locally.

For everything else, there will be state to manage, and it's not easy to shove a new version on top of an old version (hence why every API provider agrees to just offer two or more separate versions of the API server rather than having one unified API).

Re:The right way to turn off your old APIs by saberdancer on Saturday January 23, 2021 @06:52AM (#25881590)
Address lookups, weather lookup, company lookup, telephone lookup, autocomplete lookups, ...

Why wouldn't there be a stateless API?

Re:The right way to turn off your old APIs by corty on Saturday January 23, 2021 @08:29AM (#25882051)
Depends on your definition of "stateless".

A database is commonly considered state, so database queries are never stateless in some definitions. Answers to stateless queries can be cached indefinitely. Your examples can't.

Your definition probably just says that one query shouldn't influence the next one in a session/context/user. The other definition says that any query with the same parameters should yield the same result.

Re:The right way to turn off your old APIs by xg15 on Saturday January 23, 2021 @09:08AM (#25882308)
By this logic, there is no such thing as a stateless API because even a trivial "add those numbers" API would rely on the "state" of the server binary or code - which could also change at any time.

I think a more useful definition is your second paragraph - i.e. does the server have to keep state specifically for the client that did the last request? This is the case for sessions and for many non-HTTP protocols that need to track state per connection (e.g. TCP tracks connection flags, statistics and sequence numbers, TLS tracks your keys, FTP tracks your current directory, SMTP tracks which data fields were sent, etc etc).

It does not apply for simple database searches or even CRUD endpoints because while there is global state (there always is), the server does not care which client in particular made the requests.

APIs that have no per-client state can generally be implemented by a shim that internally calls a newer API pretty easily. It's not that easy with APIs that do have per-client state.

Re:The right way to turn off your old APIs by MaxBarraclough on Saturday January 23, 2021 @05:53AM (#25881362)
I think they meant that the shim can be stateless, as it just defers requests to the new API.
Re:The right way to turn off your old APIs by londons_explore on Saturday January 23, 2021 @09:03AM (#25882275)
Exactly.
Re:The right way to turn off your old APIs by xg15 on Saturday January 23, 2021 @12:36PM (#25884323)
In addition to the DB lookup point, even if the task is only doing calculations that a user could in theory also do locally, there are valid reasons why you'd want to put it behind a network boundary: The calculations may be so complex they require specialized or powerful hardware (e.g. graphics or neural network computations), they may rely on data that you don't want to show to your users - or you may want to keep the details of the calculation itself secret for IP reasons.
Re:The right way to turn off your old APIs by vasergen on Saturday January 23, 2021 @10:39AM (#25882977)
Think here about stateless in this way. Imagine you scaled your API to 2 instances. Stateless here means you don't care which server you hit.
Re:The right way to turn off your old APIs by bspammer on Saturday January 23, 2021 @06:16AM (#25881465)
A trained model is just a bunch of stateless math but they are often deployed behind an API