News for hackers. Stuff that matters.
Re:The right way to turn off your old APIs by londons_explore on Saturday January 23, 2021 @02:15AM (#25880355)
The best way to turn off old API's is to not need to.

If your API is simple enough that it can be reimplemented as a shim to the new API, and that shim layer needs no state or special permissions, then it becomes effectively maintanance free. Your shim cannot have security issues (since it has no special permissions). It likely won't have scaling issues (no state makes scaling easy). You can leave it sitting there forever if necessary, and the total cost will be well below the risks of turning off an external API.

Re:The right way to turn off your old APIs by zinekeller on Saturday January 23, 2021 @05:04AM (#25881134)
Actually pointed out in the document:

The next question, if you're not napping, is to ask yourself is whether there's an alternative to shutting down this API. Everything you turn off will break somebody's code and take their time to fix it. It's good for the health of your client ecosystem and the web as a whole if APIs keep working.

There are valid reasons to shut down an API (outside of "the company will shut down"). Some API shutdowns are security-wise, for example the API relies on an outdated authentication scheme that can easily be cloned or bruteforced. Assuming that you are in 2012 when credential sharing were acceptable, it's impossible to develop a backwards-compatible API because simply the method to authenticate is now vastly different (tokens versus classic username-password credentials). Some will argue "oh, just generate app passwords!" but unless your audience is that savvy enough, having the API left on will shift the burden from a one-time change to a continual cycle of explaining users to use an app password (which will hit you very badly).

At other times, you need to shut down an API due to an external change. For example, separating APIs by region (note that "oh, just geodetect it" haven't really been sent up letters from a government agency in charge of data and privacy).

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