9 Free APIs Every Developer Should Be Using Right Now (With Real Code Examples)

Contents show
9 Free APIs Every Developer Should Be Using Right Now (With Real Code Examples)
9 Free APIs Every Developer Should Be Using Right Now (With Real Code Examples)

9 Free APIs Every Developer Should Be Using Right Now (With Real Code Examples)

There's a specific moment most developers remember — the one where their project stopped feeling like homework and started feeling like something real.

For a lot of people, that moment happens the first time they connect their code to a live API.

Suddenly your app isn't just moving fake data around in a loop. It's pulling real weather conditions from a city halfway across the world. It's generating quotes that could actually inspire someone. It's showing dog pictures that people will genuinely laugh at. That feeling — of your code reaching out and touching something bigger than itself — is hard to replicate with todo apps and calculator clones.

The good news? You don't need a credit card, a startup budget, or weeks of setup time to get there. The APIs in this list are completely free to start with, and most of them work right out of the box without even needing an account.

Whether you're building your first portfolio project, learning how fetch() works, or just tired of making the same beginner apps over and over, this list will give you a direct path to projects that actually feel worth showing people.

Let's get into it.


What Even Is an API? (Quick Refresher)

Before jumping in, let's get this out of the way quickly.

An API, or Application Programming Interface, is basically a way for two pieces of software to talk to each other. When your app wants to get weather data, it sends a request to a weather service's API. That service processes the request and sends back the information in a structured format, usually JSON.

Think of it like ordering at a restaurant. You don't go into the kitchen and make the food yourself. You tell the waiter what you want (your request), and the kitchen sends back exactly what you ordered (the response). The menu is the documentation. The waiter is the API.

There are a few types of APIs you'll run into, but the most common for beginners is a REST API. These work over HTTP (the same protocol your browser uses to load web pages), and they follow a predictable pattern. You send a GET request to retrieve data, a POST request to create something new, PUT or PATCH to update, and DELETE to remove. Most of the APIs in this list are REST APIs.

The data they return is almost always JSON, which stands for JavaScript Object Notation. If you've used JavaScript objects before, JSON will feel familiar. It's just key-value pairs, nested objects, and arrays, structured in a way both humans and machines can read.

That's it. You don't need to understand every technical detail to start using APIs. You just need to know how to read the documentation and write a fetch() call.

Now, here are 9 of the best free ones to try.


1. JSONPlaceholder: The Training Wheels You Actually Want

URL: https://jsonplaceholder.typicode.com/

If you've ever tried to learn how to work with APIs and immediately ran into CORS errors, 401 Unauthorized responses, or complicated OAuth flows, JSONPlaceholder is going to feel like a breath of fresh air.

This is a fake REST API that exists purely for testing and learning. It has pretend data for posts, users, comments, todos, photos, and albums. None of it is real, but all of it looks realistic enough to build actual UIs with.

There are no API keys. No rate limits. No account creation. You just make a request and get clean, structured JSON back.

Why It's Worth Your Time

The reason developers keep coming back to JSONPlaceholder even after they've learned the basics is that it's genuinely useful for prototyping. If you're building a new component and just need some data to display while you're working on the layout, this is your go-to.

It also supports simulated writes. You can POST, PUT, PATCH, and DELETE, and it'll return a valid response as if the operation worked, even though nothing actually gets saved. That makes it perfect for practicing full CRUD operations without needing a real backend.

Code Example

// Fetch a list of posts
async function getPosts() {
  const response = await fetch('https://jsonplaceholder.typicode.com/posts');
  const posts = await response.json();

  posts.slice(0, 5).forEach(post => {
    console.log(`Title: ${post.title}`);
    console.log(`Body: ${post.body}`);
    console.log('---');
  });
}

getPosts();
// Create a new post (simulated)
async function createPost() {
  const response = await fetch('https://jsonplaceholder.typicode.com/posts', {
    method: 'POST',
    headers: { 'Content-Type': 'application/json' },
    body: JSON.stringify({
      title: 'My First API Post',
      body: 'This is the content of the post',
      userId: 1
    })
  });
  const newPost = await response.json();
  console.log('Created:', newPost);
}

createPost();

What to Build With It

Build a blog UI that renders posts from the API. Build a user profile page that pulls from /users/1. Create a comment section that loads from /posts/1/comments. None of these will look fake to someone scrolling through your portfolio.


2. Open-Meteo: Live Weather Without Paying For It

URL: https://open-meteo.com/

Most weather APIs charge money once you go past a few requests a day. Open-Meteo gives you completely free weather data, no API key required, and it's genuinely accurate.

You pass in a latitude and longitude, specify which weather variables you want (temperature, wind speed, precipitation, humidity, etc.), and it returns an hourly or daily forecast. It even supports historical weather data going back decades.

For developers learning to work with APIs, this is perfect because the query parameters make for great practice. You're not just calling a URL with no options, you're constructing a proper request with multiple parameters, which is how most real-world APIs actually work.

Code Example

// Get current weather for New York City
async function getWeather(latitude, longitude) {
  const url = `https://api.open-meteo.com/v1/forecast?latitude=${latitude}&longitude=${longitude}¤t_weather=true&hourly=temperature_2m,precipitation`;

  const response = await fetch(url);
  const data = await response.json();

  const current = data.current_weather;
  console.log(`Temperature: ${current.temperature}°C`);
  console.log(`Wind Speed: ${current.windspeed} km/h`);
  console.log(`Weather Code: ${current.weathercode}`);
}

// New York City coordinates
getWeather(40.7128, -74.0060);

What to Build With It

A weather dashboard with a search feature where users type in a city name (combine it with a geocoding API to convert the city name to coordinates). A “should I bring an umbrella?” app that checks precipitation chances for the next 12 hours. A historical weather lookup tool.


3. The Dog API: Absurdly Fun, Surprisingly Useful

URL: https://dog.ceo/dog-api/

Don't let the name fool you into thinking this is a toy. The Dog API is one of the cleanest, most well-structured public APIs available, which makes it a genuinely great tool for learning. It has over 20,000 dog images organized by breed and sub-breed.

You can fetch a random dog image with no setup at all. You can also filter by breed, get a list of all available breeds, or request a specific number of random images at once.

It requires no authentication for basic use, returns clean JSON every time, and handles errors predictably. That last point matters more than people realize when you're learning.

Code Example

// Get a random dog image
async function getRandomDog() {
  const response = await fetch('https://dog.ceo/api/breeds/image/random');
  const data = await response.json();
  console.log('Dog image URL:', data.message);
}

// Get multiple random images of a specific breed
async function getBreedImages(breed, count = 3) {
  const response = await fetch(`https://dog.ceo/api/breed/${breed}/images/random/${count}`);
  const data = await response.json();

  data.message.forEach((url, index) => {
    console.log(`Image ${index + 1}: ${url}`);
  });
}

getRandomDog();
getBreedImages('labrador', 5);

What to Build With It

An image gallery that loads random dog photos. A breed explorer where users can click on a breed name and see photos. A “random dog of the day” widget you can embed in other projects. Add a CSS animation and it becomes a genuinely fun thing to drop into any portfolio.


4. Open Library API: Books, Authors, and Cover Art

URL: https://openlibrary.org/developers/api

The Internet Archive's Open Library has digitized millions of books and made the metadata available through a free, public API. You can search for books by title or author, look up specific editions by ISBN, pull cover images, and access author pages, all without signing up for anything.

This one is particularly valuable for developers interested in building anything in the reading, education, or content space. The data is rich and extensive, and the documentation is solid.

Code Example

// Search for books by title
async function searchBooks(query) {
  const encoded = encodeURIComponent(query);
  const response = await fetch(`https://openlibrary.org/search.json?title=${encoded}&limit=5`);
  const data = await response.json();

  data.docs.forEach(book => {
    console.log(`Title: ${book.title}`);
    console.log(`Author: ${book.author_name ? book.author_name[0] : 'Unknown'}`);
    console.log(`First Published: ${book.first_publish_year || 'N/A'}`);
    if (book.cover_i) {
      console.log(`Cover: https://covers.openlibrary.org/b/id/${book.cover_i}-M.jpg`);
    }
    console.log('---');
  });
}

// Look up a book by ISBN
async function getBookByISBN(isbn) {
  const response = await fetch(`https://openlibrary.org/isbn/${isbn}.json`);
  const data = await response.json();
  console.log('Book data:', data);
}

searchBooks('The Great Gatsby');

What to Build With It

A reading list app where users can search for books and save them. A “book of the day” widget. A simple bookshelf UI that displays covers fetched from the API. If you combine this with local storage, you suddenly have something that looks like a real product.


5. REST Countries: Geography Data for Every Country on Earth

URL: https://restcountries.com/

REST Countries gives you detailed data for every country in the world: official names, capital cities, populations, currencies, languages, flags, time zones, bordering countries, and more. All of it is free, and none of it requires authentication.

What makes this API great for learning is that the responses are complex enough to practice real data parsing. Each country object has dozens of fields, many of which are nested objects or arrays. Working through that teaches you skills that translate directly to real-world API work.

Code Example

// Get data for a specific country
async function getCountry(name) {
  const response = await fetch(`https://restcountries.com/v3.1/name/${name}`);
  const data = await response.json();
  const country = data[0];

  console.log(`Country: ${country.name.common}`);
  console.log(`Capital: ${country.capital ? country.capital[0] : 'N/A'}`);
  console.log(`Population: ${country.population.toLocaleString()}`);
  console.log(`Region: ${country.region}`);
  console.log(`Flag: ${country.flags.png}`);

  const currencies = Object.values(country.currencies || {});
  if (currencies.length > 0) {
    console.log(`Currency: ${currencies[0].name} (${currencies[0].symbol})`);
  }
}

// Get all countries in a region
async function getCountriesByRegion(region) {
  const response = await fetch(`https://restcountries.com/v3.1/region/${region}`);
  const data = await response.json();
  console.log(`Found ${data.length} countries in ${region}`);
  data.slice(0, 5).forEach(c => console.log(` - ${c.name.common}`));
}

getCountry('Japan');
getCountriesByRegion('Europe');

What to Build With It

A country explorer app with a search bar. A geography quiz where users guess capitals or flags. A “compare two countries” feature showing population and area side by side. The flag data alone makes the UI immediately more interesting.


6. Quotable API: Instant Quotes From Real People

URL: https://quotable.kurokeita.dev/

A simple but endlessly useful API. Quotable serves up quotes from thousands of authors across history, philosophy, literature, science, and culture. You can fetch a single random quote, filter by author or tag, and search for quotes containing specific keywords.

This is a great one to start with if you're brand new to APIs because the responses are small and easy to understand. There's no complex nesting to work through, which means you can focus entirely on understanding the fetch workflow.

Code Example

// Get a random quote
async function getRandomQuote() {
  const response = await fetch('https://quotable.kurokeita.dev/api/quotes/random');
  const data = await response.json();
  const quote = data.quote;

  console.log(`"${quote.content}"`);
  console.log(`— ${quote.author}`);
}

// Get quotes by a specific author
async function getQuotesByAuthor(author) {
  const encoded = encodeURIComponent(author);
  const response = await fetch(`https://quotable.kurokeita.dev/api/quotes?author=${encoded}&limit=3`);
  const data = await response.json();

  data.quotes.forEach(q => {
    console.log(`"${q.content}"`);
    console.log(`— ${q.author}`);
    console.log('---');
  });
}

getRandomQuote();
getQuotesByAuthor('Marcus Aurelius');

What to Build With It

A quote-of-the-day app. A “random wisdom” button that people keep clicking. A themed quote generator where users pick a category (motivational, philosophical, literary) and get a curated result. These are small projects but they're genuinely shareable things to post online.


7. NASA APIs: Real Space Data, Completely Free

URL: https://api.nasa.gov/

NASA offers a collection of free public APIs that give you access to their image archives, Mars Rover photo collections, near-Earth asteroid data, and their famous Astronomy Picture of the Day (APOD) feed. You need a free API key, but signing up takes 30 seconds and the key arrives instantly.

The APOD endpoint alone is worth it. Every day NASA posts an image or video from space along with a professional explanation written by an astronomer. You can pull the current day's picture or request any date going back to June 1995. That's nearly 30 years of daily space images available through a single API call.

Code Example

// Get today's Astronomy Picture of the Day
const NASA_API_KEY = 'DEMO_KEY'; // Replace with your free key from api.nasa.gov

async function getAPOD(date = null) {
  let url = `https://api.nasa.gov/planetary/apod?api_key=${NASA_API_KEY}`;
  if (date) url += `&date=${date}`;

  const response = await fetch(url);
  const data = await response.json();

  console.log(`Title: ${data.title}`);
  console.log(`Date: ${data.date}`);
  console.log(`Explanation: ${data.explanation.slice(0, 200)}...`);
  console.log(`Image URL: ${data.url}`);
}

// Get Mars Rover photos
async function getMarsPhotos(sol = 1000) {
  const url = `https://api.nasa.gov/mars-photos/api/v1/rovers/curiosity/photos?sol=${sol}&api_key=${NASA_API_KEY}&page=1`;
  const response = await fetch(url);
  const data = await response.json();

  console.log(`Photos taken on Mars Sol ${sol}: ${data.photos.length}`);
  if (data.photos.length > 0) {
    console.log(`First photo: ${data.photos[0].img_src}`);
    console.log(`Camera: ${data.photos[0].camera.full_name}`);
  }
}

getAPOD();
getAPOD('2020-04-20'); // Get a specific date
getMarsPhotos(500);

What to Build With It

An APOD viewer with a date picker so users can browse through decades of space photography. A Mars photo gallery organized by camera or rover. An “on this day in space” feature that shows what image was posted on the user's birthday. These are portfolio pieces that genuinely impress people outside the developer world too.


8. The Cocktail DB: Drink Recipes and Ingredient Data

URL: https://www.thecocktaildb.com/api.php

TheCocktailDB has a free API that gives you access to hundreds of cocktail and mocktail recipes, including ingredient lists, measurements, glass types, and photos. You can search by drink name, filter by category or ingredient, look up a random drink, and even filter for non-alcoholic options.

What makes this one worth highlighting is that it's perfect for building a “recipe app” style project. The data structure is a little quirky (ingredients are stored as strIngredient1, strIngredient2, etc., rather than in an array), which means you actually have to think a bit about how to process the response. That's a valuable real-world skill.

Code Example

// Search for cocktails by name
async function searchCocktails(name) {
  const response = await fetch(`https://www.thecocktaildb.com/api/json/v1/1/search.php?s=${encodeURIComponent(name)}`);
  const data = await response.json();

  if (!data.drinks) {
    console.log('No drinks found');
    return;
  }

  data.drinks.slice(0, 3).forEach(drink => {
    console.log(`Name: ${drink.strDrink}`);
    console.log(`Category: ${drink.strCategory}`);
    console.log(`Glass: ${drink.strGlass}`);
    console.log(`Thumbnail: ${drink.strDrinkThumb}`);

    // Extract ingredients (API stores them as strIngredient1, strIngredient2, etc.)
    const ingredients = [];
    for (let i = 1; i <= 15; i++) {
      if (drink[`strIngredient${i}`]) {
        ingredients.push(`${drink[`strMeasure${i}`] || ''} ${drink[`strIngredient${i}`]}`.trim());
      }
    }
    console.log(`Ingredients: ${ingredients.join(', ')}`);
    console.log('---');
  });
}

// Get a random cocktail
async function getRandomCocktail() {
  const response = await fetch('https://www.thecocktaildb.com/api/json/v1/1/random.php');
  const data = await response.json();
  const drink = data.drinks[0];
  console.log(`Random Drink: ${drink.strDrink}`);
  console.log(`Instructions: ${drink.strInstructions}`);
}

searchCocktails('margarita');
getRandomCocktail();

What to Build With It

A drink recipe finder app. A “random cocktail of the evening” page with a shuffle button. A mocktail-only filter for people who don't drink alcohol. Combine it with a favorites list using local storage and you have a full, functional app.


9. ExchangeRate-API: Live Currency Conversion

URL: https://www.exchangerate-api.com/

Currency conversion is one of those things that sounds simple but requires real-time data to be accurate. ExchangeRate-API gives you free access to current exchange rates for 160+ currencies. Their free tier allows 1,500 requests per month, which is plenty for learning and small projects.

You do need to create a free account to get an API key, but the process takes under two minutes. Once you have your key, you can convert any currency pair, get a full rate table for any base currency, and track historical changes.

Code Example

const EXCHANGE_API_KEY = 'YOUR_FREE_API_KEY'; // from exchangerate-api.com

// Get current rates for a base currency
async function getExchangeRates(baseCurrency = 'USD') {
  const response = await fetch(`https://v6.exchangerate-api.com/v6/${EXCHANGE_API_KEY}/latest/${baseCurrency}`);
  const data = await response.json();

  if (data.result === 'success') {
    console.log(`Base: ${data.base_code}`);
    console.log(`Last Updated: ${data.time_last_update_utc}`);
    console.log(`EUR: ${data.conversion_rates.EUR}`);
    console.log(`GBP: ${data.conversion_rates.GBP}`);
    console.log(`JPY: ${data.conversion_rates.JPY}`);
    console.log(`NGN: ${data.conversion_rates.NGN}`);
  }
}

// Convert a specific amount between two currencies
async function convertCurrency(amount, from, to) {
  const response = await fetch(`https://v6.exchangerate-api.com/v6/${EXCHANGE_API_KEY}/pair/${from}/${to}/${amount}`);
  const data = await response.json();

  if (data.result === 'success') {
    console.log(`${amount} ${from} = ${data.conversion_result.toFixed(2)} ${to}`);
    console.log(`Rate: 1 ${from} = ${data.conversion_rate} ${to}`);
  }
}

getExchangeRates('USD');
convertCurrency(100, 'USD', 'EUR');
convertCurrency(50, 'GBP', 'NGN');

What to Build With It

A currency converter app with a clean UI. A travel budget calculator that converts expenses in real time. A multi-currency pricing widget for anyone building a commerce-related project. Add some clean styling with Tailwind CSS and you have something portfolio-worthy in an afternoon.


A Quick Glance: All 9 APIs at a Glance

Before going deeper, here's a fast summary of everything covered:

APIWhat It DoesAuth Needed?Best For
JSONPlaceholderFake REST API for practiceNoLearning fetch and CRUD
Open-MeteoLive weather forecastsNoWeather apps and dashboards
The Dog APIDog images by breedNoFun UI projects, image galleries
Open LibraryBook search and cover imagesNoReading apps, education tools
REST CountriesCountry data, flags, statsNoGeography apps, data visualization
QuotableQuotes by author and categoryNoWidgets, motivation apps
NASA APIsSpace photos, Mars rover imagesFree keyPortfolio standouts, APOD viewers
TheCocktailDBCocktail and mocktail recipesNoRecipe apps, filtering practice
ExchangeRate-APILive currency conversionFree keyFinance tools, travel apps

Nine APIs. Nine completely different types of data. And with basic JavaScript, you can build something real with every single one.


How to Actually Learn From These APIs

Having 9 APIs listed out is great, but the real value comes from how you approach using them. Here are a few ways to get the most out of each one.

Start With a Simple Fetch Before Building Anything

Open your browser console or a CodePen, make a raw fetch call, and just look at the response. Print the whole JSON object. Explore the structure. Figure out which fields you actually want before you write any UI code.

This step takes 5 minutes and saves you 45 minutes of debugging later.

Most beginners skip this and jump straight into building the UI, then wonder why their data.title keeps coming back as undefined. Get comfortable with the raw response first. Know exactly what structure you're working with before you try to display anything.

Build One Small Thing Per API

Don't try to combine 4 APIs into one mega-project right away. Pick one API, build the smallest possible working thing that displays real data, and then expand it. A single-page dog photo viewer is a complete, working project. A full pet matching app combining 6 APIs is a half-finished mess.

Small wins compound. Every time you successfully get data from a new API and display it on screen, your confidence and understanding grow in a real way.

Handle Errors Like a Real Developer

Almost nobody shows you how to handle API errors properly in beginner tutorials, but it matters. Add loading states. Handle the case where the API returns no results. Tell the user when something went wrong. That kind of polish is exactly what separates projects that look amateur from ones that look professional.

async function safeApiCall(url) {
  try {
    const response = await fetch(url);

    if (!response.ok) {
      throw new Error(`API error: ${response.status} ${response.statusText}`);
    }

    const data = await response.json();
    return data;

  } catch (error) {
    console.error('Something went wrong:', error.message);
    return null;
  }
}

This pattern alone will make your projects feel significantly more professional. When an API call fails, your app shouldn't just silently break or crash. Showing a friendly error message or a fallback state is something real products do, and it's something you can start doing right now.

Learn to Read the Documentation

Every API in this list has documentation. Reading it for 15 minutes before you start coding will save you hours. You'll discover query parameters, rate limits, and response formats you didn't know existed. The documentation is the map. Don't try to navigate without it.

A quick tip for reading API docs: skip to the “examples” section first. Most good documentation shows you a sample URL and a sample response. Just seeing that concrete example tells you most of what you need to know in about 30 seconds.

Start Using Environment Variables for API Keys

A few of the APIs in this list require a free API key. Get into the habit of storing those keys in environment variables rather than writing them directly into your code. If you ever push your code to GitHub with a key hardcoded in it, you'll need to revoke that key and generate a new one, which is an annoying process to go through.

In a Node.js project, you can use a .env file with the dotenv package:

// .env file (never commit this to Git)
NASA_API_KEY=your_key_here
EXCHANGE_API_KEY=your_other_key_here

// In your code
require('dotenv').config();
const nasaKey = process.env.NASA_API_KEY;

It's a small habit to pick up early, and it'll keep your keys safe and your code clean.


Putting It All Together

Here's something worth sitting with for a moment.

Every major web application you've ever used, Spotify, Twitter, Google Maps, any banking app, is just code that makes API calls and displays the results in a thoughtful way. The complexity is in the scale and the UX, not in some secret technique you don't have access to yet.

The gap between where you are now and building something that feels real is smaller than you think. It's mostly a matter of picking up the right tools and practicing with them until they feel natural.

What a Real Portfolio Project Looks Like

Here's a concrete example. Say you take the Open-Meteo API and the REST Countries API and combine them into a simple app that lets users pick a country and see its current weather alongside facts like population, capital, and flag. That's two API calls. Maybe 100 lines of JavaScript and some HTML. But the end result looks like an actual product, because it is one.

Add a clean design with Tailwind CSS. Write a brief README that explains what it does and how you built it. Push it to GitHub. That's a portfolio piece. That's something you can walk through in a job interview.

Nobody is expecting you to build Netflix. They're expecting you to show that you can learn new tools, read documentation, and put something working together. These APIs let you demonstrate all three.

The Compounding Effect of Building Small Things

One thing that doesn't get talked about enough in developer education is the compounding effect of small projects. Every time you build something with an API, you get a little faster. The fetch pattern becomes muscle memory. You stop having to look up how to parse JSON. You start recognizing common error patterns before they trip you up.

After building five small projects, you're not five times better than when you started. You're probably ten times faster and dramatically more confident, because each project taught you something the previous one didn't.

The nine APIs in this list could easily fuel 20 different projects at various levels of complexity. There's no shortage of things to build. The only variable is whether you start.

These Are Starting Points, Not Finish Lines

Each of the APIs in this list has more depth than what's been shown here. JSONPlaceholder has additional endpoints. Open-Meteo has historical weather data going back 80 years. The NASA API has endpoints for near-Earth asteroids and satellite imagery. ExchangeRate-API has historical rate tracking.

As you get comfortable with the basics, go back and dig deeper into whichever ones you found most interesting. Read through more of the documentation. Try to use a feature you haven't touched yet. The more familiar these tools become, the more creative you can get with what you build.

Pick one. Make a fetch call. See what comes back.

That moment of seeing live data appear in your console for the first time is one of those small but genuinely memorable experiences in a developer's life. Once you feel it, you'll want to keep chasing it, and that curiosity is what drives people to get good at this stuff over time.

You've got everything you need to start right now.

MORE POSTS:

9 Free APIs That Will Make Your Projects Feel Like Real Software (With Code You Can Use Today)
Subscription Form