FHIR API
Clients and tools
curl and jq, Postman, the HAPI web UI and Swagger: what each is good for and how to set it up against this lab.
curl and jq#
Every example in these docs uses curl and jq, because they show exactly what goes over the wire.
# A handy shell function: fhir GET Patient?family=x
fhir() { local m=$1; shift; curl -s -X "$m" "$FHIR/$1" -H "Content-Type: application/fhir+json" "${@:2}" | jq; }
fhir GET 'Patient?_count=1'
fhir POST Patient -d @patient.jsonInstall jq where you run the commands: sudo apt install jq on Debian (including the lab box, which doesn't have it yet) or winget install jqlang.jq on Windows. On Windows, also use curl.exe, because PowerShell's curl is an alias for Invoke-WebRequest.
Postman#
Create an environment#
Add the variable base = http://192.168.1.181:8080/fhir for the LAN, or https://fhir.fhirdrill.dev/fhir for outside.
For outside access, add the service token headers#
At collection level: CF-Access-Client-Id and CF-Access-Client-Secret. See Call the API from outside.
Set the default content type#
Collection → Headers: Content-Type: application/fhir+json.
HAPI web UI#
http://192.168.1.181:8080/ (or https://fhir.fhirdrill.dev/) is HAPI's built-in tester. You can browse resource types, fill in search forms, view raw responses and run operations. It's handy for exploring, but it hides the HTTP details, so build the habit with curl or Postman.
Swagger UI#
/fhir/swagger-ui/ shows every endpoint the server exposes, generated from the CapabilityStatement, and lets you try them. The raw OpenAPI document is at /fhir/api-docs, and you can import it into Postman.
VS Code#
- REST Client (humao.rest-client): save requests in
.httpfiles next to your notes. - FHIR Shorthand (MITRE): syntax highlighting for
.fshprofile files. - A JSON schema for FHIR R4 is published at
https://hl7.org/fhir/R4/fhir.schema.json. Point VS Code at it for autocomplete when you hand-write resources.