Forked from https://github.com/webdeskltd/dadata.
DaData API v2
Implemented Clean and Suggest methods.
go get github.com/cmazx/dadata/v2
import (
"context"
"fmt"
"github.com/cmazx/dadata/v2"
"github.com/cmazx/dadata/v2/api/suggest"
)
func DaDataExample() {
api := dadata.NewSuggestApi()
params := suggest.RequestParams{
Query: "ул Свободы",
}
suggestions, err := api.Address(context.Background(), ¶ms)
if err != nil {
return
}
for _, s := range suggestions {
fmt.Printf("%s", s.Value)
}
}
DADATA_API_KEY
and DADATA_SECRET_KEY
environment variables are used by default to authenticate client.
Custom credential provider may be used by implementing client.CredentialProvider
interface.
Also, there is a "simple" credential provider client.Credentials
you may utilize.
creds := client.Credentials{
ApiKeyValue: "<YOUR_API_KEY>",
SecretKeyValue: "<YOUR_SECRET_KEY>",
}
api := NewSuggestApi(client.WithCredentialProvider(&creds))
HTTP client may be overridden with custom one:
httpClient := &http.Client{}
api := NewSuggestApi(WithHttpClient(httpClient))
MIT see LICENSE