{"id":22621667,"url":"https://github.com/larscom/bitvavo-go","last_synced_at":"2025-04-11T16:39:14.571Z","repository":{"id":246858415,"uuid":"823975069","full_name":"larscom/bitvavo-go","owner":"larscom","description":"GO thread safe library (WebSockets / HTTP) for Bitvavo","archived":false,"fork":false,"pushed_at":"2025-03-15T12:23:20.000Z","size":80,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-25T12:50:56.817Z","etag":null,"topics":["api","binance","bitvavo","broker","crypto","cryptocurrency","exchange","go","golang","http","rest","websockets","ws"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/larscom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-04T05:57:16.000Z","updated_at":"2025-03-15T12:23:04.000Z","dependencies_parsed_at":"2024-07-12T05:26:25.807Z","dependency_job_id":"1ff4e1fb-51d6-4b56-9cc8-35f997d44f3e","html_url":"https://github.com/larscom/bitvavo-go","commit_stats":null,"previous_names":["larscom/bitvavo-go"],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larscom%2Fbitvavo-go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larscom%2Fbitvavo-go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larscom%2Fbitvavo-go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/larscom%2Fbitvavo-go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/larscom","download_url":"https://codeload.github.com/larscom/bitvavo-go/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248441900,"owners_count":21104097,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","binance","bitvavo","broker","crypto","cryptocurrency","exchange","go","golang","http","rest","websockets","ws"],"created_at":"2024-12-08T23:11:20.254Z","updated_at":"2025-04-11T16:39:14.547Z","avatar_url":"https://github.com/larscom.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BITVAVO-GO\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/larscom/bitvavo-go)](https://goreportcard.com/report/github.com/larscom/bitvavo-go)\n[![Go Reference](https://pkg.go.dev/badge/github.com/larscom/bitvavo-go.svg)](https://pkg.go.dev/github.com/larscom/bitvavo-go)\n\n\u003e GO **thread safe** library (WebSockets / HTTP) for Bitvavo v2 API (see: https://docs.bitvavo.com)\n\nListen to all events occurring on the Bitvavo platform (tickers, tickers24h, candles, books, trades, orders, fills)\nusing websockets. With the HTTP client you can do things like placing orders or withdraw assets from your account.\n\n## 📒 Features\n\n- WebSocket Listeners -- Read only\n    - Book\n    - Candles\n    - Trades\n    - Ticker\n    - Ticker 24h\n    - Orders/Fills\n- HTTP Client -- Read / Write\n    - Market data endpoints\n    - Account endpoints\n    - Synchronization endpoints\n    - Trading endpoints\n    - Transfer endpoints\n\n## 🚀 Installation\n\n```shell\ngo get github.com/larscom/bitvavo-go/v2@latest\n```\n\n## 💡 Usage\n\n```shell\nimport \"github.com/larscom/bitvavo-go/v2/pkg/bitvavo\"\n```\n\n## 👂 WebSocket\n\nFor each event on the Bitvavo platform there is a listener available. A listener wraps a websocket connection, you can\nalso implement your own wrapper arround the websocket. The listeners handle everything for you, like resubscribing and\nreauthenticating when the connection has been lost.\n\n### Public listeners\n\n- BookListener\n- CandlesListener\n- TickerListener\n- Ticker24hListener\n- TradesListener\n\n```go\npackage main\n\nimport \"github.com/larscom/bitvavo-go/v2/pkg/bitvavo\"\n\nfunc main() {\n\t// listen for candle (public) events\n\tlistener := bitvavo.NewCandlesListener()\n\tdefer listener.Close()\n\n\tchn, err := listener.Subscribe([]string{\"ETH-EUR\"}, []bitvavo.Interval{bitvavo.Interval1m})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfor event := range chn {\n\t\tif event.Error != nil {\n\t\t\tpanic(event.Error)\n\t\t}\n\t\tlog.Println(event.Value)\n\t}\n}\n\n```\n\n### Private listeners\n\n- OrderListener\n- FillListener\n\n```go\npackage main\n\nimport \"github.com/larscom/bitvavo-go/v2/pkg/bitvavo\"\n\nfunc main() {\n\t// listen for order (private) events\n\tlistener := bitvavo.NewOrderListener(\"MY_API_KEY\", \"MY_API_SECRET\")\n\tdefer listener.Close()\n\n\tchn, err := listener.Subscribe([]string{\"ETH-EUR\"})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tfor event := range chn {\n\t\tif event.Error != nil {\n\t\t\tpanic(event.Error)\n\t\t}\n\t\tlog.Println(event.Value)\n\t}\n}\n\n```\n\n### Provide debug printer\n\nYou can add the debug printer option to enable debug logging for websockets. There is a default printer, but you can\nalso provide your own as long as it implements the `DebugPrinter` interface.\n\n```go\npackage main\n\nimport \"github.com/larscom/bitvavo-go/v2/pkg/bitvavo\"\n\nfunc main() {\n\tlistener := bitvavo.NewCandlesListener(bitvavo.WithWebSocketDefaultDebugPrinter())\n}\n\n```\n\n### Provide Http client for websocket\n\nYou can provide your own http client from the `net/http` package which will be used to set up the initial websocket connection.\n\n```go\npackage main\n\nimport (\n\t\"net/http\"\n\t\"github.com/larscom/bitvavo-go/pkg/bitvavo/v2\"\n)\n\nfunc main() {\n\tlistener := bitvavo.NewCandlesListener(bitvavo.WithWebSocketHttpClient(http.DefaultClient))\n}\n\n```\n\n### Create custom listener\n\nIt's possible to create your own wrapper arround the websocket and listen to multiple events at the same time.\n\n```go\npackage main\n\nimport \"github.com/larscom/bitvavo-go/v2/pkg/bitvavo\"\n\nfunc main() {\n\tonMessage := func(data bitvavo.WebSocketEventData, err error) {\n\t\tif err != nil {\n\t\t\t// oh no error!\n\t\t} else if data.Event == bitvavo.EventBook {\n\t\t\t// decode into Book\n\t\t\tvar book bitvavo.Book\n\t\t\tdata.Decode(\u0026book)\n\t\t} else if data.Event == bitvavo.EventCandle {\n\t\t\t// decode into Candle\n\t\t\tvar candle bitvavo.Candle\n\t\t\tdata.Decode(\u0026candle)\n\t\t}\n\t\t// etc\n\t}\n\n\tonReconnect := func() {\n\t\t// gets called when successfully reconnected\n\t}\n\n\tws, err := bitvavo.NewWebSocket(context.Background(), onMessage, onReconnect)\n\t// do stuff with ws\n}\n```\n\n## 🌐 HTTP\n\nThe HTTP client implements 2 interfaces (PrivateAPI and PublicAPI)\n\nIf you need both private and public endpoints you can create a private http client as it includes both public and\nprivate endpoints.\n\n### Private and Public endpoints\n\n```go\npackage main\n\nimport \"github.com/larscom/bitvavo-go/v2/pkg/bitvavo\"\n\nfunc main() {\n\t// private http client (includes public as well)\n\tclient := bitvavo.NewPrivateHTTPClient(\"MY_API_KEY\", \"MY_API_SECRET\")\n\n\torders, err := client.GetOrders(context.Background(), \"ETH-EUR\")\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tlog.Println(\"Orders\", orders)\n}\n\n```\n\n### Public endpoints only\n\n```go\npackage main\n\nimport \"github.com/larscom/bitvavo-go/v2/pkg/bitvavo\"\n\nfunc main() {\n\t// public http client\n\tclient := bitvavo.NewPublicHTTPClient()\n\n\tmarkets, err := client.GetMarkets(context.Background())\n\tif err != nil {\n\t\tlog.Fatal(err)\n\t}\n\tlog.Println(\"Markets\", markets)\n}\n\n```\n\n### Endpoints with params\n\nSome endpoints have additional params which you can provide.\n\n```go\npackage main\n\nimport \"github.com/larscom/bitvavo-go/v2/pkg/bitvavo\"\n\nfunc main() {\n\tclient := bitvavo.NewPublicHTTPClient()\n\n\t// limit to 100 trades\n\tparams := \u0026bitvavo.TradeParams{\n\t\tLimit: 100,\n\t}\n\ttrades, err := client.GetTrades(context.Background(), \"ETH-EUR\", params)\n}\n\n```\n\n### Provide HTTP client\n\nYou can provide your own http client from the `net/http` package which will be used to execute all requests.\n\n```go\npackage main\n\nimport (\n\t\"net/http\"\n\t\"github.com/larscom/bitvavo-go/pkg/bitvavo/v2\"\n)\n\nfunc main() {\n\tclient := bitvavo.NewPublicHTTPClient(bitvavo.WithHttpClient(http.DefaultClient))\n}\n\n```\n\n### Provide window time\n\nYou can provide your own window time which specifies the maximum allowed deviation (in milliseconds) between the\ntimestamp you sent and the server's actual time when processing your request.\n\nThe default window time is: `10000` (10 seconds)\n\n```go\npackage main\n\nimport (\n\t\"github.com/larscom/bitvavo-go/pkg/bitvavo/v2\"\n)\n\nfunc main() {\n\tclient := bitvavo.NewPrivateHTTPClient(\"MY_API_KEY\", \"MY_API_SECRET\", bitvavo.WithWindowTime(5000))\n}\n\n```\n\n### Provide debug printer\n\nYou can add the debug printer option to enable debug logging for http. There is a default printer, but you can\nalso provide your own as long as it implements the `DebugPrinter` interface.\n\n```go\npackage main\n\nimport (\n\t\"github.com/larscom/bitvavo-go/pkg/bitvavo/v2\"\n)\n\nfunc main() {\n\tclient := bitvavo.NewPrivateHTTPClient(\"MY_API_KEY\", \"MY_API_SECRET\", bitvavo.WithDefaultDebugPrinter())\n}\n\n```\n\n## 👉🏼 Run example\n\nThere is an example that uses the ticker listener for ticker events\nand HTTP client to retrieve the trading markets.\n\nYou can run this example by cloning this project and running:\n\n`make run` or without make: `go run ./example/main.go`\n\nThis command will subscribe to all available trading markets and log the received tickers.\n\n### Private\n\nIf you want to test private endpoints and listeners you can place a `.env` file in the root of the project.\n\n\u003e .env file\n\n```shell\nAPI_KEY=MY_API_KEY\nAPI_SECRET=MY_API_SECRET\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flarscom%2Fbitvavo-go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flarscom%2Fbitvavo-go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flarscom%2Fbitvavo-go/lists"}