Skip to content

alexliesenfeld/opencage

Repository files navigation

opencage

An API client implementation for the OpenCage Geocoder API.

Build codecov Go Report Card GolangCI FOSSA Status

Documentation · Report Bug · Request Feature

An API client implementation for the OpenCage Geocoder API. It provides a reverse (latitude/longitude to text) and forward (text to latitude/longitude) geocoding API. Please visit https://opencagedata.com/api for more information.

How to install

go get github.com/alexliesenfeld/opencage

Usage

You can import this package into your application as follows:

import "github.com/alexliesenfeld/opencage"

Use it as follows:

client := New("my-api-key")

// Can be used to control timeouts (e.g., using context.WithDeadline), cancellation, etc.
ctx := context.Background()

// Call the API with default parameters.
// Also shows how to use forward geocoding API using a location.
response, err := client.Geocode(ctx, "Berlin, Germany", nil)

// Or set your own API parameters.
// Also shows how to use reverse geocoding API using latitude and longitude.
response, err := client.Geocode(ctx, "52.3877830 9.7334394", &GeocodingParams{
    RoadInfo:  true,
    Proximity: []float32{1.0, -1.0},
    Language:  "de",
})

Please refer to this file to see more about how the response looks like and what parameters you are able to set.

Legal

Please note that the OpenCage API is property of OpenCage GmbH. Head over to https://opencagedata.com for more information.

License

This library is free software: you can redistribute it and/or modify it under the terms of the MIT Public License.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MIT Public License for more details.

[FOSSA Status]

About

An API client implementation for the OpenCage API

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Languages