4.8 KiB
4.8 KiB
Users
List users
Returns the Users resource with the roles relation.
Example request:
curl -X GET \
-G "http://localhost/api/users" \
-H "Content-Type: application/json" \
-H "Accept: application/json"
const url = new URL(
"http://localhost/api/users"
);
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
};
fetch(url, {
method: "GET",
headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$response = $client->get(
'http://localhost/api/users',
[
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
Example response (200):
{
"data": [
{
"id": "fb8cab66-23e4-3f0b-8880-094f1ed59223",
"name": "Mr. Dayton Pagac",
"email": "urolfson@example.net",
"created_at": "2020-12-30T20:48:33+00:00",
"updated_at": "2020-12-30T20:48:33+00:00",
"roles": {
"data": []
}
},
{
"id": "6db61d41-17bc-3604-b7d5-83da76f9b03a",
"name": "Annabel Senger",
"email": "cstoltenberg@example.com",
"created_at": "2020-12-30T20:48:33+00:00",
"updated_at": "2020-12-30T20:48:33+00:00",
"roles": {
"data": []
}
}
],
"meta": {
"pagination": {
"total": 2,
"count": 2,
"per_page": 20,
"current_page": 1,
"total_pages": 1,
"links": {}
}
}
}
Received response:
Request failed with error:
Request
GET
api/users
Get single user
Returns the User resource by it's uuid
Example request:
curl -X GET \
-G "http://localhost/api/users/minima" \
-H "Content-Type: application/json" \
-H "Accept: application/json"
const url = new URL(
"http://localhost/api/users/minima"
);
let headers = {
"Content-Type": "application/json",
"Accept": "application/json",
};
fetch(url, {
method: "GET",
headers,
}).then(response => response.json());
$client = new \GuzzleHttp\Client();
$response = $client->get(
'http://localhost/api/users/minima',
[
'headers' => [
'Content-Type' => 'application/json',
'Accept' => 'application/json',
],
]
);
$body = $response->getBody();
print_r(json_decode((string) $body));
Example response (200):
{
"data": {
"id": "c6eaae09-1a89-33ed-93a5-6c8528d810d8",
"name": "Kaelyn Lemke",
"email": "alta.heller@example.com",
"created_at": "2020-12-30T20:48:33+00:00",
"updated_at": "2020-12-30T20:48:33+00:00",
"roles": {
"data": []
}
}
}
Received response:
Request failed with error:
Request
GET
api/users/{uuid}
URL Parameters
uuid string
The UUID of the user.