Application Programming Interface (API)

Source: Wikipedia: API


Application programming interface
From Wikipedia, the free encyclopedia
(Redirected from Api)
Jump to: navigation, search
"API" redirects here. For other uses, see API (disambiguation).
Acap.svg
This article may require copy editing for grammar, style, cohesion, tone or spelling. You can assist by editing it. (December 2008)

An Application Programming Interface (API) is an interface implemented by a software program to enable its interaction with other software. It is similar to the way the user interface facilitates interaction between humans and computers. APIs are implemented by applications, libraries and operating systems to determine the vocabulary and calling conventions. The programmer should employ it to use their services. It may include specifications for routines, data structures, object classes, and protocols used to communicate between the consumer and implementer of the API.[1][2][3]
Contents
[hide]

* 1 Concept
* 2 Advanced explanation
* 3 Web APIs
* 4 Use of APIs to share content
* 5 Implementations
* 6 Release policies
* 7 ABIs
* 8 API examples
* 9 Language bindings and interface generators
* 10 See also
* 11 References
* 12 External links

[edit] Concept

An API is an abstraction that describes an interface for the interaction with a set of functions used by components of a software system. The software providing the functions described by an API is said to be an implementation of the API.

An API can be:

* generic, the full set of API that are bundled in the libraries of a programming language (e.g. the Standard Template Library in C++ or the Java API)

* specific, meant to address a specific problem, like the Google Maps API or the Java API for XML Web Services.

* Language-dependent, available only in a given programming language. It is only available by using the syntax and elements of that language to make the API convenient to use in this context.

* Language-independent, written in a way that means it can be called from several programming languages. This is a desired feature for a service-oriented API that is not bound to a specific process or system and may be provided as remote procedure calls or web services.

For example, a website that allows users to review local restaurants is able to layer their reviews over maps taken from Google Maps, because Google Maps has an API that facilitates this functionality. Google Maps' API controls what information a third-party site can use and how they can use it.

"API" may be used to refer to a complete interface, a single function, or even a set of multiple APIs provided by an organization. Thus, the scope of meaning is usually determined by the person or document that communicates the information.
[edit] Advanced explanation

An API may describe the ways in which a particular task is performed. For example, in Unix systems the math.h include file for the C language contains the definition of the mathematical functions available in the C language library for mathematical processing (usually called libm). This file would describe how to use these functions and the expected result. For example, on a Unix system the command man 3 sqrt will present the signature of the function sqrt in the form:

SYNOPSIS
#include <math.h>
double sqrt(double X);
float sqrtf(float X);
DESCRIPTION
DESCRIPTION
sqrt computes the positive square root of the argument. …
RETURNS
On success, the square root is returned. If X is real and positive…

that means that the function returns the square root of a positive floating point number (single or double precision) as a floating point number. Hence the API in this case can be interpreted as the collection of the included files used by the C language and its human readable description provided by the man pages.

In object oriented languages an API usually entails a description of a set of class definitions with a set of behaviours associated with the classes. A behaviour is a description of how an object, derived from that class, will behave in a given circumstance. This abstract concept is associated with real functionalities exposed by the classes that are implemented in terms of actual class methods.

The API in this case can be conceived as the totality of all the methods publicly exposed by the classes (usually called the class interface). This means that the API prescribes the methods by which one handles the objects derived from the class definitions.

More generally one can see the API as the collection of all the kind of objects one can derive from the class definitions, and their associated possible behaviours. The use again is mediated by the public methods, but in this interpretation the methods are seen as a technical detail of how the behaviour is implemented.

For instance: a class representing a Stack can expose publicly two methods push() (to add a new item to the stack), and pop() (to extract the last item, ideally placed on top of the stack).

The API in this case can be interpreted as the two methods pop() and push(), or more generally as the idea that one can use an item of type Stack that implements the behaviour of a stack (a pile exposing its top to add/remove elements).

This concept can be carried to the point where a class interface in an API has no methods at all, but only behaviours associated with it. For instance the Java language API includes the interface Serializable which is an interface that requires the class that implements it to behave in such a serialized fashion. This does not require it to have any public method, but rather requires that the class permit it to have a representation that can be saved at any time (this is typically true for any class containing simple data, and no link to external resources like an open connection to a file, a remote system or an external device).

In this sense, in object oriented languages, the API defines a set of behaviors, possibly mediated by a set of class methods.

In object oriented languages the API is still distributed as a library. For example, the Java language libraries include a set of APIs that are provided in the form of the JDK used by the developers to build new Java programs. The JDK includes the documentation of the API in Javadoc notation. The quality of the documentation associated to an API is often a factor determining its success in terms of ease of use.
[edit] Web APIs
Main article: web service

When used in the context of web development, an API is typically a defined set of Hypertext Transfer Protocol (HTTP) request messages along with a definition of the structure of response messages, usually expressed in an Extensible Markup Language (XML) or JavaScript Object Notation (JSON) format. While "Web API" is virtually a synonym for web service, the recent trend (so-called Web 2.0) has been moving away from Simple Object Access Protocol (SOAP) based services towards more direct Representational State Transfer (REST) style communications[4]. Web APIs allow the combination of multiple services into new applications known as mashups [5].
[edit] Use of APIs to share content

The practice of publishing APIs has allowed web communities to create an open architecture for sharing content and data between communities and applications. In this way, content that is created in one place can be dynamically posted and/or updated in multiple locations on the web.
1. Photos can be shared from sites like Flickr and Photobucket to social network sites like Facebook and MySpace.
2. Content can be embedded, e.g., embedding a presentation from SlideShare on a Linked-In profile.
3. Content can be dynamically posted. Sharing live comments made on Twitter to a Facebook account, for example, is enabled by Twitter and Facebook's APIs.
4. Video content can be embedded on sites which are served by another host.
5. User information can be shared from web communities to outside applications, delivering new functionality to the web community that shares its user data via an open API. One of the best examples of this is the Facebook Application platform. Another is the Open Social platform[6].
[edit] Implementations

The POSIX standard defines an API that allows a wide range of common computing functions to be written such that they may operate on many different systems (Mac OS X, and various Berkeley Software Distributions (BSDs) implement this interface); however, making use of this requires re-compiling for each platform. A compatible API, on the other hand, allows compiled object code to function without any changes to the system implementing that API. This is beneficial to both software providers (where they may distribute existing software on new systems without producing/distributing upgrades) and users (where they may install older software on their new systems without purchasing upgrades), although this generally requires that various software libraries implement the necessary APIs as well.

Microsoft has shown a strong commitment to a backward compatible API, particularly within their Windows API (Win32) library, such that older applications may run on newer versions of Windows using an executable-specific setting called "Compatibility Mode"[7]. Apple Inc. has shown less concern, breaking compatibility or implementing an API in a slower "emulation mode"; this allows greater freedom in development, at the cost of making older software obsolete.[citation needed]

Among Unix-like operating systems, there are many related but incompatible operating systems running on a common hardware platform (particularly Intel 80386-compatible systems). There have been several attempts to standardize the API such that software vendors may distribute one binary application for all these systems; however, to date, none of these have met with much success. The Linux Standard Base is attempting to do this for the Linux platform, while many of the BSD Unices (FreeBSD, NetBSD, OpenBSD) implement various levels of API compatibility for both backward compatibility (allowing programs written for older versions to run on newer distributions of the system) and cross-platform compatibility (allowing execution of foreign code without recompiling).
[edit] Release policies

Common API publishing policies include:

* Protecting information on APIs from the general public. For example, Sony used to make its official PlayStation 2 API available only to licensed PlayStation developers. This enabled Sony to control who wrote PlayStation 2 games. This can increase quality control and provide companies with potential licensing revenue streams.
* Making APIs freely available. For example, Microsoft makes the Microsoft Windows API public and Apple releases its APIs Carbon and Cocoa so that software can be written for their platform.

[edit] ABIs

The related term application binary interface (ABI) is a lower level definition concerning details at the assembly language level. For example, the Linux Standard Base is an ABI, while POSIX is an API.[8]
[edit] API examples
See also: Category:Application programming interfaces

* ASPI for SCSI device interfacing
* Carbon and Cocoa for the Macintosh
* DirectX for Microsoft Windows
* Java APIs
* OpenGL cross-platform graphics API
* OpenAL cross-platform sound API
* OpenCL cross-platform API for general-purpose computing for CPUs & GPUs
* OpenMP API that supports multi-platform shared memory multiprocessing programming in C, C++ and Fortran on many architectures, including Unix and Microsoft Windows platforms.
* Simple DirectMedia Layer (SDL)
* Windows API

[edit] Language bindings and interface generators

APIs that are intended to be used by more than one high-level programming language often provide, or are augmented with, facilities to automatically map the API to features (syntactic or semantic) that are more natural in those languages. This is known as language binding, and is itself an API. The aim is to encapsulate most of the required functionality of the API, leaving a "thin" layer appropriate to each language.

Below are listed some interface generator tools which bind languages to APIs at compile time.

* SWIG generates interfaces from many languages for many languages (Typically Compiled->Scripted)
* F2PY: Fortran to Python interface generator.
* XPCOM (Cross Platform Component Object Model) is a cross platform component model from Mozilla.

[edit] See also

* API Sanity Autotest
* API Writer
* Application Binary Interface (ABI)
* Document Object Model (DOM)
* Double-chance function
* List of 3D graphics APIs
* Mashup (web application hybrid)
* Open Service Interface Definitions (OSID)
* Platform-enabled website
* Plugin
* Software Development Kit (SDK)
* Web service

[edit] References

1. ^ "Application Program accessdate=2009-06-28".
2. ^ "Definition of: API". PC Magazine. 1996. http://www.pcmag.com/encyclopedia_term/0,2542,t=application+programming+interface&i=37856,00.asp. Retrieved 2009-06-28.
3. ^ Orenstein, David (2000-01-10). "QuickStudy: Application Programming Interface (API)". Computerworld. http://www.computerworld.com/action/article.do?command=viewArticleBasic&articleId=43487. Retrieved 2009-06-04.
4. ^ Benslimane, Djamal; Schahram Dustdar, and Amit Sheth (2008). "Services Mashups: The New Generation of Web Applications". IEEE Internet Computing, vol. 12, no. 5. Institute of Electrical and Electronics Engineers. pp. 13–15. http://dsonline.computer.org/portal/site/dsonline/menuitem.9ed3d9924aeb0dcd82ccc6716bbe36ec/index.jsp?&pName=dso_level1&path=dsonline/2008/09&file=w5gei.xml&xsl=article.xsl.
5. ^ Niccolai, James (2008-04-23), "So What Is an Enterprise Mashup, Anyway?", PC World, http://www.pcworld.com/businesscenter/article/145039/so_what_is_an_enterprise_mashup_anyway.html
6. ^ "Dynamic Community content via APIs". October 26 2009.
7. ^ Microsoft (October 2001). "Run Older Programs On Windows XP" (in EN). Microsoft. pp. 4. http://www.microsoft.com/windowsxp/using/helpandsupport/learnmore/appcompat.mspx.
8. ^ Stoughton, Nick (April 2005). "Update on Standards" (PDF). USENIX. https://db.usenix.org/publications/login/2005-04/openpdfs/standards2004.pdf. Retrieved 2009-06-04.

[edit] External links

* How to design a good API and why it matters-PDF
* Service-Oriented Architecture (SOA): The Road to Enterprise Application Integration (EAI)
* ISO/IEC JTC 1 Directives, 5th Edition Version 3.0, Annex J: Guidelines for API standardization
* API functions tutorial for game making
* Why using APIs and why managing them

Retrieved from "http://en.wikipedia.org/wiki/Application_programming_interface"
Categories: Technical communication | Application programming interfaces

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License