- Java 11 or later (uses
java.net.http.HttpClient) - org.json for JSON parsing
- Download
json-20231013.jarfrom Maven Central. - Place it in the
java/folder.
Compile and run:
javac -cp .:json-20231013.jar MotiPhysioClient.java
java -cp .:json-20231013.jar MotiPhysioClient(On Windows replace : with ;)
Add to your pom.xml:
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20231013</version>
</dependency>Add to your build.gradle:
implementation 'org.json:json:20231013'Open MotiPhysioClient.java and edit the three constants at the top:
private static final String BASE_URL = "https://api.motiphysio.com";
private static final String PROGRAM_ID = "YOUR_PROGRAM_ID";
private static final String SECURITY_KEY = "YOUR_SECURITY_KEY";java/
├── MotiPhysioClient.java # All 8 endpoints, zero external HTTP dependency
└── README.md
- Uses the built-in
java.net.http.HttpClient— no third-party HTTP library needed. - A 200 ms sleep is added between requests to stay within the 10 req/s rate limit.
- Business-logic errors (
"error"key in response body) are thrown asRuntimeException. - For production use consider wrapping the calls in a dedicated service class and using Gson or Jackson for type-safe JSON deserialization.