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
| Field | Type | Default | Notes |
|---|---|---|---|
BaseURL | string (required) | — | https://api.drukverify.com in production |
APIKey | string (required) | — | dv_sk_live_… or dv_sk_test_… |
Timeout | time.Duration | 30s | Per-request HTTP timeout |
HTTPClient | *http.Client | new pooled client | Override for tests / custom transport |
Headers | map[string]string | nil | Extra static headers on every request |
APIVersion | string | SDK constant | Pin 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(),
})