Official Java Onfleet API Wrapper Visit our blog post on the API wrapper project to learn more about our initiatives. If you have any questions, please reach us by submitting an issue here or contact support@onfleet.com.
To use this API wrapper, you need to include it in your Java project. Here's how to do it:
To include your API wrapper as a dependency in a Maven project, add the following dependency to your pom.xml
file:
<dependencies>
<dependency>
<groupId>com.onfleet</groupId>
<artifactId>java-api-wrapper</artifactId>
<version>1.0.0</version> <!-- Use the latest version -->
</dependency>
</dependencies>
For Gradle, you can add the following dependency to your build.gradle
file:
dependencies {
implementation group: 'com.onfleet', name: 'java-api-wrapper', version: '1.0.0' // Use the latest version
}
To use the API wrapper, you need to obtain API credentials from OnFleet's Dashboard. Once you have your credentials, you can set them as environment variables or directly in your Java code.
Create an instance of the OnFleet
class and initialize it with your OnFleet API key:
OnFleet onFleet = new OnFleet("YOUR_API_KEY");
Handle API errors gracefully. If an API request fails, the wrapper will throw an ApiException
that you can catch and handle appropriately.
try {
// Make an API call
onFleet.getOrganizationApi.getOrgDetails();
} catch (ApiException e) {
// Handle the error
System.out.println("API Error: " + e.getMessage());
}