Skip to content

Quick Reference

This page contains quick reference cURL examples for manual shell interaction or simple bash scripting. All examples include explicit request verbs for endpoint disambiguation. For more language examples, visit the static reference prototype, powered by Scalar. Be aware that the Scalar render is currently just a static prototype and cannot access localhost through the hosted client.

For a fully interactive API reference session with the Swagger UI you need to install the service and spin up a server. See the Quickstart Guide for details.






Get A JWT

This example illustrates a basic service call to obtain a JWT.

Terminal window
curl -s --request POST \
--url http://127.0.0.1:3000/v1/login \
--header "Content-Type: application/json" \
--data '{"username": "admin", "password": "apidocpass"}' | jq .

This example does the same thing as the first example, but also creates a shell variable for use in auth headers in subsequent API calls. The example uses tee to split the response, sending the raw JSON response to stderr for visual debugging with jq formatting, and extracts/stores the token fields from successfull calls a variable called TOKEN. Be aware that json_pp does not allow you to parse or further pipe output, so you will need to set shell variables from the API responses some other way.

Terminal window
TOKEN=$(curl -s --request POST \
--url http://127.0.0.1:3000/v1/login \
--header "Content-Type: application/json" \
--data '{"username": "admin", "password": "apidocpass"}' \
| tee >(jq . >&2) | jq -r '.token')

Create A Patient Record

This example illustrates creating a patient record. Some fields are left blank for illustrative purposes.

Terminal window
curl -s --request POST \
--url http://127.0.0.1:3000/v1/patient \
--header "Content-Type: application/json" \
--header "Authorization: Bearer $TOKEN" \
--data '{
"name": {
"first": "Bobson",
"surname": "Dugnutt"
},
"address": {
"address_lines": ["311 Lightning St", "ste 1300"],
"sublocality": "",
"locality": "",
"administrative_area": "",
"postal_code": "97217",
"country_region": "USA"
},
"birth_date": {
"day": 8,
"month": 10,
"year": 1969
}
}' | jq .

Get A Patient Record

This example illustrates retrieving a specific patient record by patient_id.

Terminal window
curl -s --request GET \
--url http://127.0.0.1:3000/v1/patient/a6115489-91b0-4ae7-a453-14a5fe2f6f51 \
--header "Content-Type: application/json" \
--header "Authorization: Bearer $TOKEN" | jq .

List Patient Records

This example returns all records where the patient record’s first_name is Dingus. If you supply no query the service returns all records.


Terminal window
curl -s --request GET \
--url http://127.0.0.1:3000/v1/patient?first_name="Dingus" \
--header "Content-Type: application/json" \
--header "Authorization: Bearer $TOKEN" | jq .

Updates A Patient Record

This example updates a specified patient record to change the US state and postal code in the patient’s address. You can clear out a field by issuing an empty string for the field. You can update all fields but name.first, name.last, and birthdate.


Terminal window
curl -s --request PATCH \
--url http://127.0.0.1:3000/v1/patient/e4cce44f-c0e1-4186-ae60-176d2f3294f1 \
--header "Content-Type: application/json" \
--header "Authorization: Bearer $TOKEN" \
--data '{
"name": {
"first": "Brian"
},
"address": {
"administrative_area": "AK",
"postal_code": "97216"
}
}' | jq .

Delete A Patient Record

This example deletes a specified patient record. The service returns the deleted patient record.


Terminal window
curl -s --request DELETE \
--url http://127.0.0.1:3000/v1/patient/5a32e01a-41b3-45d0-ac8b-9345b5f835c7 \
--header "Content-Type: application/json" \
--header "Authorization: Bearer $TOKEN" | jq .