Estimated Time: 1.5 hours

<aside> ❗ Welcome to CodeLab's article on HTML & CSS. Here, you'll learn the basics of how APIs work, and how to call them - both with and without writing code.

As always, you can follow along with the source code here.

</aside>

Prerequisites

Setting Up Your Development Environment

JavaScript

Overview

What is an API?

An API (or Application Programming Interface) is a connection between two computer programs over the web to translate information between them - a vital tool to send and retrieve data in software development.

APIs

Intro to APIs

An API is, ultimately, a way to share and communicate data across software programs. For instance, if my program needs to use your program's function that calculates the 7-day weather average in a given year, how am I to do it if I don't have access to your source code or a library that I can import? This is where APIs come in - I can use one to easily trigger that function and then receive a response that it returns over the web!

API Architecture

It's worth noting that there are many different types of APIs - that is, the rules they're built by, their general programming guidelines, how they format their data, etc. We'll be focusing primarily on REST APIs. Other common ones you might have heard of include Webhooks, Websockets, or SOAP, but no need to worry about those here.

Components of a RESTful API Request

There's a lot of information that you need to know before you can just make an API request - here are some of the most simple pieces broken down. Note that this is the information you use when trying to talk to some person's API to get data from them - without supplying these certain pieces of data, your request might be rejected as invalid!