Skip to content

Latest commit

 

History

History
48 lines (35 loc) · 1.3 KB

README.md

File metadata and controls

48 lines (35 loc) · 1.3 KB

OTP GraphQL API Java Client

This library provides an easy way to access OTP's GTFS GraphQL API with Java.

Compatible OTP version

You need at least version 2.4.0 of OpenTripPlanner to use this client.

Installation

Maven Central

It's deployed to Maven Central so add it to your project like this:

<dependency>
   <groupId>org.opentripplanner</groupId>
   <artifactId>otp-client</artifactId>
   <version>${LATEST_VERSION}</version>
</dependency>

Usage

Coordinate ORIGIN = new Coordinate(52.4885, 13.3398);
Coordinate DEST = new Coordinate(52.5211, 13.4106);
OtpApiClient client = new OtpApiClient(ZoneId.of("Europe/Berlin"), "https://example.com");

var result = client.plan(
      TripPlanParameters.builder()
        .withFrom(ORIGIN)
        .withTo(DEST)
        .withTime(LocalDateTime.now())
        .withModes(Set.of(RequestMode.TRANSIT))
        .build()
    );

For more examples take a look at IntegrationTest.java.

Releasing

git tag 0.0.4 -m "Release 0.0.4"
mvn clean deploy
git push --tags