A Collective List of Free Public APIs You Need to Know in 2024

cover
27 Jun 2024

As an experienced software developer, I'd like to share my insights on some of the free APIs you need to know about in 2024. Undeniably, APIs are essential tools that enable developers to integrate third-party services and enhance their applications with diverse functionalities.

Here, I categorize the APIs, making it convenient for developers to find the ones relevant to their projects.

So, without any further ado, let’s start !!!

Gaming APIs

Steam Community API:

This API provides an interface to Steam features such as user authentication, inventory management, and game data. It allows developers to integrate Steam's functionality into their applications.

Know More About Steam Community API Click Here

const fetch = require('node-fetch');
const steamApiKey = 'YOUR_STEAM_API_KEY';
const steamId = 'STEAM_USER_ID';
const url = http://api.steampowered.com/ISteamUser/GetPlayerSummaries/v0002/?key=${steamApiKey}&steamids=${steamId};
fetch(url)
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));

In this example, we're using the node-fetch module to make an API request to the Steam Community API. We need to replace 'YOUR_STEAM_API_KEY' with our actual Steam API key and 'STEAM_USER_ID' with the Steam ID of the user we want to retrieve information about. The API request URL is constructed dynamically using template literals. We then use fetch to make the request, handle the response, parse the JSON data, and log it to the console.

Riot Games API

Know More About Riot Games API Click Here

The Riot Games API provides access to data for popular games like:

  • League of Legends.
  • Teamfight Tactics, and
  • Valorant.

Developers can retrieve information on matches, rankings, champions, and other game-related statistics.

const fetch = require('node-fetch');
const riotApiKey = 'YOUR_RIOT_API_KEY';
const summonerName = 'SUMMONER_NAME';
const url = `https://na1.api.riotgames.com/lol/summoner/v4/summoners/by-name/${summonerName}?api_key=${riotApiKey}`;
fetch(url)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

Here, we're using the Riot Games API to retrieve information about a summoner (player) by their name. We need to replace 'YOUR_RIOT_API_KEY' with our actual Riot API key and 'SUMMONER_NAME' with the name of the summoner we want to look up. The API request URL is constructed using template literals, and we use fetch to make the request, handle the response, parse the JSON data, and log it to the console.

Language APIs:

Evil Insult Generator API:

A fun and lighthearted API, it generates random insults in various languages. While seemingly frivolous, it can be useful for testing or adding humorous elements to applications.

Know More About Riot Games API Click Here

const fetch = require('node-fetch');
const url = 'https://evilinsult.com/generate_insult.php?lang=en&type=json';
fetch(url)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

This example demonstrates a simple API request to the Evil Insult Generator API. We use node-fetch to fetch the URL, which includes the language parameter 'lang=en' and the response type 'type=json'. The API returns a random insult in JSON format, which we then parse and log to the console.

Fun Translations API

This API offers a unique twist to traditional translation by converting text into fun languages like Yoda, Shakespeare, or Minion speak. It adds a creative element to applications and can be used for entertainment or educational purposes.

Know More About Fun Translations API Click Here

const fetch = require('node-fetch');
const text = 'Hello, world!';
const url = `https://api.funtranslations.com/translate/yoda.json?text=${encodeURIComponent(text)}`;
fetch(url)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

Here, we're using the Fun Translations API to translate the text 'Hello, world!' into Yoda-speak. We encode the text using encodeURIComponent to ensure special characters are properly handled in the URL. The API request URL is constructed dynamically, and we use fetch to make the request, handle the response, parse the JSON data, and log it to the console.

Music APIs:

Spotify Web API

The Spotify Web API allows developers to access music data such as albums, artists, playlists, and user preferences. It also provides control over Spotify playback, enabling the creation of music-focused applications or the integration of music features into existing projects.

Know More About Spotify Web API Click Here

const fetch = require('node-fetch');
const accessToken = 'YOUR_SPOTIFY_ACCESS_TOKEN';
const url = 'https://api.spotify.com/v1/me/player/recently-played';
fetch(url, {
  headers: {
    'Authorization': `Bearer ${accessToken}`
  }
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

In this example, we're using the Spotify Web API to retrieve information about the user's recently played tracks. We need to replace 'YOUR_SPOTIFY_ACCESS_TOKEN' with our actual Spotify access token. The API request URL is specified, and we include an authorization header with the Bearer token. We use fetch to make the authenticated request, handle the response, parse the JSON data, and log it to the console.

Security APIs

Have I Been Pwned API

This API checks if an email or username has been compromised in a data breach. It provides valuable security information by alerting developers and users to vulnerabilities and helping them take preventive measures.

Know More About Have I Been Pwned API Click Here

const fetch = require('node-fetch');
const email = 'test@example.com';
const url = `https://haveibeenpwned.com/api/v2/breachedaccount/${email}`;
fetch(url, {
  headers: {
    'User-Agent': 'Node.js'
  }
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

Here, we're using the Have I Been Pwned API to check if an email address has been compromised in a data breach. We replace 'test@example.com' with the email address we want to check. The API request URL is constructed dynamically. We include a 'User-Agent' header to identify our application. We use fetch to make the request, handle the response, parse the JSON data, and log it to the console.

Shodan API

Shodan is a unique search engine for Internet-connected devices. Its API provides data on servers, devices, and systems worldwide, offering valuable insights for security research, network discovery, and device identification.

Know More About Shodan API Click Here

const fetch = require('node-fetch');
const shodanApiKey = 'YOUR_SHODAN_API_KEY';
const query = 'apache';
const url = `https://api.shodan.io/shodan/host/search?key=${shodanApiKey}&query=${query}`;
fetch(url)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

This example demonstrates a search using the Shodan API. We replace 'YOUR_SHODAN_API_KEY' with our actual Shodan API key. The API request URL is constructed dynamically, including the API key and the search query 'apache'. We use fetch to make the request, handle the response, parse the JSON data, and log it to the console.

Science & Math APIs

NASA API

NASA's API grants access to astronomical data, including astronomy photos, planetary information, and more. It empowers developers to create applications related to space exploration and scientific research.

Know More About NASA API Click Here

const fetch = require('node-fetch');
const nasaApiKey = 'YOUR_NASA_API_KEY';
const url = `https://api.nasa.gov/planetary/apod?api_key=${nasaApiKey}`;

fetch(url)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

Here, we're using the NASA API to retrieve the Astronomy Picture of the Day (APOD). We replace 'YOUR_NASA_API_KEY' with our actual NASA API key. The API request URL includes the API key. We use fetch to make the request, handle the response, parse the JSON data, and log it to the console.

Wolfram Alpha API

Wolfram Alpha is a renowned computational knowledge engine. Its API provides access to mathematical calculations, data analysis, and vast computational knowledge, making it a powerful tool for developers working on scientific or data-intensive projects.

Know More About Wolfram Alpha APIs Click Here

const fetch = require('node-fetch');
const wolframAppId = 'YOUR_WOLFRAM_APP_ID';
const query = 'integrate x^2';
const url = `http://api.wolframalpha.com/v2/query?input=${encodeURIComponent(query)}&appid=${wolframAppId}&output=json`;
fetch(url)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

In this example, we're using the Wolfram Alpha API to perform a mathematical calculation. We replace 'YOUR_WOLFRAM_APP_ID' with our actual Wolfram Alpha app ID. The API request URL includes the encoded query 'integrate x^2' and the app ID. We use fetch to make the request, handle the response, parse the JSON data, and log it to the console.

Sports APIs:

NBA API

The NBA API offers sports enthusiasts access to data on NBA teams, players, and games. It enables the creation of sports-related applications, fan engagement platforms, or statistical analysis tools.

Know More About NBA API Click Here

const fetch = require('node-fetch');
const url = 'https://api-nba-v1.p.rapidapi.com/teams/league/standard';
const options = {
  method: 'GET',
  headers: {
    'X-RapidAPI-Key': 'YOUR_RAPIDAPI_KEY',
    'X-RapidAPI-Host': 'api-nba-v1.p.rapidapi.com'
  }
};

fetch(url, options)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

In this example, we're using the NBA API to retrieve information about NBA teams. We need to replace 'YOUR_RAPIDAPI_KEY' with our actual RapidAPI key, which is used to authenticate and authorize the request. The API request URL is specified as 'https://api-nba-v1.p.rapidapi.com/teams/league/standard', which will provide us with standard information about NBA teams.

The options object is used to configure the request. We set the method to 'GET', indicating that we want to retrieve data from the specified URL. The headers object includes two headers:

  • 'X-RapidAPI-Key': This header contains our RapidAPI key, which is required for authentication and rate limiting.
  • 'X-RapidAPI-Host': This header specifies the host of the API endpoint, which is 'api-nba-v1.p.rapidapi.com' in this case.

We then use fetch (url, options) to make the API request. The fetch function takes the URL and the options object as arguments. It returns a Promise that resolves to the Response object representing the response to our request.

Once the response is received, we use .json() to parse the response body as JSON. The parsed data is then logged to the console using console.log(data). If there's an error during the request, we catch it using .catch() and log the error message to the console.

Web Apps APIs

Discord API

The Discord API allows developers to integrate their applications with the popular messaging platform. It enables user authentication, messaging, and more, making it ideal for creating community-focused features or gaming-related tools.

Know More About Discord API Click Here

features or gaming-related tools.


const fetch = require('node-fetch');
const discordToken = 'YOUR_DISCORD_BOT_TOKEN';
const url = 'https://discord.com/api/users/@me';
fetch(url, {
  headers: {
    'Authorization': `Bot ${discordToken}`
  }
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

In this example, we're using the Discord API to retrieve information about the authenticated bot user. We replace 'YOUR_DISCORD_BOT_TOKEN' with our actual Discord bot token, which is used for authentication. The API request URL is 'https://discord.com/api/users/@me', which represents the currently authenticated user.

We use fetch to make the request, and we include an Authorization header in the headers object. The header value is constructed as 'Bot YOUR_DISCORD_BOT_TOKEN', where 'YOUR_DISCORD_BOT_TOKEN' is replaced with the actual token. This header is required for Discord API requests to identify the bot.

Once the response is received, we parse the JSON data and log it to the console. If there's an error during the request, we catch it and log the error message.

Slack API

Slack, a widely used collaboration platform, offers an API that provides access to features like messaging, user data, and workspace management. This API is ideal for creating custom integrations or automating workflows within Slack.

Know More About Slack API Click Here

const fetch = require('node-fetch');
const slackToken = 'YOUR_SLACK_API_TOKEN';
const url = 'https://slack.com/api/conversations.list';

fetch(url, {
    headers: {
        'Authorization': `Bearer ${slackToken}`
    }
})
    .then(response => response.json())
    .then(data => console.log(data))
    .catch(error => console.error('Error:', error));

Here, we're using the Slack API to retrieve a list of conversations (channels) in a Slack workspace. We replace 'YOUR_SLACK_API_TOKEN' with our actual Slack API token, which is used for authentication. The API request URL is 'https://slack.com/api/conversations.list', which is the endpoint for listing conversations.

We use fetch to make the request, and we include an Authorization header in the headers object. The header value is constructed as 'Bearer YOUR_SLACK_API_TOKEN', where 'YOUR_SLACK_API_TOKEN' is replaced with the actual token. This header is required for Slack API requests to authenticate the request.

After making the request, we parse the JSON response and log the data to the console. If there's an error during the request, we catch it and log the error message.

Products and Things APIs:

Car Query API

This API provides detailed data on cars, including make, model, and year information. It can be useful for automotive-related applications, car rental platforms, or maintenance tracking systems.

Know More About Car Query API Click Here

const fetch = require('node-fetch');
const url = 'https://www.carqueryapi.com/api/0.3/?cmd=getMakes';
fetch(url)
    .then(response => response.json())
    .then(data => console.log(data))
    .catch(error => console.error('Error:', error));

In this example, we're using the Car Query API to retrieve a list of car makes. The API request URL is 'https://www.carqueryapi.com/api/0.3/?cmd=getMakes', which specifies the command to get the list of car makes.

We use fetch to make the request, handle the response, parse the JSON data, and log it to the console. This API provides information about cars, including make, model, and year, which can be useful for automotive-related applications.

Yelp Fusion API

Yelp, a well-known business review platform, offers an API that provides access to data on local businesses, including reviews, ratings, and business details. This API is valuable for creating location-based applications or integrating review features.

Know More About Yelp Fusion API Click Here

const fetch = require('node-fetch');
const yelpApiKey = 'YOUR_YELP_API_KEY';
const url = 'https://api.yelp.com/v3/businesses/search?location=San Francisco';
fetch(url, {
  headers: {
    'Authorization': `Bearer ${yelpApiKey}`
  }
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

Here, we're using the Yelp Fusion API to search for businesses in a specific location, in this case, San Francisco. We replace 'YOUR_YELP_API_KEY' with our actual Yelp API key, which is used for authentication. The API request URL includes the search parameters, such as the location.

We use fetch to make the request, and we include an Authorization header in the headers object. The header value is constructed as 'Bearer YOUR_YELP_API_KEY', where 'YOUR_YELP_API_KEY' is replaced with the actual key. This header is required for Yelp API requests to authenticate the request.

After making the request, we parse the JSON response and log the data to the console. If there's an error during the request, we catch it and log the error message.

Health APIs

Healthcare.gov API This API provides access to data on healthcare plans, provider directories, and other health-related information. It can be utilized by developers creating applications focused on healthcare services, insurance, or patient resources.

Know More About Healthcare API Click Here

const fetch = require('node-fetch');
const url = 'https://data.healthcare.gov/resource/xyz123.json';

fetch(url)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

In this example, we're using the Healthcare.gov API to retrieve data from a specific resource. The API request URL is 'https://data.healthcare.gov/resource/xyz123.json', where 'xyz123' should be replaced with the actual resource ID you want to retrieve.

We use fetch to make the request, handle the response, parse the JSON data, and log it to the console. This API provides access to healthcare-related data, such as plans, provider directories, and other health information.

Governments & Geography APIs:

Code.gov API

Code.gov's API offers access to data on federal government software projects, including code repositories and project details. It promotes transparency and enables developers to leverage government-related data in their applications.

Know More About Code.Gov API Click Here

const fetch = require('node-fetch');
const url = 'https://api.code.gov/projects';
fetch(url)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

Here, we're using the Code.gov API to retrieve a list of federal government software projects. The API request URL is 'https://api.code.gov/projects', which is the endpoint for listing projects.

We use fetch to make the request, handle the response, parse the JSON data, and log it to the console. This API provides transparency and access to data on government software projects.

Data.gov API

Data.gov provides a wide range of datasets from the US government, covering areas like weather, education, and health. It is a valuable resource for developers creating applications that rely on public data or conducting data-driven research.

Know More About Data.gov API Click Here

const fetch = require('node-fetch');
const url = 'https://api.data.gov/ed/collegescorecard/v1/schools.json?api_key=YOUR_DATA_GOV_API_KEY';
fetch(url)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

In this example, we're using the Data.gov API to retrieve data on colleges and universities. We replace 'YOUR_DATA_GOV_API_KEY' with our actual Data.gov API key, which is used for authentication. The API request URL includes the endpoint for retrieving school data and the API key as a query parameter.

We use fetch to make the request, handle the response, parse the JSON data, and log it to the console. This API provides access to a wide range of datasets from the US government, including education-related information.

Data.europa.eu API

This API provides open data from European Union institutions and bodies. It covers a range of topics and is valuable for developers creating applications with a focus on European data or conducting cross-border projects.

Know More About Data.Europea.EU API Click Here

const fetch = require('node-fetch');
const url = 'https://data.europa.eu/api/hub/search/datasets';
fetch(url)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

Here, we're using the Data.europa.eu API to search for datasets available from European Union institutions and bodies. The API request URL is 'https://data.europa.eu/api/hub/search/datasets', which is the endpoint for searching datasets.

We use fetch to make the request, handle the response, parse the JSON data, and log it to the console. This API provides open data from Europe, covering various topics, and is valuable for cross-border projects or applications with a European focus.

Open Source Projects APIs:

Libraries.io API: This API provides access to data on open-source projects, including dependency information, version history, and more. It is a valuable resource for developers contributing to or relying on open-source software.

Know More About Libraries.io API Click Here

const fetch = require('node-fetch');
const librariesApiKey = 'YOUR_LIBRARIES_IO_API_KEY';
const url = `https://libraries.io/api/platforms?api_key=${librariesApiKey}`;
fetch(url)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

The provided code example demonstrates how to use the Libraries.io API to retrieve information about open-source projects and platforms. It imports the node-fetch module, constructs the API request URL with the API key, fetches data from the API, handles the response, parses the JSON data, and logs it to the console or handles any errors that occur during the process.

Remember to replace 'YOUR_LIBRARIES_IO_API_KEY' with your actual API key for successful authentication.

Movies and Comics APIs:

Chuck Norris Jokes API: A lighthearted API, it provides access to a collection of Chuck Norris jokes. While amusing, it can be used to add

humorous elements to applications or create entertainment-focused projects.

Know More About Chuck Norris Jokes API Click Here

const fetch = require('node-fetch');
const url = 'https://api.chucknorris.io/jokes/random';
fetch(url)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

In this lighthearted example, we're using the Chuck Norris Jokes API to retrieve a random joke. The API request URL is 'https://api.chucknorris.io/jokes/random', which returns a random joke in JSON format.

We use fetch to make the request, handle the response, parse the JSON data, and log the joke to the console. This API adds a fun element to applications or can be used for entertainment purposes.

Marvel API

The Marvel API offers a wealth of data on Marvel comics, characters, and creators. It is ideal for developers creating applications or games related to the expansive Marvel universe.

Know More About Marvel API Click Here

const fetch = require('node-fetch');
const marvelPublicKey = 'YOUR_MARVEL_PUBLIC_KEY';
const marvelPrivateKey = 'YOUR_MARVEL_PRIVATE_KEY';
const ts = new Date().getTime();
const hash = require('crypto').createHash('md5').update(ts + marvelPrivateKey + marvelPublicKey).digest('hex');
const url = `https://gateway.marvel.com/v1/public/characters?ts=${ts}&apikey=${marvelPublicKey}&hash=${hash}`;

fetch(url)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

Here, we're using the Marvel API to retrieve information about Marvel comic characters. We replace 'YOUR_MARVEL_PUBLIC_KEY' and 'YOUR_MARVEL_PRIVATE_KEY' with our actual Marvel API public and private keys, respectively. The API request URL includes the timestamp (ts), the public key (apikey), and a hash generated using the timestamp, private key, and public key.

We use fetch to make the request, handle the response, parse the JSON data, and log it to the console. This API is ideal for creating applications or games related to the Marvel universe.

PokeAPI

For fans of Pokémon, this API provides comprehensive data on Pokémon species, abilities, and game information. It enables the creation of Pokémon-related applications, games, or fan sites.

Know More About PokeAPI Click Here

const fetch = require('node-fetch');
const url = 'https://pokeapi.co/api/v2/pokemon/ditto';
fetch(url)
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));

In this example, we're using the PokeAPI to retrieve information about a specific Pokémon, in this case, Ditto. The API request URL is 'https://pokeapi.co/api/v2/pokemon/ditto', which will provide details about Ditto.

We use fetch to make the request, handle the response, parse the JSON data, and log it to the console. The PokeAPI offers comprehensive data on Pokémon species, abilities, and game information, making it useful for Pokémon-related applications or fan sites.

Let’s Wrap Up

Thank you, Geeks, for reading this blog. This article is a valuable collection of free APIs spanning diverse categories. These APIs empower new developers to enhance their applications with innovative features and functionalities. From gaming and music to science, healthcare, and entertainment, the possibilities are endless.

As a founder, I encourage developers to explore these APIs and integrate them into their projects. By utilizing these resources, developers can create engaging, feature-rich applications while also learning and expanding their skill sets.

Happy coding, and feel free to reach out if you have any questions or feedback!