Week 9 - Networking and APIs

Introduction to Networking

Client Server Model

TCP/IP Protocol

HTTP Protocol

URL Format

Web APIs

API Testing Tools

Using APIs

Practice

Assignment

Core program

The URL Format

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.

Key Characteristics

  1. Uniform: The structure and rules for URLs are standardized (defined by the Internet Engineering Task Force, or IETF). This means that every application, from a web browser to a JavaScript network request, interprets the address in the same way.
  2. Resource: The thing being located. This could be a static file (like an image or an HTML page), or, in the case of APIs, a dynamic data endpoint (like a list of users or a place to submit a form).
  3. Locator: It provides the specific mechanism (the scheme or protocol) and the location (authority and path) needed to access the resource.

URL Components Explained

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

Scheme (Protocol)

The scheme or protocol defines the set of rules used to retrieve the resource. It specifies how the browser should communicate with the server.

Authority (Host and Port)

The authority component is often prefixed with // and identifies the server hosting the resource. It is typically broken down into:

Path

The 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.

Query String (Optional)

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 (&).

Fragment (Optional)

The 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.

Example URL Breakdown

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 **

CC BY-NC-SA 4.0 Icons

*https://hackyourfuture.net/*