Just like a user interface enables com­mu­ni­ca­tion between humans and machines, APIs enable com­mu­ni­ca­tion between different software ap­pli­ca­tions. Thanks to these in­ter­faces, data can be trans­ferred back and forth in an orderly manner. This even works when the ap­pli­ca­tions were created in different pro­gram­ming languages.

Key Takeaways

Anyone con­nect­ing software to an outside service works through its API: the provider decides which functions are available, who is allowed to call them and in what form the answer comes back.

  • What an API is: an ap­pli­ca­tion pro­gram­ming interface through which one program can call defined functions of another and exchange data in a stan­dard­ized form
  • Why they are needed: they let de­vel­op­ers reuse existing software com­po­nents, connect services to one another and control who is allowed in
  • How they work: the provider publishes an interface and documents it, the calling program sends a request to it and receives a defined response
  • Which types exist: function-based, file-based, protocol-based and object-based in­ter­faces, plus the dis­tinc­tion between private and public APIs
  • How to test them: with a graphical client such as Postman or on the command line with curl
IONOS Developer API
Manage your hosting products through our powerful API
  • DNS man­age­ment
  • Easy SSL admin
  • API doc­u­men­ta­tion

What is an API?

API stands for ap­pli­ca­tion pro­gram­ming interface. As the name suggests, APIs allow external pro­gram­mers to access certain functions. The in­ter­faces act as the entry point to another software program. Both programs can use the API to com­mu­ni­cate with each other, exchange data and issue commands. And this is possible with desktop software as well as mobile apps and web ap­pli­ca­tions. An in­di­vid­ual program can also be designed so that various modules com­mu­ni­cate with one another via in­ter­faces.

De­f­i­n­i­tion: API

An ap­pli­ca­tion pro­gram­ming interface is an interface that connects various programs together and stan­dard­izes data trans­mis­sion and the exchange of in­struc­tions between the program modules.

Why do we need APIs?

Nowadays, APIs are used by various software man­u­fac­tur­ers to make it easier for pro­gram­mers to access software com­po­nents. SAP, Amazon and Google offer APIs for different ap­pli­ca­tion areas, for example. These in­ter­faces allow de­vel­op­ers to perform different tasks:

  • Forward a developer’s in­struc­tion to a software program and receive its response
  • Insert content in web services
  • Reuse app codes by net­work­ing programs
  • Control access for other pro­gram­mers

In daily use, APIs are used in web services for instance. When booking a flight, you can ask a suitable search engine to find all flights and flight prices for a certain des­ti­na­tion and date. As soon as you click on “Search”, the website will start to com­mu­ni­cate with the APIs of the in­di­vid­ual airlines to find out prices for the des­ti­na­tion. This all happens in a matter of seconds and you, as the customer, quickly receive an overview of available flights. But how exactly does it work?

Tip

Fancy pro­gram­ming a mobile app? Our starter guide on mobile app design has all the in­for­ma­tion you need.

How do APIs work?

Although they benefit end users, APIs are primarily intended for pro­gram­mers. The ap­pli­ca­tion pro­gram­ming interface is typically provided by software de­vel­op­ers so that pro­gram­mers of other ap­pli­ca­tions can use the interface. The pro­gram­ming interface defines how in­for­ma­tion and data are accepted and returned between modules. For instance, Google has released an API that enables other pro­gram­mers to dock their own ap­pli­ca­tions to Google services. Here, a dedicated standard is used which the external software has to follow.

The REST protocol is highly popular for com­mu­ni­ca­tion between ap­pli­ca­tions – es­pe­cial­ly within the web. A REST API uses the same commands as HTTP. The in­struc­tions are not complex and, therefore, make in­for­ma­tion exchange quite easy. What’s more, the basic protocol sim­pli­fies the process of es­tab­lish­ing a con­nec­tion to the API for pro­gram­mers.

What that looks like in practice is a short exchange. The calling program addresses a defined web address, the endpoint, and states which resource it wants and what it intends to do with it. The interface answers with a defined response: a status code that says whether the request worked, and the requested data as a struc­tured data set, today usually in JSON format. Because that response follows an agreed structure, the calling program can read it without knowing anything about the internals of the program that produced it – which is exactly why the exchange also works between ap­pli­ca­tions written in different pro­gram­ming languages.

Access to the interface is part of what an API defines. A provider that opens an interface to outside pro­gram­mers needs to be able to tell callers apart, so a developer normally registers an ap­pli­ca­tion first and receives an API key that is sent with every request. Where an interface reaches data belonging to an in­di­vid­ual user, a key is not enough: The user is asked to grant per­mis­sion, and the ap­pli­ca­tion then works with a token issued for that one user. The widely used standard for this is OAuth 2.0. Providers also set limits on how often an interface may be called within a given period, which is why a program that uses external APIs has to be prepared for a request being turned down.

So, stan­dard­iza­tion is vital in order to use the pro­gram­ming interface – re­gard­less of which protocol is used for exchange. Moreover, it’s important to show other pro­gram­mers how to use the interface properly. That’s why an API is often provided with extensive doc­u­men­ta­tion on syntax and function. Many providers write that doc­u­men­ta­tion in a machine-readable form, the OpenAPI spec­i­fi­ca­tion being the common one; the Swagger toolset is built around it and generates readable doc­u­men­ta­tion and test pages from such a de­scrip­tion. Good doc­u­men­ta­tion also names the version of the interface it describes. In­ter­faces change over time, and providers usually keep an older version reachable for a tran­si­tion period – often marked by a version number in the endpoint address – so that ap­pli­ca­tions built against it keep working.

GZvSYJDk-us.jpg To display this video, third-party cookies are required. You can access and change your cookie settings here.

What types of API exist?

There are generally four different classes of pro­gram­ming interface:

  • Function-based APIs
  • File-based APIs
  • Protocol-based APIs
  • Object-based APIs

The choice of class depends on the relevant area of ap­pli­ca­tion. Function-based pro­gram­ming in­ter­faces are rel­a­tive­ly complex. For example, they enable de­vel­op­ers to access hardware com­po­nents. But only functions are accessed. File-based APIs enable con­nec­tions at the file level. This way, data can be requested and written. The protocol-based interface provides stan­dard­ized com­mu­ni­ca­tion between programs and does not depend on the operating system or hardware. Lastly, object-based APIs are more versatile.

A dif­fer­en­ti­a­tion can also be made between internal in­ter­faces and public APIs. Private in­ter­faces are only available within an or­ga­ni­za­tion. They are often used to connect a company’s own func­tion­al­i­ties, allowing employees or customers to gain access to private networks. Public in­ter­faces are open to de­vel­op­ers outside the provider’s or­ga­ni­za­tion – which rarely means that they are open without con­di­tions. Usually, you register an ap­pli­ca­tion, accept the provider’s terms of use and receive the key or token described above. Google, Amazon, eBay, Facebook and PayPal all run public APIs of this kind. What such access costs does not depend on how many people work with it: Providers price a public API by what is actually requested of it – the number of calls, the volume of data trans­ferred or a quota booked in advance – and many of them keep a free tier below a certain number of calls per day. Many providers (such as Google) also actively invite de­vel­op­ers to par­tic­i­pate in their API de­vel­op­ment.

What ad­van­tages do APIs have?

APIs provide a number of ad­van­tages and for different groups of people: end users benefit from pro­gram­ming in­ter­faces just as much as the de­vel­op­ers do.

De­vel­op­ers who equip their programs with good pro­gram­ming in­ter­faces can expect to achieve greater dis­tri­b­u­tion. Since this makes it easier for other pro­gram­mers to interact with the software, ap­pli­ca­tions with effective APIs are preferred. External de­vel­op­ers can sig­nif­i­cant­ly expand the func­tion­al scope of their own software by building con­nec­tions with other ap­pli­ca­tions. Ul­ti­mate­ly, it’s primarily the users who benefit from the interface con­nec­tions: APIs enable them to combine a wide range of programs with ease and enjoy greater con­ve­nience.

Example: APIs and SDKs for Google Maps

Google Maps is a well-known service for in­te­grat­ing APIs. The popular online maps were released in February 2005 and have since been part of everyday life for many people – on desktop computers and smart­phone apps.

On the Google Maps platform, de­vel­op­ers can find SDKs (software de­vel­op­ment kits) and APIs to integrate with their own apps, programs and websites. This allows the functions of Google Maps to be quickly and easily in­te­grat­ed into other ap­pli­ca­tions. With the Maps JavaScript API, for example, website owners can con­ve­nient­ly insert in­ter­ac­tive maps. This is es­pe­cial­ly useful for shops or restau­rants whose business success often depends on whether customers are easily able to find and visit their premises.

The example also shows how such an interface is paid for in practice. Access runs through a project with a key of its own, and Google bills usage by the number of map loads and other requests, not by the number of de­vel­op­ers or visitors involved. Anyone building a service on an external API should therefore look at the expected volume of calls first.

Zxf1mnP5zcw.jpg To display this video, third-party cookies are required. You can access and change your cookie settings here.

How to test APIs?

When in­te­grat­ing ap­pli­ca­tion pro­gram­ming in­ter­faces into programs or ap­pli­ca­tions, it’s important to first test them to make sure every­thing works as intended and the APIs don’t take too long to access in­for­ma­tion. De­vel­op­ers who write their own APIs should also test them first. For­tu­nate­ly, it’s now rel­a­tive­ly easy to test APIs – not least thanks to ap­pli­ca­tions like Postman or curl.

Postman makes it possible to test API access defined by the user. De­vel­op­ers can import and try out their API spec­i­fi­ca­tions. Postman also offers schematic support for formats like OpenAPI, AsyncAPI, RAML and GraphQL. APIs can be tested both in their initial stages and in their final state. The pricing structure of Postman varies depending on the scope of re­quire­ments. There is also a free plan. A single developer can design and test APIs with the Solo plan for $9 per user per month, while teams are served by the Team plan at $19 per user per month, each billed annually. An En­ter­prise plan with custom pricing is available on request.

curl is a command-line tool for testing APIs. It requires a good un­der­stand­ing of command-line functions. It’s not as con­ve­nient as Postman and doesn’t offer a graphical user interface. But curl is free of charge. The documents on various topics can be viewed on the curl project page.

Postman curl
A free plan is available; paid plans start at $9 per user per month. Free, open-source
Platform-based Command-line tool
Postman allows APIs to be tested in detail curl is used more fre­quent­ly for quickly viewing HTTP headers
Web hosting
Get your site online fast without breaking the bank
  • Fast page loads while cutting costs by 60%
  • Keep your site open 24/7 with 99.99% uptime
  • Never run out of space with unlimited storage

Reviewer

Go to Main Menu