-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f895c4f
commit 104b87d
Showing
1 changed file
with
47 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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! |