Skip to content

APIs for Beginners: What They Are and How to Use Them (2023)

What is an API? Understanding the Basics

An API (Application Programming Interface) is a contract that defines how software components should interact. Interfaces are all around us:

  • A radio has knobs (interface) to change volume/station, but you don't know how the internals work.
  • A graphical user interface (GUI) on your phone has a play button, you press it, music plays, but the implementation is hidden.

Similarly, an API:

  • Provides a set of tools for developers to use.
  • Abstracts away complex implementation details.
  • Uses a contract, you call it a certain way and expect a certain result.

"Interfaces abstract away the implementation. An API is a contract of sorts, it defines how it is expected to be used and what you can expect to receive."

Types of APIs You Already Use

  • Programming Language APIs, e.g., string.toUppercase() in any language.
  • File System APIs, same code works on Windows and Mac because the API abstracts the OS.
  • Web Browser APIs, your web code works in Chrome, Firefox, Safari thanks to standard browser APIs.
  • Frameworks & Libraries, add routes to a web app or make an image black-and-white with a single method call.

Remote APIs & Why REST Changed Everything

A remote API lets you control something over a network:

  • A TV remote changes channels without getting up.
  • A song-identifying app sends a snippet and gets results from a huge server database.
  • Google Translate uses massive processing power elsewhere to translate in real time.

After years of clunky standards, REST (Representational State Transfer) emerged as the clear winner. It's so popular that "REST API" is almost synonymous with "web API" today. For a deeper dive into understanding APIs and building your first AI assistant, check out Understanding APIs and Building Your First AI Assistant in Python.

How the Web Works (Quick Refresher)

| Term | Meaning | |------|---------| | Client | Your browser (or your code) | | Server | The remote computer holding data | | URL/URI | The address of the resource | | HTTP | The protocol (contract) for communication | | HTTP Verb | GET (retrieve), POST (create), PUT/PATCH (update), DELETE (remove) | | Headers | Extra info like auth tokens, content type, caching | | Status Code | 200 OK, 404 Not Found, 500 Server Error |

HTTP is stateless, each request is independent. State (like login) must be sent with every request, usually via headers. You can learn more about the fundamentals of testing these interactions in Comprehensive Introduction to API Testing Fundamentals and Tools.

RESTful APIs in Practice

Core REST Constraints (Your Scavenger Hunt)

Client-Server Architecture, Your code (client) talks to a remote server. ✅

Stateless, The server doesn't remember you; you send credentials each time. ✅

Resources, Everything is a resource (a book, an author, a photo). You interact using URLs. ✅

CRUD via HTTP Verbs

| Operation | HTTP Verb | Endpoint Example | |-----------|-----------|------------------| | Create | POST | /artists | | Read | GET | /artists/{id} | | Update | PATCH | /artists/{id} | | Delete | DELETE | /artists/{id} |

Representation, Data comes back as JSON (JavaScript Object Notation), which is easy to turn into objects in any language.

Cacheability, Responses can be cached to improve speed (Spotify uses this heavily). ✅

Layered System, You don't care if there are caching layers, databases, or other servers in between. ✅

Hands-On: Exploring Spotify's API

1. Using the Interactive Console

  1. Go to developer.spotify.com and scroll to the bottom.
  2. Click Developers → Docs → Web API.
  3. In the left sidebar, choose Search.
  4. Fill in: q = Beyoncé, type = artist.
  5. Click Get Token (you may need to create a free Spotify account).
  6. Click Try It, you'll get JSON back with artists.

2. Using curl from Your Terminal

curl is a command-line tool for making HTTP requests.

Check if it's installed:

curl --help

To replicate the Spotify search:

curl -X GET "https://api.spotify.com/v1/search?q=Beyonc%C3%A9&type=artist" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE"

What you get back: JSON listing artists, their genres, follower counts, and external URLs.

3. Fetching Albums for an Artist

  1. Copy the artist ID from the search results (e.g., 6vWDO969PvNqNYHIOW5v0m).
  2. Call the albums endpoint:
curl -X GET "https://api.spotify.com/v1/artists/6vWDO969PvNqNYHIOW5v0m/albums" \
  -H "Authorization: Bearer YOUR_TOKEN_HERE"

You'll get a list of albums including image URLs, release dates, and available markets.

Key Takeaways

  • APIs make complex tasks simple, you don't need to know the internals, just the interface.
  • REST APIs use the same web tools you already know (HTTP, URLs, headers, status codes).
  • JSON is the standard format for data exchange in web APIs.
  • curl is a powerful tool for testing and exploring APIs from the command line.
  • Real-world APIs like Spotify's let you search, retrieve data, and even create playlists programmatically. For more on structuring endpoints, see Mastering API Routing: Static, Dynamic, Query Parameters & Best Practices.

Teacher Notes / Next Steps

Keep this summary

Save it to LunaNotes and it becomes a real note in your library — editable, searchable, and ready to turn into flashcards or a diagram. Free to start.

Save to LunaNotes

Or summarise for another video.

32K+ people have turned 65K+ videos into notes

“Very useful tool. I'm using it for the last couple weeks and I'm loving it so far. Makes learning on YouTube a great experience.”
Bhai Chrome Web Store review

This summary and transcript were automatically generated using AI with the Free YouTube transcript summary tool by LunaNotes.

Related summaries

Comprehensive Introduction to API Testing Fundamentals and Tools

Comprehensive Introduction to API Testing Fundamentals and Tools

This session covers the basics of API testing, including client-server architecture, types of APIs, and key testing methods. Learn how APIs function as intermediaries between front-end and back-end systems, the importance of API testing, and the tools like Postman and Rest Assured used for manual and automated testing.

Understanding APIs and Building Your First AI Assistant in Python

Understanding APIs and Building Your First AI Assistant in Python

Learn what an API is through a simple restaurant analogy and build your own command-line AI assistant by the end of the first day. This hands-on tutorial emphasizes a build-first philosophy, requiring minimal setup.

HTTP Protocol Fundamentals: Statelessness, Methods, CORS, Caching, and Status Codes for Backend Developers

HTTP Protocol Fundamentals: Statelessness, Methods, CORS, Caching, and Status Codes for Backend Developers

This comprehensive guide explains core HTTP concepts every backend developer needs to know, covering stateless architecture, request/response headers, methods, status codes, CORS flow, caching strategies, content negotiation, and large data transfer. You'll learn why HTTP is stateless, how browsers handle cross-origin requests with preflight checks, and practical ways to optimize performance using caching and compression.

.NET Full-Stack Interview: C#, SQL, Web API & React Concepts Explained

.NET Full-Stack Interview: C#, SQL, Web API & React Concepts Explained

In this mock interview, a full-stack developer with 3.5 years of experience is quizzed on key .NET, SQL, and React concepts. Topics covered range from C# fundamentals like IEnumerable vs IQueryable and async/await, to SQL indexing and normalization, as well as Web API middleware and React hooks.

Python Mastery Course: Complete Beginner to Pro Guide (2024)

Python Mastery Course: Complete Beginner to Pro Guide (2024)

Learn Python from scratch with this comprehensive guide covering variables, strings, numbers, and essential programming concepts. Master Python for AI, web development, and automation with step-by-step tutorials from an experienced software engineer.

Found this summary useful?

Take it with you. One click puts it in your own LunaNotes library.

Save to LunaNotes

Start taking better notes today with LunaNotes