What is an api?
In web dev, is the interaction between the client and server considered an api?
- Newms34Lv 61 month ago
An Application Programming Interface is, in overly-simple terms, exactly what it says on the box: it's a way for a Program to Interface with your Application. So in the case of a client and web server, you
consider the interaction between the client and server an API of sorts, but there's usually a slightly more strict definition.
To quote Wikipedia, an API "[abstracts] the underlying implementation and only exposing objects or actions the developer needs" (or, only objects or actions the developer wants to be available). Huh? So let's take the example of an MMO I play, Guild Wars 2. They have a surprisingly comfy API that allows you to access stuff like current market price, skill info, etc.in relatively real-time. The GW2 devs might want you to be able to read the current price of, say, iron ingots on the in game market, but they certainly don't want you to be able sell stuff using that API (because that would open the game to some serious market manipulation flaws). So the GW2 API has a route at https://api.guildwars2.com/v2/commerce/prices/1968... (19683 is the ID for "iron ingot") that lists current prices (high and low) for iron ingots. It does not, however, have something like "https://api.guildwars2.com/v2/commerce/sellThisIte... that'd allow you to sell an iron ingot.
An API doesn't have to be HTTP (or similar stuff) either. Often times, in using a library (such as jQuery), we refer to the individual "bits" we can use from the library as belonging to an API. Again, I'm gonna quote Wikipedia here, which says that "the API describes and prescribes the 'expected behavior' (a specification) while the library is an 'actual implementation' of this set of rules". So I know for example that if I do "jQuery('#some-css-id .some-class')", that'll use normal CSS selector "abilities" to find an element with id "some-css-id" and then find a sub-element with class "some-class". I don't need to care about how this is done; just that I expect jQuery to be able to do it.
- amania_rLv 72 months ago
Strictly speaking a web browser communication with a web server uses an API (HTML over HTTP) but it's never called that. AJAX in that context however is called an API.
Other clients talking to servers use APIs. E.g. SOAP, REST, RPC etc are called APIs
- ∅Lv 72 months ago
application program interface is a way to interact with data using an application.
an API is a way to make such interaction seemless, without giving source info.
so like how Google offers a way to use their services with 3rd party software, by having API code available, so that you don't need direct access to their servers to be able to use them.