This package provides a Java client to the OpenCage Geocoding API: https://opencagedata.com/api
You can find a comprehensive tutorial for using this package on the OpenCage site.
Sign up for a free-trial API Key.
Maven
<dependency>
<groupId>com.opencagedata</groupId>
<artifactId>jopencage</artifactId>
<version>replace.with.version</version>
</dependency>Gradle
implementation "com.opencagedata:jopencage:REPLACE.WITH.VERSION"// 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); // try..catch or throw JOpenCageException// 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); // try..catch or throw JOpenCageExceptionStarting with version 3.x, the methods forward() and reverse() can throw a com.opencagedata.jopencage.JOpenCageException.
https://opencagedata.github.io/jopencage/javadoc/
- JDK 17+
- Apache Http Client
- FasterXml Jackson
- Slf4j
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./gradlew wrapper --gradle-version 9.2.1See CHANGELOG.
Apache 2.0. Please see LICENSE.
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!
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.