A URL stands for Uniform Resource Locator. In simple terms, a URL is like the street address of a resource on the internet. Just as a GPS needs a specific, unique address to find a location, your browser or API client needs a URL to find a specific file, data endpoint, or service hosted on a server.
A URL is essentially an address used by a web browser or application to locate a resource on the internet. While they can seem complex, they follow a predictable, structured format.
The general format is:
scheme://authority/path?query#fragment
The scheme or protocol defines the set of rules used to retrieve the resource. It specifies how the browser should communicate with the server.
http: (HyperText Transfer Protocol)https: (HyperText Transfer Protocol Secure - the standard for secure web traffic)The authority component is often prefixed with // and identifies the server hosting the resource. It is typically broken down into:
api.example.com or 192.0.2.1.80 for HTTP, 443 for HTTPS).
api.example.com:8080The path identifies the specific resource on the server. This often resembles the file structure of the server, but in modern web APIs, it often represents a hierarchy of resources.
https://api.example.com/users/123/orders, the path is /users/123/orders. The path starts after the host and port, and ends before the first ? or #.The query string is used to pass additional parameters or data to the server, often to filter, sort, or paginate the requested resource. It begins with a question mark (?) and consists of key-value pairs separated by ampersands (&).
.../products?**category=electronics&sort=price**, the query string is category=electronics&sort=price.
category, sortelectronics, priceThe fragment (or hash) component begins with a hash symbol (#) and is used to identify a specific section or portion of the resource. Critically, the fragment is usually processed by the browser and is NOT sent to the server in an HTTP request.
.../document.html#**section-3**, the fragment is section-3. This tells the browser to scroll to the element with the ID section-3 on the page.Let's look at a complete example:
https://dev.example.com:443/api/v1/users?active=true#profile-info
| Component | Value | Role |
|---|---|---|
| Scheme | https |
Defines the secure communication protocol. |
| Host | dev.example.com |
The server's domain name. |
| Port | 443 |
The standard HTTPS port (often omitted). |
| Path | /api/v1/users |
The resource being requested (a collection of users). |
| Query | active=true |
A parameter to filter the results (only active users). |
| Fragment | profile-info |
A section on the client-side, not sent to the server. |
The HackYourFuture curriculum is licensed under CC BY-NC-SA 4.0 **
