Creating REST APIs in CodeIgniter — a practical guide to CodeIgniter REST API with clear examples you can reuse in real projects.
CodeIgniter Tutorial Series (45/74). Prefer one article? Read the complete CodeIgniter tutorial.
Short description
REST APIs use HTTP verbs and JSON bodies/responses. Keep controllers focused on status codes and payloads.
API list endpoint
public function index()
{
$posts = model('PostModel')->findAll();
return $this->response->setJSON(['data' => $posts]);
}