
Aweb API is anapplication programming interface (API) for either aweb server or aweb browser. As a web development concept, it can be related to a web application'sclient side (including anyweb frameworks being used). A server-side web API consists of one or more publicly exposedendpoints to a defined request–response message system, typically expressed inJSON orXML by means of anHTTP-based web server.
Aserver API (SAPI) is not considered a server-side web API, unless it is publicly accessible by a remote web application.
Aclient-side web API is a programmatic interface to extend functionality within aweb browser or other HTTP client. Originally these were most commonly in the form of nativeplug-inbrowser extensions however most newer ones target standardizedJavaScript bindings.
TheMozilla Foundation created their WebAPI specification which is designed to help replace native mobile applications withHTML5 applications.[1][2]
Google created theirNative Client architecture which is designed to help replace insecure native plug-ins with secure nativesandboxed extensions and applications. They have also made this portable by employing a modifiedLLVMAOT compiler.
Aserver-side web API consists of one or more publicly exposedendpoints to a definedrequest–response message system, typically expressed inJSON orXML. The web API is exposed most commonly by means of anHTTP-basedweb server.
Mashups areweb applications which combine the use of multiple server-side web APIs.[3][4][5]Webhooks are server-side web APIs that take input as aUniform Resource Identifier (URI) that is designed to be used like a remotenamed pipe or a type ofcallback such that the server acts as a client to dereference the provided URI and trigger an event on another server which handles this event thus providing a type of peer-to-peerIPC.
Endpoints are important aspects of interacting with server-side web APIs, as they specify where resources can be accessed by third-party software. Usually the access is via a URI to which HTTP requests are posted, and from which the response is thus expected. Web APIs may be public or private, the latter of which requires anaccess token.[6]
Endpoints need to be static, otherwise the correct functioning of software that interacts with them cannot be guaranteed. If the location of a resource changes (and with it the endpoint) then previously written software will break, as the required resource can no longer be found at the same place. As API providers still want to update their web APIs, many have introduced a versioning system in the URI that points to an endpoint.
Web 2.0 Web APIs often use machine-based interactions such asREST andSOAP. RESTful web APIs useHTTP methods to access resources via URL-encoded parameters, and useJSON orXML to transmit data. By contrast,SOAP protocols are standardized by theW3C and mandate the use ofXML as the payload format, typically overHTTP. Furthermore,SOAP-based Web APIs useXML validation to ensure structural message integrity, by leveraging theXML schemas provisioned withWSDL documents. AWSDL document accurately defines the XML messages and transport bindings of aWeb service.
Server-side web APIs are interfaces for the outside world to interact with the business logic. For many companies this internal business logic and the intellectual property associated with it are what distinguishes them from other companies, and potentially what gives them a competitive edge. They do not want this information to be exposed. However, in order to provide a web API of high quality, thereneeds to be a sufficient level of documentation. One API provider that not only provides documentation, but also links to it in its error messages isTwilio.[7]
However, there are now directories of popular documented server-side web APIs.[8]
The number of available web APIs has grown consistently over the past years, as businesses realize the growth opportunities associated with running an open platform, that any developer can interact with.ProgrammableWeb tracks over 24000 Web APIs that were available in 2022, up from 105 in 2005.
Web APIs have become ubiquitous. There are few major software applications/services that do not offer some form of web API. One of the most common forms of interacting with these web APIs is via embedding external resources, such as tweets, Facebook comments, YouTube videos, etc. In fact there are very successful companies, such asDisqus, whose main service is to provide embeddable tools, such as a feature-rich comment system.[9] Any website of the TOP 100Alexa Internet ranked websites uses APIs and/or provides its own APIs, which is a very distinct indicator for the prodigious scale and impact of web APIs as a whole.[10]
As the number of available web APIs has grown, open source tools have been developed to provide more sophisticated search and discovery. APIs.json provides a machine-readable description of an API and its operations, and the related project APIs.io offers a searchable public listing of APIs based on the APIs.json metadata format.[11][12]
Many companies and organizations rely heavily on their Web API infrastructure to serve their core business clients. In 2014Netflix received around 5 billion API requests, most of them within their private API.[13]
Many governments collect a lot of data, and some governments are now opening up access to this data. The interfaces through which this data is typically made accessible are web APIs. Web APIs allow for data, such as "budget, public works, crime, legal, and other agency data"[14] to be accessed by any developer in a convenient manner.
An example of a popular web API is theAstronomy Picture of the Day API operated by the American space agencyNASA. It is a server-side API used to retrieve photographs of space or other images of interest toastronomers, andmetadata about the images.
According to the API documentation,[15] the API has one endpoint:
https://api.nasa.gov/planetary/apod[permanent dead link]
The documentation states that this endpoint acceptsGET requests. It requires one piece of information from the user, anAPI key, and accepts several other optional pieces of information. Such pieces of information are known asparameters. The parameters for this API are written in a format known as aquery string, which is separated by aquestion mark character (?) from the endpoint. Anampersand (&) separates the parameters in the query string from each other. Together, the endpoint and the query string form aURL that determines how the API will respond. This URL is also known as aquery or anAPI call.
In the below example, two parameters are transmitted (orpassed) to the API via the query string. The first is the required API key and the second is an optional parameter — the date of the photograph requested.
https://api.nasa.gov/planetary/apod?api_key=DEMO_KEY&date=1996-12-03
Visiting the above URL in a web browser will initiate a GET request, calling the API and showing the user a result, known as areturn value or as areturn. This API returnsJSON, a type of data format intended to be understood by computers, but which is somewhat easy for a human to read as well. In this case, the JSON contains information about a photograph of awhite dwarf star:
{"date":"1996-12-03","explanation":"Like a butterfly,\r a white dwarf star begins its life\r by casting off a cocoon that enclosed its former self. In this\r analogy, however, the Sun would be\r a caterpillar\r and the ejected shell of gas would become the prettiest of all!\r The above cocoon, the planetary nebula\r designated NGC 2440, contains one of the hottest white dwarf stars known.\r The white dwarf can be seen as the bright dot near the photo's\r center. Our Sun will eventually become a \"white dwarf butterfly\",\r but not for another 5 billion years. The above false color image recently entered the public domain\r and was post-processed by F. Hamilton.\r","hdurl":"https://apod.nasa.gov/apod/image/9612/ngc2440_hst2_big.jpg","media_type":"image","service_version":"v1","title":"Cocoon of a New White Dwarf\r\nCredit:","url":"https://apod.nasa.gov/apod/image/9612/ngc2440_hst2.jpg"}
The above API return has been reformatted so that names of JSON data items, known askeys, appear at the start of each line. The last of these keys, namedurl, indicates a URL which points to a photograph:
https://apod.nasa.gov/apod/image/9612/ngc2440_hst2.jpg
Following the above URL, a web browser user would see this photo:
Although this API can be called by anend user with a web browser (as in this example) it is intended to be called automatically by software or by computer programmers while writing software. JSON is intended to beparsed by a computer program, which would extract the URL of the photograph and the other metadata. The resulting photo could be embedded in a website, automatically sent via text message, or used for any other purpose envisioned by a software developer.
{{cite web}}: CS1 maint: url-status (link){{cite journal}}:Cite journal requires|journal= (help)