Course API Development

HTTP Fundamentals

API Basics Preview

HTTP

The methods

MethodPurposeIdempotent
GETRead dataYes
POSTCreate a resourceNo
PUTReplace a resourceYes
PATCHPartial updateNo
DELETERemove a resourceYes

Idempotent means repeating the request gives the same result. GET is safe to retry; POST usually creates a new record each time.

Status codes

CodeMeaningExample
200OKSuccessful GET
201CreatedSuccessful POST
400Bad requestInvalid input
401UnauthorizedMissing token
403ForbiddenNo permission
404Not foundUnknown endpoint
422UnprocessableValidation failed
500Server errorA bug

Headers

Content-Type: application/json\nAuthorization: Bearer <token>\nAccept: application/json
Tip: Learn the status code ranges: 2xx success, 3xx redirect, 4xx your fault, 5xx the server's fault.

This is a free preview lesson

Enroll in the API Development to unlock every lesson, lesson PDF guides, quizzes and your certificate - and start creating your own pieces today.


Discussion

Free preview lesson