From 104b87df05931018eea44989a7ba8024f627798a Mon Sep 17 00:00:00 2001 From: David Beauchamp Date: Sun, 12 Feb 2023 01:25:47 -0800 Subject: [PATCH] Update README.md --- README.md | 48 +++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4c2201b..e7f635c 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,55 @@ # Go Defined.fi API Client -A client library for accessing Defined.fi graphql api +A client library for accessing [Defined.fi's](www.defined.fi) realtime graphql api ## Installation ```bash go get -u github.com/dbeauchamp/go-defined ``` + +## Usage +You'll need a Defined API Key. See instructions here: [defined docs](www.defined.fi) + +```go +package main + +import ( + "fmt" + "os" + + "github.com/dbeauchamp/go-defined/pkg/wsclient" +) + +func main() { + // Your api key + ws := wsclient.New(os.Getenv("DEFINED_API_KEY")) + + // Subscribe to events + msgCh, doneCh, err := ws.SubscribeToPairEvents( + wsclient.PairEventsSubscriptionArgs{ + Id: "0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640:1", // WETH/USDC + }, + ) + if err != nil { + ... + } + + // Do something fun! + for msg := range *msgCh { + fmt.Println(*msg.Maker) + } + + // Unsubscribe + *doneCh <- struct{}{} + + // Close connection + ws.Close() +} +``` + +## License +MIT + +## Contributing +Contributions are welcome!