COMP9321 · 05 REST · Terms

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/54

encourage image

There's no tags or description

Looks like no tags are added yet.

55 Terms

1
New cards
REST
REpresentational State Transfer: an architectural style (not a standard) of constraints for building services from the Web's own parts: HTTP, URIs, representations. ✎ Exam: The ride service follows ___: resources with URIs, standard HTTP methods and stateless requests.
2
New cards
Resource
The fundamental unit of a REST API: anything worth naming (an order, a customer), identified by a URI. ✎ Exam: Each ride is a ___ with its own URI, /v1/rides/R789.
3
New cards
URI
Uniform Resource Identifier: the address that names a resource, e.g. /v1/rides/R789. ✎ Exam: The ___ uses nouns (/rides), and the HTTP method supplies the verb.
4
New cards
Addressable
Every resource has its own URI that can be called directly. ✎ Exam: Rides are ___: GET /rides/R789 returns that ride.
5
New cards
Representation
The form a resource is sent in: JSON, XML, HTML, a language. ✎ Exam: The client asks for the JSON ___ with Accept: application/json.
6
New cards
Content negotiation
The client asks for a representation with headers such as Accept: application/json or Accept-Language: fr, and the server picks the matching one. ✎ Exam: Through ___, the same order can be returned as JSON or XML.
7
New cards
API contract
The agreement of what you send and what you get back; an API is for programs, so it must be clear and stable. ✎ Exam: Changing a field name breaks the ___, so it needs a new version.
8
New cards
GET
Read a resource. Safe and idempotent. 200 OK. ✎ Exam: ___ /v1/users/U123/rides?status=completed → 200 OK with the list.
9
New cards
POST
Create a resource under a collection (the server picks the ID), or a non-idempotent action. Not safe, not idempotent. 201 Created + Location header. ✎ Exam: ___ /v1/rides creates a ride request → 201 Created, Location: /v1/rides/R789.
10
New cards
PUT
Create or fully replace the resource at a URI the client knows. Idempotent, not safe. Missing fields are cleared. 200/204, or 201 if created. ✎ Exam: ___ /orders/42 with the whole order replaces order 42.
11
New cards
PATCH
Partially update a resource: send only the changed fields. Not idempotent in general. 200/204. ✎ Exam: ___ /v1/rides/R789 {"status": "completed"} changes one field, so ___, not PUT.
12
New cards
DELETE
Remove a resource. Idempotent, not safe. 204 No Content (or 200). ✎ Exam: ___ /v1/rides/R789 → 204 No Content.
13
New cards
HEAD
Like GET but returns only the headers, no body. Safe and idempotent. ✎ Exam: ___ checks a file's size and Last-Modified without downloading it.
14
New cards
OPTIONS
Asks which methods are allowed on a resource. Safe and idempotent. ✎ Exam: ___ /rides tells the client GET and POST are allowed.
15
New cards
Safe method
Read-only: no server state changes (GET, HEAD, OPTIONS). Like multiplying by 1. ✎ Exam: GET must be safe, so GET /orders/42/delete is a misuse: crawlers or caches may trigger it.
16
New cards
Idempotent method
One request has the same effect as many identical ones (GET, PUT, DELETE, HEAD, OPTIONS). Like multiplying by 0. ✎ Exam: PUT is ___: sending the same replacement twice leaves the same result.
17
New cards
200 OK
Success with a body (GET, or an update returning the resource). ✎ Exam: GET /rides/R789 → ___ with the ride.
18
New cards
201 Created
A new resource was ___; send a Location header with its URI. ✎ Exam: POST /rides → ___, Location: /rides/R789.
19
New cards
204 No Content
Success with no body (often DELETE or an update). ✎ Exam: DELETE /rides/R789 → ___.
20
New cards
304 Not Modified
The client's cached copy is still valid (conditional GET), so no body is re-sent. ✎ Exam: With If-None-Match and an unchanged ETag, the server answers ___.
21
New cards
400 Bad Request
The client sent invalid or missing data. ✎ Exam: Missing pickup coordinates → ___.
22
New cards
401 Unauthorized
Not authenticated: no valid credentials/token. ("Who are you?" failed.) ✎ Exam: A request without a valid token → ___.
23
New cards
403 Forbidden
Authenticated, but not allowed to do this. ("What may you do?" failed.) ✎ Exam: A logged-in rider updating someone else's ride → ___.
24
New cards
404 Not Found
The resource doesn't exist. ✎ Exam: PATCH /rides/R999 for a non-existent ride → 404.
25
New cards
405 Method Not Allowed
The ___ isn't ___ on this resource. ✎ Exam: DELETE on /rides (the whole collection) → 405.
26
New cards
409 Conflict
The request ___ with the resource's current state (illegal transition, edit ___). ✎ Exam: Changing a ride from completed back to requested → ___.
27
New cards
429 Too Many Requests
Rate limit exceeded. ✎ Exam: A client sending 1,000 ___ a minute gets ___.
28
New cards
500 Internal Server Error
Something failed on the ___ (a 5xx = ___'s fault, 4xx = client's fault). ✎ Exam: An unhandled exception returns 500.
29
New cards
Client–server
REST constraint 1: UI separated from data and storage, so each side evolves independently. ✎ Exam: ___ separation lets the mobile app change without touching the database.
30
New cards
Uniform interface
REST constraint: resources + URIs + standard methods + representations (+ links), the same meaning everywhere. Simple, predictable, decoupled. ✎ Exam: Thanks to the ___, DELETE means the same on rides and on users.
31
New cards
Statelessness
REST constraint: every request carries all the information needed to process it; the server keeps no client session between requests. Benefit: scalability. ✎ Exam: Each request carries its token, so any server can handle it: ___ lets us add servers freely.
32
New cards
Cacheable
REST constraint: responses are marked ___ or not. Fewer round trips, better performance. ✎ Exam: Product pages are ___ for an hour with Cache-Control: max-age=3600.
33
New cards
Layered system
REST constraint: the client can't tell whether it talks to the server or an intermediary (load balancer, cache, gateway). Scalability and security ___. ✎ Exam: A ___ lets us add a cache in front of the API without changing clients.
34
New cards
Code on demand
Optional REST constraint: the server may send code to run on the client (JavaScript). ✎ Exam: ___ is the only optional REST constraint.
35
New cards
HATEOAS
Hypermedia as the Engine of Application State: responses include links to the next possible actions; clients follow links instead of hard-coding URIs. ✎ Exam: The order response includes a payment link (___), so the client doesn't hard-code the payment URI.
36
New cards
Richardson Maturity Model
Levels of REST: 0 one endpoint (SOAP-like) · 1 resources · 2 HTTP verbs + status codes · 3 hypermedia (HATEOAS). ✎ Exam: Most REST APIs stop at ___ level 2: proper verbs and codes, but no links.
37
New cards
ETag
A version tag of a resource. With If-None-Match → 304 if unchanged; with If-Match on PUT/PATCH → prevents lost updates (412/409 if changed). ✎ Exam: The client sends If-None-Match with the ___ and gets 304 Not Modified if nothing changed.
38
New cards
Cache-Control
Header saying how a response may be ___: max-age=N, public, private (browser only), no-store (never ___, sensitive data). ✎ Exam: Account balances are sent with ___: no-store.
39
New cards
API versioning
Keep old clients working when the API changes: ___ in the URI (/v1/), a header (Accept: application/vnd.shop.v2+json) or a query parameter. ✎ Exam: Breaking changes go into /v2/ while /v1/ keeps running for old clients.
40
New cards
Swagger / OpenAPI
Machine-readable API description with an interactive documentation UI; Flask-RESTX generates it. ✎ Exam: Flask-RESTX publishes ___ docs so developers can try every endpoint.
41
New cards
Flask-RESTX
Python library for REST APIs: Resource classes with get/post/put/delete methods, request parsing, models, and Swagger docs. ✎ Exam: In ___ each endpoint is a Resource class with a get() and a post() method.
42
New cards
Content negotiation
Scenario: The same resource must be returned as JSON to one client and XML to another, at the same URI. Why: ___ via the Accept header.
43
New cards
GET
Scenario: Retrieve a rider's past completed rides. Why: ___ /v1/users/{id}/rides?status=completed → 200: reading is safe.
44
New cards
POST
Scenario: A rider requests a new ride; the server assigns the ride ID. Why: ___ /v1/rides → 201 Created + Location: create under a collection, server picks the ID.
45
New cards
PUT
Scenario: The client sends the complete new version of order 42 to its exact URI. Why: ___: full replacement at a known URI; idempotent.
46
New cards
PATCH
Scenario: Update only the status field of an existing ride (sample paper). Why: ___: a partial update. PUT would need the whole ride.
47
New cards
Safe method
Scenario: Why is GET /orders/42/delete wrong? Why: GET must be a safe (read-only) ___; caches and crawlers may call it.
48
New cards
Idempotent method
Scenario: A client times out and resends the same request. For which ___ is that harmless? Why: ___ ___ (GET, PUT, DELETE): repeating changes nothing more. POST could create a duplicate.
49
New cards
201 Created
Scenario: What should POST /orders return after ___ order 1234? Why: ___ with Location: /orders/1234 (not 200).
50
New cards
401 Unauthorized
Scenario: A request arrives with no token at all. Why: ___: authentication failed.
51
New cards
403 Forbidden
Scenario: Rider A, correctly logged in, tries to update rider B's ride. Why: ___: authenticated but not authorised.
52
New cards
409 Conflict
Scenario: A client tries to move a completed ride back to "requested". Why: ___: an illegal state transition.
53
New cards
Statelessness
Scenario: Does storing customer records in a database violate this REST constraint? Why: No. ___ bans client session state on the server, not resource state in a database.
54
New cards
HATEOAS
Scenario: An order response contains . Why: ___: links to the next actions; Richardson level 3.
55
New cards
ETag
Scenario: Two clients edit the same order; the second must not overwrite the first's change silently. Why: ___ + If-Match conditional request → 412/409 if the resource changed (no lost update).