Skip to content

OpenCageData/jopencage

Repository files navigation

JOpenCage

Maven Central UnitTests Javadoc

security status stability status

This package provides a Java client to the OpenCage Geocoding API: https://opencagedata.com/api

Tutorial

You can find a comprehensive tutorial for using this package on the OpenCage site.

Getting started

Signup for a free-trial API Key.

Usage

Maven

  <dependency>
    <groupId>com.opencagedata</groupId>
    <artifactId>jopencage</artifactId>
    <version>replace.with.version</version>
  </dependency>

Gradle

    implementation "com.opencagedata:jopencage:REPLACE.WITH.VERSION"

Example

Forward

// In real live application the JOpenCageGeocoder should be a Singleton
JOpenCageGeocoder jOpenCageGeocoder = new JOpenCageGeocoder(YOUR_API_KEY);

JOpenCageForwardRequest request = new JOpenCageForwardRequest("Graz");
request.setMinConfidence(1);
request.setNoAnnotations(false);
request.setNoDedupe(true);
JOpenCageResponse response = jOpenCageGeocoder.forward(request);

Reverse

// In real live application the JOpenCageGeocoder should be a Singleton
JOpenCageGeocoder jOpenCageGeocoder = new JOpenCageGeocoder(YOUR_API_KEY);

JOpenCageReverseRequest request = new JOpenCageReverseRequest(-22.6792, 14.5272);
request.setNoAnnotations(true);

JOpenCageResponse response = jOpenCageGeocoder.reverse(request);

Libraries

  • JDK 8+
  • Apache Http Client
  • FasterXml Jackson
  • Slf4j

Testing

For running the tests you have to use your OWN OpenCage Geocoding API Key. Get a free trial key at https://opencagedata.com

./gradlew -DOPENCAGE_API_KEY=<your apikey> test

Gradle

./gradlew wrapper --gradle-version 8.10

Contribute

See Contribution Guidelines.

Changelog

See CHANGELOG.

License

Apache 2.0. Please see LICENSE.

History

Until July 2023 this library was maintained by Michael Oberwasserlechner. At his request due to lack of time to work on it the libary was then taken over by OpenCage GmbH. Thanks, Michael!

Who is OpenCage GmbH?

OpenCage Logo

We run the OpenCage Geocoding API. Learn more about us.

We also run Geomob, a series of regular meetups for location based service creators, where we do our best to highlight geoinnovation. If you like geo stuff, you will probably enjoy the Geomob podcast.