What is an API?

An API lets different programs talk to each other and share data. Here we explain how it works, which types exist, and why APIs matter for websites, online shops and businesses.
Technical article

An API, or Application Programming Interface, is a set of rules that lets different programs talk to each other and share data. The API decides what one system can ask another for, and what answer it gets back.

How an API works

Think of an API as a waiter in a restaurant. You order from the menu, the waiter takes the order to the kitchen and comes back with the food. You do not need to know how the kitchen works. In the same way, an app sends a request to an API, the system behind it does the job, and the API sends the answer back in a fixed format, usually JSON.

A call to an API usually consists of an address (an endpoint), an action such as fetching, creating, changing or deleting data, and often a key that shows you are allowed to ask.

Examples you use every day

  • Payment. When you pay with Vipps or a card in an online shop, the shop talks to the payment provider through an API.
  • Maps. The map on a contact page is fetched from a map service through an API.
  • Login. "Sign in with Google" or BankID uses an API to confirm who you are.
  • Shipping. Online shops fetch prices and tracking from Posten and Bring through APIs.
  • Weather. The weather app on your phone fetches the forecast from a weather API, for example from the Norwegian Meteorological Institute.

Different types of API

Most APIs on the web today are REST APIs, which use ordinary web addresses and HTTP. GraphQL lets you ask for exactly the fields you need in a single call. Webhooks turn it around. Instead of you asking, the system tells you by itself when something happens, for example when an order has been paid.

APIs can also be open, so anyone can use them, partner APIs that only selected parties can access, or internal APIs used only between a company's own systems.

Why APIs matter for businesses

APIs let your systems work together instead of separately. Orders from the online shop can go straight into the accounts, forms on the website can land in the CRM, and stock levels can update automatically. That saves manual work, gives fewer errors and makes it possible to build new services on top of what you already have.

A headless CMS is a good example. The content is stored in one place and sent through an API to the website, the app and other channels.

Things to consider

  • Security. API keys are like passwords and should never be visible in the website's code.
  • Documentation. A good API is well described, so developers know what they can ask for.
  • Limits. Many APIs limit how many calls you can make, and some charge per call.
  • Changes. The provider can change the API, so the integration must be maintained over time.

APIs and your website

Almost all modern websites and online shops fetch something from an API, whether it is payment, maps, forms or content. If you want to connect your website to the systems you use today, you can read about digital solutions at Cure or online shops.

Talk to Odd-Erik

Odd-Erik is happy to help you get your next project started.