Web API: Difference between revisions

Content deleted Content added
Example: Link
See also: WP:SEEALSO, linked in lead
 
(45 intermediate revisions by 34 users not shown)
Line 1:
{{Short description|HTTP-based application programming interface usedon inthe web development}}
[[File:Screenshot of NASA API documentation.png|thumb|Screenshot of web API documentation written by [[NASA]]]]
 
A '''web API''' is an [[application programming interface]] for either a [[web server]] or a [[web browser]]. It is a [[web development]] concept, usually limited to a [[web application]]'s client-side (including any [[web framework]]s being used), and thus usually does not include web server or browser implementation details such as [[Server application programming interface|SAPI]]s or APIs unless publicly accessible by a remote web application.
A '''web API''' is an [[API|application programming interface]] (API) for either a [[web server]] or a [[web browser]].
As a web development concept, it can be related to a web application's [[client side]] (including any [[web framework]]s being used).
A server-side web API consists of one or more publicly exposed '''endpoints''' to a defined request–response message system, typically expressed in [[JSON]] or [[XML]] by means of an [[HTTP]]-based web server.
 
A [[server API]] (SAPI) is not considered a server-side web API, unless it is publicly accessible by a remote web application.
 
==Client side==
A [[client-side]] web API is a programmatic interface to extend functionality within a [[web browser]] or other HTTP client. Originally these were most commonly in the form of native [[plug-in (computing)|plug-in]] [[browser extension]]s however most newer ones target standardized [[JavaScript]] bindings.
 
The [[Mozilla Foundation]] created their WebAPI specification which is designed to help replace native mobile applications with [[HTML5]] applications.<ref>{{Cite web|date=2013-12-05|title=Mozilla's WebAPI Wants to Replace Native Apps With HTML5 {{!}} Webmonkey {{!}} Wired.com|url=http://www.webmonkey.com/2011/08/mozillas-webapi-wants-to-replace-native-apps-with-html5/|access-date=2022-01-13|archive-url=https://web.archive.org/web/20131205024538/http://www.webmonkey.com/2011/08/mozillas-webapi-wants-to-replace-native-apps-with-html5/ |archive-date=2013-12-05 }}</ref><ref>[https://developer.mozilla.org/en-US/docs/WebLearn_web_development/APIExtensions/Client-side_APIs Mozilla WebAPI Wiki]</ref>
 
[[Google]] created their [[Google Native Client|Native Client]] architecture which is designed to help replace insecure native plug-ins with secure native [[sandbox (computer security)|sandbox]]ed extensions and applications. They have also made this portable by employing a modified [[LLVM]] [[ahead-of-time compilation|AOT compiler]].
 
==Server side==
A [[server-side]] web API is a programmatic [[interface (computing)|interface]] consistingconsists of one or more publicly exposed ''endpoints'' to a defined [[request–response]] message system, typically expressed in [[JSON]] or [[XML]],. whichThe web API is exposed via the web—mostmost commonly by means of an [[Hypertext Transfer Protocol|HTTP]]-based [[web server]].

''[[Mashup (web application hybrid)|Mashup]]s'' are [[web application]]s which combine the use of multiple server-side web APIs.<ref>{{Cite web |title=What is mash-up? - Definition from WhatIs.com |url=http://whatis.techtarget.com/definition/mash-up |websiteurl-status=WhatIs.comlive |access-date=2015-11-04 |website=WhatIs.com |language=en-US |archive-url=https://web.archive.org/web/20150424163155/http://whatis.techtarget.com/definition/mash-up |archive-date=Apr 24, 2015 }}</ref><ref>{{cite web |year=2009 |title=Mashup Dashboard |url=http://www.programmableweb.com/mashups |url-status=dead |access-date=May 29, 2021 |publisher=ProgrammableWeb.com |yeararchive-url=2009https://web.archive.org/web/20210507015502/http://www.programmableweb.com/mashups |archive-date=May 7, 2021}}</ref><ref>{{Cite journal |last1=Maximilien |first1=E. Michael |last2=Ranabahu |first2=Ajith |last3=Gomadam |first3=Karthik |date=Sep–Oct 2008 |title=An Online Platform for Web APIs and Service Mashups |date=Sep–Oct 2008 |journal=[[IEEE Internet Computing]] |language=en-US |volume=12 |issue=5 |pages=32–43 |doi=10.1109/MIC.2008.92 |last1=Maximilien |first1=E. Michael |last2=Ranabahu |first2=Ajith |last3=Gomadam |first3=Karthik |pages=32–43 |s2cid=14949046 }}</ref> ''[[Webhook]]s'' are server-side web APIs that take input as a [[Uniform Resource Identifier]] (URI) that is designed to be used like a remote [[named pipe]] or a type of [[callback (computer programming)|callback]] 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-peer [[inter-process communication|IPC]].
 
===Endpoints===
'''Endpoints''' are important aspects of interacting with server-side web APIs, as they specify where resources lie that 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 an ''[[access token]]''.<ref>{{Cite web|url=https://blog.twitter.com/developer/en_us/a/2012/changes-coming-to-twitter-api.html|title = Changes coming in Version 1.1 of the Twitter API}}</ref>
 
Endpoints need to be static, otherwise the correct functioning of software that interacts with itthem 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.
 
===Resources versus services===
[[Web 2.0]] Web APIs often use machine-based interactions such as [[representational state transfer|REST]] and [[SOAP]]. RESTful web APIs use [[Hypertext Transfer Protocol|HTTP]] methods to access resources via URL-encoded parameters, and use [[JSON]] or [[XML]] to transmit data. By contrast, [[SOAP]] protocols are standardized by the [[World Wide Web Consortium|W3C]] and mandate the use of [[XML]] as the payload format, typically over [[Hypertext Transfer Protocol|HTTP]]. Furthermore, [[SOAP]]-based Web APIs use [[XML validation]] to ensure structural message integrity, by leveraging the [[XML schema]]s provisioned with [[Web Services Description Language|WSDL]] documents. A [[Web Services Description Language|WSDL]] document accurately defines the XML messages and transport bindings of a [[Web service]].
 
===Documentation===
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, there ''needs'' to be a sufficient level of documentation. One API provider that not only provides documentation, but also links to it in its error messages is [[Twilio]].<ref>{{Cite book|title = Web API Design - Crafting Interfaces that Developers Love|last = Mulloy|first = Brian|publisher = apigee|pages = 11|url = https://pages.apigee.com/rs/apigee/images/api-design-ebook-2012-03.pdf}}</ref>
 
However, there are now directories of popular documented server-side web APIs.<ref>{{Cite web|title = API Directory|url = http://www.programmableweb.com/category/all/apis?order=field_popularity|website = ProgrammableWeb|access-date = 2015-11-03}}</ref>
Line 22 ⟶ 36:
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 as [[Disqus]], whose main service is to provide embeddable tools, such as a feature-rich comment system.<ref>{{Cite web |title=Disqus – The Web's Community of Communities |url=https://disqus.com/ |website=Disqus |access-date=2015-11-04}}</ref> Any website of the TOP 100 [[Alexa 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.<ref>{{Cite web |title=Alexa Top 500 Global Sites |url=http://www.alexa.com/topsites |website=www.alexa.com |access-date=2015-11-04 |archive-date=2015-03-02 |archive-url=https://web.archive.org/web/20150302173920/http://www.alexa.com/topsites |url-status=dead }}</ref>
 
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.<ref>{{Cite web|url=http://apisjson.org/|title=APIs.json|website=apisjson.org|access-date=2016-03-14}}</ref><ref>{{Cite web|url=http://apis.io/|title=APIs.io - the API search engine|website=apis.io|access-date=2016-03-14}}So make it clearly understandable & share your knowledge.</ref>
Line 32 ⟶ 46:
 
====Governmental====
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"<ref>{{Cite web|title = Tech Trends 2015, API economy|url = http://dupress.com/articles/tech-trends-2015-what-is-api-economy/|website = Deloitte University Press|access-date = 2015-11-03|archive-date = 2016-08-15|archive-url = https://web.archive.org/web/20160815023024/http://dupress.com/articles/tech-trends-2015-what-is-api-economy/|url-status = dead}}</ref> to be accessed by any developer in a convenient manner.
 
==Client side==
A [[client-side]] web API is a programmatic interface to extend functionality within a [[web browser]] or other HTTP client. Originally these were most commonly in the form of native [[plug-in (computing)|plug-in]] [[browser extension]]s however most newer ones target standardized [[JavaScript]] bindings.
 
The [[Mozilla Foundation]] created their WebAPI specification which is designed to help replace native mobile applications with [[HTML5]] applications.<ref>{{Cite web|date=2013-12-05|title=Mozilla's WebAPI Wants to Replace Native Apps With HTML5 {{!}} Webmonkey {{!}} Wired.com|url=http://www.webmonkey.com/2011/08/mozillas-webapi-wants-to-replace-native-apps-with-html5/|access-date=2022-01-13|archive-url=https://web.archive.org/web/20131205024538/http://www.webmonkey.com/2011/08/mozillas-webapi-wants-to-replace-native-apps-with-html5/ |archive-date=2013-12-05 }}</ref><ref>[https://developer.mozilla.org/en-US/docs/Web/API Mozilla WebAPI Wiki]</ref>
 
[[Google]] created their [[Google Native Client|Native Client]] architecture which is designed to help replace insecure native plug-ins with secure native [[sandbox (computer security)|sandbox]]ed extensions and applications. They have also made this portable by employing a modified [[LLVM]] [[ahead-of-time compilation|AOT compiler]].
 
==Example==
Line 46 ⟶ 53:
 
According to the API documentation,<ref>{{cite web |url=https://api.nasa.gov/ |website=NASA APIs |title=Astronomy Picture of the Day }}</ref> the API has one endpoint:
https://api.nasa.gov/planetary/apod{{Dead link|date=November 2024 |bot=InternetArchiveBot |fix-attempted=yes }}
 
The documentation states that this endpoint accepts [[GET request]]s. It requires one piece of information from the user, an [[API key]], and accepts several other optional pieces of information. Such pieces of information are known as ''parameters''. The parameters for this API are written in a format known as a [[query string]], which is separated by a [[question mark]] character (<code>?</code>) from the endpoint. An [[ampersand]] (<code>&amp;</code>) separates the parameters in the query string from each other. Together, the endpoint and the query string form a [[URL]] that determines how the API will respond. This URL is also known as a ''query'' or an ''API call''.
Line 53 ⟶ 60:
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 a ''[[return value]]'' or as a ''return''. This API returns [[JSON]], 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 a [[white dwarf star]]:
 
<syntaxhighlight lang="json">
Line 77 ⟶ 84:
 
==See also==
*[[Application programming interface]]
*[[Dynamic web page]]
*[[Overview of RESTful API Description Languages]]
*[[Representational state transfer|REST]]
*[[GraphQL]]
*[[Web service]]
Line 97 ⟶ 103:
|isbn=978-1-4493-0892-6}}
*{{cite book |title=Web API Design - Crafting Interfaces that Developers Love |last1=Mulloy |first1=Brian |publisher=Apigee |url=https://pages.apigee.com/rs/351-WXY-166/images/Web-design-the-missing-link-ebook-2016-11.pdf}}
*{{cite web |title=Web APIs |url=https://developer.chrome.com/extensions/api_other |website=Google Chrome |access-date=2015-11-30 |archive-date=2018-07-19 |archive-url=https://web.archive.org/web/20180719084229/https://developer.chrome.com/extensions/api_other |url-status=dead }}
*{{cite web |title=Web API reference - Web technology reference |url=https://developer.mozilla.org/en-US/docs/Web/Reference/API |website=[[Mozilla Developer Network]]|date=20 February 2023 }}
*{{cite web |title=Web API Demonstration |url=http://sourcecodehub.com/article/428/api-demonstration-aspnet |website=Web API Demonstration}}