# Client libraries
Client libraries enable easy access to drand randomness in specific programming languages. They also provide peace of mind by verifying randomness rounds and add additional features like failover, racing, aggregation, and caching.
drand randomness is available over HTTP and over libp2p PubSub.
Currently, the following client libraries are available:
- Go (opens new window), to build both PubSub and HTTP clients
- JS (opens new window), to build HTTP clients
- Rust (opens new window), to build HTTP clients
If your application cannot use the libraries above, you can still make requests to the HTTP API endpoints. If you have created a client library or know of a client library not listed here, please let us know by opening an issue (opens new window).
# Go
# Install
go get github.com/drand/drand/v2@latest
# Usage
The Go drand client library is structured with a base client interface in /client
, and with protocol-specific transport implementations in /client/http
, /client/grpc
and /lp2p/client
. The main client
package holds transport agnostic logic for retrying, validation, and caching.
For documentation and examples please check the Go clients reference:
- Transport agnostic top-level client: https://pkg.go.dev/github.com/drand/drand/client (opens new window)
Client implementations (to be used with the above):
- HTTP client: https://pkg.go.dev/github.com/drand/drand/client/http (opens new window)
- libp2p gossip client: https://pkg.go.dev/github.com/drand/drand/lp2p/client (opens new window)
- gRPC client: https://pkg.go.dev/github.com/drand/drand/client/grpc (opens new window)
# JS
# Install
In the browser or Deno (opens new window) you can grab and use the client from a CDN e.g. https://cdn.jsdelivr.net/npm/drand-client/drand.js (opens new window).
In Node.js (opens new window), install with:
npm install drand-client
# Usage
The JS drand client is an esmodule. It has no dependencies and is not transpiled. It can be import
ed directly in the browser, Deno or Node.js. In Node.js it can be imported from CommonJS using await import('...')
.