🌐

APIs: REST, GraphQL & HTTP Status Codes

108 cards · 🇺🇸 English

REST and GraphQL API concepts plus common HTTP status codes.

Study all 108 cards for free

Flashcards, quizzes, pixel-art games and a daily review that remembers for you.

Study this deck free

Try the first 10 cards

1 / 10
Question

REST

Knew itLearning

Tap the card for the answer · swipe right if you knew it, left if not

Already have an account? Sign in

Cards

  1. 1REST
    REpresentational State Transfer - an architectural style for distributed systems using stateless, client-server communication with uniform interfaces and resource-based URIs.
  2. 26 REST constraints
    1) Uniform Interface, 2) Client-Server, 3) Stateless, 4) Cacheable, 5) Layered System, 6) Code-on-Demand (optional).
  3. 3Uniform interface constraint
    Resources identified by URIs, manipulation through representations, self-descriptive messages, and hypermedia as the engine of application state (HATEOAS).
  4. 4Stateless
    Each request contains all information needed to understand and process it. Server doesn't store client session state between requests.
  5. 5Resource in REST
    Any information that can be named - a document, image, collection, non-virtual object. Resources are identified by URIs and manipulated via representations.
  6. 6Resource representation
    The state of a resource at a given time, including data, metadata, and hypermedia links. Common formats: JSON, XML, HTML.
  7. 7What HTTP method is used for retrieving resources?
    GET - retrieves a resource without side effects. Idempotent and safe (doesn't modify server state).
  8. 8What HTTP method is used for creating resources?
    POST - creates a new resource. Server determines URI. Not idempotent (multiple calls create multiple resources).
  9. 9What HTTP method is used for updating resources?
    PUT - replaces entire resource or creates if doesn't exist. Idempotent (same request multiple times has same effect).
  10. 10What HTTP method is used for partial updates?
    PATCH - applies partial modifications to a resource. Updates specific fields without replacing the entire resource.
  11. 11What HTTP method is used for deleting resources?
    DELETE - removes a resource. Idempotent (deleting same resource multiple times has same effect).
  12. 12Idempotent
    An operation is idempotent if performing it multiple times has the same effect as performing it once. GET, PUT, DELETE are idempotent; POST is not.
  13. 13Safe
    A safe method doesn't modify server state. Only retrieves information. GET, HEAD, OPTIONS are safe.
  14. 14What HTTP status code indicates success?
    200 OK - successful GET, PUT, PATCH. 201 Created - successful POST. 204 No Content - successful DELETE.
  15. 15400 Bad Request
    Client error - malformed request syntax, invalid parameters, or missing required fields.
  16. 16401 Unauthorized
    Authentication is required. Client must provide valid credentials. Misleading name - actually means unauthenticated.
  17. 17403 Forbidden
    Client is authenticated but doesn't have permission to access the resource. Authorization failed.
  18. 18404 Not Found
    Requested resource doesn't exist. Server can't find the URI.
  19. 19500 Internal Server Error
    Server encountered an unexpected condition. Generic server-side error message.
  20. 20503 Service Unavailable
    Server temporarily unable to handle request (overload, maintenance). Includes Retry-After header when possible.
  21. 21HATEOAS
    Hypermedia As The Engine Of Application State - responses include hypermedia links to related resources and possible actions, making API self-descriptive.
  22. 22API endpoint
    A specific URI where an API resource or collection can be accessed. Example: /api/users, /api/users/123.
  23. 23How should collections be named in REST?
    Use plural nouns: /users, /products, /orders. Be consistent. Avoid verbs - use HTTP methods instead.
  24. 24How should single resources be addressed?
    Use resource ID after collection: /users/123, /products/abc. ID can be numeric or string (UUID).
  25. 25How should nested resources be structured?
    Reflect relationships: /users/123/posts, /orders/456/items. Keep nesting shallow (max 2-3 levels).
  26. 26Query parameters used for
    Filtering, sorting, pagination, searching. Example: /users?role=admin&sort=name&page=2&limit=20.
  27. 27How should pagination be implemented?
    Query params: ?page=2&limit=20 or ?offset=40&limit=20. Include total count and links (next, prev) in response.
  28. 28API versioning
    Managing breaking changes by maintaining multiple API versions. Methods: URI (/v1/users), header (Accept: application/vnd.api+json;version=1), subdomain (api-v1.example.com).
  29. 29Content Negotiation
    Client specifies desired format via Accept header. Server responds with Content-Type. Example: Accept: application/json.
  30. 30What headers are commonly used in REST APIs?
    Authorization, Content-Type, Accept, Cache-Control, ETag, If-None-Match, If-Modified-Since, Location (for redirects).

And 78 more cards. Study the whole deck free

Articles about this deck

More Programming decks

See all
Study all 108 cards free