Skip to main content

The Client type

Constructed once per process, shared across all goroutines. Safe for concurrent use.

client, err := ekyc.NewClient(ekyc.Config{
BaseURL: "https://api.drukverify.com",
APIKey: os.Getenv("EKYC_SECRET_KEY"),
Timeout: 30 * time.Second,
})

Config fields

FieldTypeDefaultNotes
BaseURLstring (required)https://api.drukverify.com in production
APIKeystring (required)dv_sk_live_… or dv_sk_test_…
Timeouttime.Duration30sPer-request HTTP timeout
HTTPClient*http.Clientnew pooled clientOverride for tests / custom transport
Headersmap[string]stringnilExtra static headers on every request
APIVersionstringSDK constantPin a specific API version

Namespaces

Client exposes four field namespaces, each constructed eagerly in NewClient:

client.OCR // *OCRClient
client.Face // *FaceClient
client.Liveness // *LivenessClient
client.Sessions // *SessionsClient

Mode parsing

client.Mode is "live" or "test", parsed from the API key prefix. Useful for guardrails:

if isProduction && client.Mode == "test" {
log.Fatal("refusing to start with test key in production")
}

Concurrency

*Client is safe for concurrent use. Construct once in your main, share via dependency injection. The underlying *http.Client is connection-pooled — no need to construct one per request.

Test harness

For unit tests, point BaseURL at a httptest.Server:

srv := httptest.NewServer(/* handler */)
defer srv.Close()

client, _ := ekyc.NewClient(ekyc.Config{
BaseURL: srv.URL,
APIKey: "dv_sk_test_x",
HTTPClient: srv.Client(),
})