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.
Signup 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"
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);
- JDK 8+
- 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 8.11.1
See 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.