DummyJSON User Connector — Live Demo

getUser(int $id): User

Fetches a single user by ID via GET /users/{id}. The JSON response is mapped into a User DTO — a final readonly value object carrying id, firstName, lastName, and email. Additional fields from the API payload (age, phone, password, etc.) are deliberately ignored.

Throws: UserNotFoundException on 404, TransportException on a network/DNS/timeout failure, ApiException on any other non-2xx, and InvalidResponseException if the response body is missing required fields or has the wrong shape.

Try it

DummyJSON has ~208 users. Try an ID like 1, 42, or 208 for success — or something huge like 999999 to trigger UserNotFoundException.

Consumer code

use Kayrah87\DummyJsonUserConnector\Exception\UserNotFoundException;
use Kayrah87\DummyJsonUserConnector\Service\UserService;

$service = UserService::create();

try {
    $user = $service->getUser(1);
    echo $user->firstName;
} catch (UserNotFoundException $e) {
    echo "no user with id " . $e->getUserId();
}