Lesson content
Read, practise, then check your understanding
REST-style HTTP APIs expose resources through URIs and standard method semantics. GET reads, POST creates/actions, PUT replaces, PATCH modifies, and DELETE removes when those meanings fit.
Practical example
<?php
header('Content-Type: application/json; charset=utf-8');
http_response_code(201);
echo json_encode(['data' => ['id' => $id]], JSON_THROW_ON_ERROR);
Use accurate statuses, consistent error objects, authentication and authorization, content negotiation, pagination, rate limits, idempotency keys for retried creation, and versioning policy. Never expose stack traces or database errors. Validate media type and payload schema.
Knowledge check
Answer every question correctly to complete this chapter.
0 of 10 checks passed
Your progress is saved on this device.