What is an API (application programming interface)? Definition and examples

A lot of people who work in technology have an intuitive understanding of what an API (application programming interface) is — but if you asked them to define it, they might have trouble putting an explanation into words. In simple terms, an API is both a piece of software running on a networked server and a component of programming code.

APIs are standards for application data interchange, just as protocols are standards for network data interchange. Without them, software developers would have a much harder time writing code to get information from platforms or apps they want to access.

API definition

When running on a server, an API is a set of coded routines that receives requests from and sends responses to other programs. API designers implement that code through standardised programming statements that expose functions that make sense for accessing the platform in question.

For example, suppose you wanted to incorporate a map to your business on your website or display a list of your latest tweets. You can’t directly access Google Maps or Twitter — the code that runs those sites sits on Google and Twitter servers. But those platforms provide APIs that let authorised users retrieve data from their sites.

The Google Maps API and Twitter API may be among the most widely used API examples, but most software-as-a-service (SaaS) providers offer APIs that let developers write code that posts data to and retrieves data from the provider’s site as well.

Developers can use multiple different programming languages to create web-based APIs, including Java, JavaScript, Perl, Python, and Ruby. Each call that’s a part of these APIs has a defined syntax, and each vendor that provides an API documents its syntax, usually on their site or sometimes on sites like GitHub or ProgrammableWeb.

Most types of APIs have several methods, or operations, that allow developers to create, retrieve, update, and delete data. The verbs used to implement these methods are, respectively, POST, GET, PUT, and DELETE. Each method generally takes a payload in the form of a file in a defined format (usually JSON or XML) that contains the data to be operated on, and uses a URI (Uniform Resource Identifier) that acts as an address where the API can interact with the calling programme.

How does that look in practise? Let’s look at a Talend API as an example. The Stitch Import API lets developers send data from an arbitrary source to the Stitch data pipeline. You can push a single record through the Stitch data pipeline with a POST API call:

<pre> curl -X "POST" " https://api.stitchdata.com/v2/import/batch" \
     -H 'Authorization: Bearer [ACCESS_TOKEN]' \
     -H 'Content-Type: application/json' \
     -d $
'{
    "table_name": "customers",
    "schema": {
      "properties": {
        "id": {
          "type": "integer"
        },
        "name": {
          "type": "string"
        },
        "age": {
          "type": "integer"
        },
        "has_magic": {
          "type": "boolean"
        },
        "modified_at":{
            "type":"string",
            "format":"date-time"
         }
      }
    },
    "messages": [
      {
        "action": "upsert",
        "sequence": 1565880017,
        "data": {
          "id": 1,
          "name": "Finn",
          "age": 15,
          "has_magic": false,
          "modified_at":"2020-12-13T21:25:03+0000"
        }
      }
    ],
    "key_names": [
      "id"
    ]
  }'
</pre>

APIs are useful because they make software developers more productive. Without them, all developers would have to write and then maintain their own code to access remote resources. Having a standard way to read from and write to those resources makes the platform that provides the API more accessible and more attractive to developers, therefore increasing the likelihood that third parties will use and exchange data with their platform.

History of APIs

APIs have been around longer than the World Wide Web — for several decades, in fact. They became more popular with the rise of network computing, when server-based application vendors and operating systems needed standard ways to allow clients to access server resources.

As the Web became ubiquitous, APIs moved into web development. Salesforce introduced the first web APIs when it launched in 2000.

API design

Many of these early APIs relied on SOAP — Simple Object Access Protocol. “Simple” was a misnomer. SOAP relies on XML documents and remote procedure calls (RPC). Developers had to concern themselves with things like transport bindings, operation names, and endpoint URIs. No one set standards for API design, so SOAP APIs were hard to maintain.

An alternative known as CORBA (Common Object Request Broker Architecture), defined by the Object Management Group (OMG), was even more complex.

REST API

Recognising the need for simplicity, computer scientist Roy Fielding proposed representational state transfer (REST) in his Ph.D. thesis as “an abstraction of the architectural elements within a distributed hypermedia system” — namely the World Wide Web. It provides roles for a user agent (commonly a web browser), an origin server that provides access to web services, and intermediary components that forward requests and responses. RESTful web services allow requesting systems to access and manipulate representations of web resources by using a uniform, predefined set of stateless operations. Stateless just means that the web services don’t retain session information from one request to another.

eBay launched the first REST API in 2002, and quickly proved the wisdom of allowing developers who worked outside the company to add value to eBay’s platform. Since that time, software development teams have written APIs not just for web-based services, but for social media, mobile applications, and hardware devices (the Internet of Things, or IoT), among other platforms. Today, almost all vendors' APIs are REST-based APIs.

Most APIs are public APIs (also called open APIs). After all, if programmers outside your organization can’t use your API, how much value does it have? But private APIs can be useful in certain circumstances, such as internal APIs that can only be accessed and used by an organization’s developers for internal use cases. Partner APIs fall somewhere in between, accessible only to a company’s business partners.

API integration

APIs are also a key tool for application integration. Application integration is a means of enabling applications and systems from different vendors to involve each other in their workflows, so that, for example, you can enter data in one application and have it automatically available in other platforms.

An API integration serves as the connection between two applications, letting them exchange data. APIs allow developers to sync data between multiple platforms and can facilitate communication among the various microservices in web applications. API integration is what does the work when, for example, you enter a new contact in Salesforce and it auto-populates to Marketo as well.

A key advantage of API integration is that it automates data sharing in a secure process, therefore helping maintain data integrity between platforms.

API management

To create APIs, businesses turn to API management software. API management tools foster the creation and publication of APIs, enforce usage policies, control access, collect and analyse usage statistics, and report on performance. Both commercial and open source API management tools are available. You can read more about them.

Talend API Services

Many organizations see the value of offering APIs to let outside developers interact with their platforms, but designing and documenting APIs can be a major project that takes months of developer time and costs tens of thousands of dollars.

Rather than start from scratch, businesses can use Talend API Services to do the heavy lifting. It lets developers collaborate to create and test new APIs with visual design tools and an intuitive user interface. We’d be happy to give you a demo and show you what Talend API Services can do for you.

Ready to get started with Talend?