Image for post
Image for post

bitmexgo: a golang library for Bitmex REST APIs

Zhen Wang
Zhen Wang
Oct 25, 2018 · 2 min read

I’ve open-sourced bitmexgo, a golang package that enables clients to call REST APIs for the Bitmex crypto trading platform. You may use it to analyze the most liquid crypto futures market or develop trading bots in Go.

Bitmex’s official golang library, which is automatically generated by swagger-codegen, turns out to be nonfunctional: due to its broken authentication flow, none of the APIs works at all. Ideally the bugs should be fixed at the swagger layer, but it appears to be a pretty thorny problem. Therefore I directly applied patches on top of the auto-generated code and created this new bitmexgo package.

In addition to bug fixes, I’ve rubbed out all external dependencies from the original code base to make bitmexgo leaner and self-contained.

To install the package, run the following shell command:

Apart from a few simplifications here and there, bitmexgo’s API adheres to the original interface quite faithfully. For example:

The swagger-generated code contains no tests, neither does the bitmexgo package. I have, however, manually tested many of its APIs in a side project without any issues.

As required by Bitmex, bitmexgo needs an API key/secret pair to work, which can be created at https://www.bitmex.com/app/apiKeys.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store