1 of 17

Intro to HTTP

CSCI 344: Advanced Web Technologies

Spring 2025

2 of 17

Weekly Announcements

  1. Tutorial 6 – due Tonight (3/03)
  2. Quiz 2a – this Friday during class (3/07)
  3. Wednesday, 3/06 at 5PM: JavaScript review session

3 of 17

Outline

  1. Finishing Tutorial 6
  2. Intro to Web Services and Web APIs
  3. Intro to HTTP
  4. Interacting with a REST APIs

4 of 17

Outline

  1. Finishing Tutorial 6
  2. Intro to Web Services and Web APIs
  3. Intro to HTTP
  4. Interacting with a REST APIs

5 of 17

Let’s discuss Tutorial 6

6 of 17

Outline

  • Finishing Tutorial 6
  • Intro to Web Services and Web APIs
  • Intro to HTTP
  • Interacting with a REST APIs

7 of 17

Understanding how to work with Web Services & APIs is so useful!

  • Many organizations make their data, storage, and compute services available over the web.
  • Understanding how to interact with various web services using the HTTP protocol is perhaps one of the most useful, practical skills that you can learn.
  • This isn’t just relevant for web browsers – all modern programming languages have a way to encode, decode, and communicate messages over HTTP.

8 of 17

What is a Web API?

API → “Application Programming Interface”

A set of rules that you have to follow to interact with a piece of software

Web API

An API that you access via HTTP protocol. Offers a systematic way to:

  1. Create update, read, and delete resources over the internet
  2. Expose parts of your database to third party clients
  3. Allow a web client (or any client) to take advantage of resources distributed across providers, servers, organizations, etc.

REST API

A kind of Web API that honors the “REST” endpoint design conventions

8

9 of 17

Many Organizations Publish their Data via Web APIs

  • Companies:
    • e.g., Spotify, Yelp, OpenAI, etc.
  • Government Organizations:
    • e.g., NASA, Asheville Open Data Portal, etc.

10 of 17

Outline

  1. Finishing Tutorial 6
  2. Intro to Web Services and Web APIs
  3. Intro to HTTP
  4. Interacting with Web / REST APIs

11 of 17

HTTP: Hypertext Transfer Protocol

Web servers communicate through HTTP – a stateless protocol for encoding, decoding, and transmitting messages over the web.

  • Stateless mean that no memory is preserved between requests – each request must contain all the information needed on its own to fulfill the request (no stored context).
  • HTTP requests and responses have a header (which contains metadata about the request) and a body (which contains the request itself)
  • HTTP requests also have methods (GET, POST, PATCH, PUT, DELETE, etc.) – next slide.
  • HTTP responses have status codes that tell you whether the request was successful or not.

11

12 of 17

HTTP Methods

Methods tell the server what action they should take (verbs):

12

Method

Job

Description

GET

Read

Retrieves / reads a resource (or container of resources) from an address (endpoint) on a server

POST

Create

Creates a NEW resource on a server; done by posting data to an address (endpoint) on a server

PUT

Replace

Replaces a resource on a server

PATCH

Update

Updates a resource on a server

DELETE

Deletes

Deletes a resource on a server

13 of 17

HTTP Status Codes

Status codes provide information re: whether your request was successful. Here is a list of them. Ones you should be familiar with:

Code

Definition

201

POST method successfully created a resource

200

Valid request made (generic success message)

400

Client posted a bad request that the server can’t understand

403

Forbidden (you don’t have access to it)

404

Resource cannot be found

500

Server error (usually because there’s a server bug)

14 of 17

Outline

  1. Finishing Tutorial 6
  2. Intro to Web Services and Web APIs
  3. Intro to HTTP
  4. Interacting with Web / REST APIs

15 of 17

Interacting with a Web / REST API: Clients

You can access a REST API via many different clients (including):

  1. Through your browser
  2. Through Java, C, C++, Python, or any other language
    1. In other words, servers talk to other servers via HTTP/S requests
  3. cURL or wget (command line tools)
  4. Postman
  5. And more!

16 of 17

Interacting with a Web API: Authentication

  1. To use a Web API, you typically need to register with the API provider and obtain an access token (like a secret password).
  2. This enables the provider to track who is using their API and for what purposes.
    • Many platforms also charge for their data services (i.e. Google, Amazon, Azure, etc.), so people’s bank accounts are often tied to their API key
  3. We will learn some different approaches to handling authentication later in the semester
  4. For now, I have already registered each of you with the course Photo App so that we can practice.

16

17 of 17

Photo App API: Practice

  1. Navigate to https://photo-app-secured.herokuapp.com/
  2. Log in:
    1. Username: your first name (lowercase)
      1. Anthony and Ben: add first letter of last name
    2. Password: password
  3. Once you’ve logged in click on the API Docs link at the top, right-hand side of the web interface.
  4. (Walkthrough)