https://github.com/opencagedata/jopencage
OpenCage geocoding client for Java
https://github.com/opencagedata/jopencage
Last synced: 6 months ago
JSON representation
OpenCage geocoding client for Java
- Host: GitHub
- URL: https://github.com/opencagedata/jopencage
- Owner: OpenCageData
- License: apache-2.0
- Created: 2023-07-04T20:50:12.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2025-09-28T13:46:00.000Z (6 months ago)
- Last Synced: 2025-09-28T15:50:57.872Z (6 months ago)
- Language: Java
- Homepage:
- Size: 965 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# JOpenCage
[](https://central.sonatype.com/artifact/com.opencagedata/jopencage)
[](https://github.com/OpenCageData/jopencage/actions)
[](https://OpenCageData.github.io/jopencage/javadoc/)
[](https://www.meterian.io/report/gh/OpenCageData/jopencage)
[](https://www.meterian.io/report/gh/OpenCageData/jopencage)
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](https://opencagedata.com/tutorials/geocode-in-java).
## Getting started
Signup for a [free-trial API Key](https://opencagedata.com/users/sign_up).
## Usage
**Maven**
```xml
com.opencagedata
jopencage
replace.with.version
```
**Gradle**
```gradle
implementation "com.opencagedata:jopencage:REPLACE.WITH.VERSION"
```
### Example
Forward
```java
// 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
```java
// 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= test
```
## Gradle
```bash
./gradlew wrapper --gradle-version 9.0.0
```
## Contribute
See [Contribution Guidelines](https://github.com/OpenCageData/jopencage/blob/master/.github/CONTRIBUTING.md).
## Changelog
See [CHANGELOG](https://github.com/OpenCageData/jopencage/blob/master/CHANGELOG.md).
## License
Apache 2.0. Please see [LICENSE](jopencage/blob/master/LICENSE).
## History
Until July 2023 this library was maintained by [Michael Oberwasserlechner](https://github.com/moberwasserlechner). 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?
[](https://opencagedata.com)
We run the [OpenCage Geocoding API](https://opencagedata.com/api). Learn more [about us](https://opencagedata.com/about).
We also run [Geomob](https://thegeomob.com), 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](https://thegeomob.com/podcast/).