API FUNDAMENTALS / LESSON 03
URLs and Endpoints.
Addressing resources on the web

Loading the lesson…
Loading activities…
API FUNDAMENTALS / LESSON 03
Addressing resources on the web

Loading the lesson…
Loading activities…
Every API request needs somewhere to GO. You can't mail a letter without an address, and you can't send an API request without a URL. The specific spots where you send those requests are called endpoints.
Good news, you already know this one. A URL is a web address. You type them into your browser every day.
A URL tells your computer where to find something on the internet. Think street addresses, but for the web.
Let's pull a URL apart and look at the pieces.
This is HOW you connect. HTTPS means secure and HTTP means not secure. Go with HTTPS whenever you can.
This is the server's address. It's like the street address of a building.
This is the specific spot on that server... kinda like the apartment number inside the building.
These are extra options or filters, and they show up after a question mark. Think of them as special instructions for your order.
An endpoint is a specific URL where an API accepts requests. Each one does its own job.
Back to the restaurant for a sec. The restaurant has one address, but inside there are a few different counters.
Each counter is like an endpoint. Same building, different purposes.
Most APIs follow pretty similar patterns for their endpoints. Learn the pattern once and you can usually guess how a brand new API works (which feels like a lil superpower the first time it happens).
These work with lists of things.
These work with one specific thing, so they include an ID.
Sometimes things belong to other things.
HTTP methods and endpoints are a team. The method says WHAT to do and the endpoint says WHERE to do it.
Here's how they team up on a user endpoint.
| Method | Endpoint | What It Does |
|---|---|---|
| GET | /users | Get all users |
| GET | /users/42 | Get user 42 |
| POST | /users | Create a new user |
| PUT | /users/42 | Update user 42 |
| DELETE | /users/42 | Delete user 42 |
Same endpoint pattern, different methods, different actions.
Sometimes you want to filter or tweak what comes back. That's what query parameters are for. They go at the end of the URL after a question mark.
If you've got more than one, you separate them with &.
Common uses for query parameters
?status=active (only show active items)?sort=price (order by price)?page=2&limit=20 (get page 2, 20 items per page)?search=laptop (find items matching "laptop")Here's how a couple of APIs might lay out their endpoints.
Real APIs have a base URL that every endpoint shares. The base URL is the domain part.
When you read API docs, you'll usually see just the endpoint part (/products) with the base URL mentioned once somewhere else. Glue them together and you've got the full address.
/users and /products/users/42?status=activeYou know where to send requests and which methods to use. Next up is the data itself. When APIs send and receive information they use a format called JSON, and that's what we're tackling next...