How to Use an API: A Complete Beginner's Guide

Never used an API before? This guide walks you through everything step by step — from your first browser request to writing code in JavaScript and Python.

1. What is an API?

An API (Application Programming Interface) lets your code talk to another service over the internet. You send a request to a URL, and the server sends back data (usually in JSON format).

For example, a weather API lets you ask "What's the temperature in Tokyo?" and get back a structured answer that your program can use.

2. What You Need

Web Browser

Chrome, Firefox, Safari, or Edge. You already have this.

Terminal / Command Line

Mac: Terminal.app (built-in)
Windows: PowerShell (built-in)
Linux: Terminal (built-in)

Code Editor (Optional)

VS Code (free) is recommended for writing .js or .py files.

3. Try it in Your Browser

The simplest way to call an API is to paste its URL into your browser's address bar. Try this right now:

https://theaxolotlapi.netlify.app/

You should see JSON data appear in your browser. That's it — you just made your first API call!

4. Using curl (Terminal / Command Line)

curl is a command-line tool for making HTTP requests. It comes pre-installed on Mac and Linux. On Windows, PowerShell has it built-in too.

Mac / Linux

Open Terminal and run:

curl https://theaxolotlapi.netlify.app/

Windows (PowerShell)

Open PowerShell and run:

curl.exe https://theaxolotlapi.netlify.app/

Or using PowerShell's native command:

Invoke-WebRequest -Uri "https://theaxolotlapi.netlify.app/" | Select-Object -ExpandProperty Content

5. Using JavaScript (Node.js)

Install Node.js

Mac: brew install node (or download from nodejs.org)

Windows: Download installer from nodejs.org

Linux: sudo apt install nodejs (Ubuntu/Debian)

Quick One-Liner

node -e "fetch('https://theaxolotlapi.netlify.app/').then(r=>r.json()).then(d=>console.log(JSON.stringify(d,null,2)))"

As a File (app.js)

const url = "https://theaxolotlapi.netlify.app/";
const response = await fetch(url);
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data);

Save as app.js and run: node app.js

6. Using Python

Install Python

Mac: brew install python (or download from python.org)

Windows: Download from python.org (check "Add to PATH")

Linux: sudo apt install python3 python3-pip

Install requests library

pip install requests

Quick One-Liner

python -c "import requests; print(requests.get('https://theaxolotlapi.netlify.app/').json())"

As a File (app.py)

import requests

url = "https://theaxolotlapi.netlify.app/"
headers = {}

response = requests.get(url, headers=headers, timeout=30)
response.raise_for_status()
data = response.json()
print(data)

Save as app.py and run: python app.py

7. When an API Key is Required

Many APIs require an API key to identify you. Here is how to use one:

  1. Sign up on the API provider's website
  2. Find the "API Keys" or "Developer" section in your dashboard
  3. Copy your API key
  4. Add it to your request header or URL

Example: curl with API key in header

curl -H "X-API-Key: YOUR_API_KEY" https://api.example.com/data

Example: curl with API key in URL

curl "https://api.example.com/data?api_key=YOUR_API_KEY"

For a deeper dive, read our Authentication Guide.

8. Next Steps

Frequently Asked Questions

What is an API?

An API (Application Programming Interface) is a way for two programs to communicate. When you call an API, you send a request to a server and get structured data (usually JSON) back. Think of it like ordering from a menu at a restaurant: you ask for something specific, and the kitchen (server) prepares and delivers it.

Do I need to know how to code to use an API?

Not necessarily! You can test most APIs directly in your web browser or using a tool like curl from the command line. However, to integrate an API into an application, basic knowledge of JavaScript or Python is helpful.

How do I call an API?

The simplest way is to open a URL in your browser (for GET requests with no authentication). For more control, use curl in your terminal, or write a few lines of JavaScript (fetch) or Python (requests). Our Getting Started guide walks through each method step by step.

Are public APIs free?

Many are! Our directory includes hundreds of APIs that require no authentication and are free to use. Browse our beginner-friendly list to find them.