API

Application programming interface

An API is a set of rules that lets one piece of software ask another piece of software to do something, without a person clicking anything.

Checked 27/11/2026 against 2 sources. Next review 27/05/2027.

An API (application programming interface) is a set of features and rules inside a software program that lets other software interact with it, instead of a human using a screen [1]. MDN describes it as a simple contract between the program offering it and other software or hardware [1]. On a website, the caller is usually your page or your server, and the other side is a service such as a payment provider, a map or a CRM. The caller sends a request to a URL and gets a reply, often as JSON [2].

What does an API do on a normal business website?

It lets your site use a service you did not build. MDN's examples include code that reads a visitor's webcam and code that talks to third-party websites and services [1]. A shop that does not build its own card processing can call the API of a payment gateway and hand over the order.

Stripe describes its API as built around predictable, resource-oriented URLs, form-encoded request bodies and JSON replies, with standard HTTP response codes, authentication and verbs [2].

How does a booking form take a payment through an API?

The visitor never sees the API. They fill in a name, a date and a card, and press Book. Behind that button your server makes a request to the payment provider.

  1. The form sends the booking to your server Your server saves the date and the customer details.
  2. Your server calls the payment API It sends the amount and currency, along with your secret API key, which Stripe uses to authenticate the request [2].
  3. The provider replies The reply says whether the payment went through. Your server reads it and shows a confirmation or an error.
  4. Your server updates the booking If the payment worked, the slot is marked as paid. If not, it stays open.
curl https://api.stripe.com/v1/payment_intents \
  -u sk_test_yourkey: \
  -d amount=5000 \
  -d currency=sgd

That request creates a payment for 5000 in the sgd currency. The key goes in the request so the provider knows which account it belongs to [2].

Why must the API key stay on my server?

Stripe's docs say requests are authenticated with your API key, and that calls made over plain HTTP fail [2]. They also say not to embed secret or restricted API keys in source code or client-side applications, and to keep them in your server platform's secrets vault instead [2]. Page code is visible to every visitor, so a key placed there is exposed. Send requests over HTTPS.

What does a failed API call look like?

The reply carries an HTTP status code. Stripe says its API uses standard HTTP response codes [2]. See HTTP status codes for what each class means. When the other service is slow or down, your page should show a clear message and let the customer try again, rather than a blank screen.

If you want the other service to contact you instead of waiting for your request, that is a webhook.

Questions people ask

Is an API the same as a website?

No. A website is made for a person to read. An API is made for software to call [1], and Stripe's replies are JSON rather than a designed page [2].

Do I need an API for my small business website?

Only if the site must talk to another service, such as taking card payments, syncing orders to accounting or showing live availability. A simple brochure site does not.

Is an API key the same as a password?

It plays a similar role. Stripe uses the key to authenticate each request, and requests without authentication fail [2]. Treat a secret key like a password and keep it out of your page code.

See also

  • Webhook A webhook is a message that one service sends to a URL on your server the moment something happens, so you do not have to keep asking.
  • HTTP status codes HTTP status codes are three-digit numbers a server sends back with every page or file to say whether the request worked.
  • Payment gateway A payment gateway is the tool that lets a business safely accept payments online, passing the customer's details to the bank side for approval.
  • Stripe Stripe is an online payments company whose platform lets a business take card and other payments on a website or app and receive the money in its bank account.
  • HTTPS HTTPS is the secure version of HTTP, the language browsers and websites speak, with everything sent between them encrypted.
  • CRM A CRM is software that keeps a business's customer and prospect details, enquiries and follow-ups in one shared place.

References

  1. API (Glossary), MDN Web Docs. Read 27/11/2026.An API (Application Programming Interface) is a set of features and rules that exist inside a software program (the application) enabling interaction with it through software
  2. API Reference, Stripe Docs. Read 27/11/2026.Our API has predictable resource-oriented URLs, accepts form-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes, authentication, and verbs.