REST, status codes, versioning, pagination, auth, gRPC and GraphQL
Practise these as flashcards. One or two lines each; the ones you miss come back first.
Start freeA REST resource is an object or entity, like a user or order, that the API exposes. It's represented by a URI, such as /users/123, and manipulated using HTTP verbs like GET, POST, PUT, and DELETE.
GET, PUT, and DELETE are idempotent, meaning repeating the same request has the same effect. This matters because it makes APIs safer and more predictable, especially when clients retry requests.
You should return 201 Created, and ideally include a Location header pointing to the new resource.
I would add query parameters like limit and offset for offset-based pagination, or use a cursor parameter for cursor-based pagination, to let clients fetch results in pages.
Authentication verifies the identity of the client, such as via API keys or OAuth tokens. Authorization checks if the authenticated client has permission to perform a specific action, often using roles or scopes.
409 Conflict is for resource state conflicts, like trying to create a duplicate. 422 Unprocessable Entity is for semantic errors, like invalid input that passes syntax checks but fails business rules.
I avoid breaking changes in existing endpoints, use versioning for major changes, and add new fields or endpoints in a way that doesn't affect current clients.
An idempotency key is a unique value sent by the client with a POST request. The server uses it to recognize and ignore duplicate requests, ensuring only one resource is created even if the client retries.
I would require authentication, such as API keys or OAuth 2.0, use HTTPS to encrypt traffic, validate input, and implement rate limiting to prevent abuse.
Contract-first design ensures everyone agrees on the API before coding, reduces misunderstandings, enables code generation, and provides up-to-date documentation for clients.
I would use a structured format, like RFC 7807 Problem Details, including fields like type, title, status, and detail, so clients can programmatically handle errors.
OAuth 2.0 is an authorization framework for delegated access, while JWT is a token format often used to carry claims in OAuth. JWTs are self-contained and stateless, making them suitable for scalable APIs.