The MDJM REST API includes the /client/
endpoint to enable a specific clients details to be retrieved.
The /client/
endpoint allows you to query the database by a client’s user ID, and then returns MDJM relevant information pertaining to that client.
Parameters
The /client/
endpoint requires one of two possible parameters to be sent along with the API request;
- client_id (Optional)
The user ID of the client you wish to retrieve. - client_email (Optional)
The email address of the client you wish to retrieve.
If neither one of these parameters is provided, the request will return an error.
If validation succeeds and the client is located the following details will be returned;
ID
(integer)
The user ID of the clientfirst_name
(string)
First name of clientlast_name
(string)
Last name of clientemail
(string)
Email address of clientlast_login
(datetime)
The last login time of the clientevents
(array)
An array of the client’s events stored within MDJM (Event ID => Event date)next_event
(array)
An array containing the ID and date of the client’s next event
Method
The /client/
endpoint accepts both the GET and POST HTTP methods.
Security
The /client/
endpoint requires security validation and therefore your API Key and Token need to be included within the API request. Furthermore, the API will determine whether or not the client_id being specified is indeed that of a client. if it is not, an error will be returned.
Example API Call
To retrieve information for the client with user ID 62, the following would be used;
http://<yoursite.com>/wp-json/mdjm/v1/client/?api_key=03e8d350690c06b6106edc7936bd2b96&token=b35b7c30f56e2975dcc7dc171db90cdb&client_id=62
Response
The response from the above query would look like;
{ "data": { "client": { "first_name": "Jonathan", "last_name": "King", "email": "[email protected]", "login": "[email protected]", "last_login": "2016-07-15 14:42:47", "events": { "7792": "2016-08-27", "8872": "2016-12-31" }, "next_event": { "id": 7791, "date": "2016-08-27" } } }, "headers": { "Content-type": "application/json" }, "status": 200 }