2 ms·
I think what we see these days is confusion, where APIs are trying to take over what has traditionally been handled by protocols and file formats. I prefer tha
by makecheck 17y ago
I think what we see these days is confusion, where APIs are trying to take over what has traditionally been handled by protocols and file formats.
I prefer that APIs actually do things, such as calculations, or composite actions that would be awkward to perform individually. (Yes, APIs can exist primarily to expose data, too; but I think APIs that do this are wasting time in unnecessary encapsulation; all they really need to do is something simple, like returning the URL of data in a certain format.)
If I am looking for only data, it should have a (preferably popular) format, optionally with a protocol to access it using whatever network and/or database. This opens you up to multiple implementations, too: so if it turns out that Social Networking Site Du Jour's API isn't actually the most efficient way to do X, you might find an alternative Y that is better, but could use the same data.
APIs are also not good for data for the same reason that APIs can be a problem for code: instability. You can't be sure what languages will remain supported, and when things will change. You have to wait for an API to do X, even if it might have been possible given the "raw" data. And ultimately, a company could go out of business and leave your API unusable, whereas actual data can be copied to avoid this, and cached for performance.