Skip to main content

Python client for the Bitfinex API

Project description

# Bitfinex Python Client

**Continuation of**:

A Python client for the Bitfinex API v1 and v2 + websockets for v2.

## Installation

pip install bitfinex-v2

## Setup

Install the libs

pip install -r ./requirements.txt

## Documentation

Full documentation coming soon. Please refer to the code to see function
names etc. for now.

## Usage REST API (v2)

from bitfinex import ClientV2 as Client
client = Client(

>>>> [0.00011989,

## Usage Websockets API (v2)

The documentation for bitfinex websockets are somewhat confusing
So expect to spend some time figuring out just what is actually returned
through the authenticated channel.

import os
key = os.environ.get("API_KEY")
secret = os.environ.get("API_SECRET")
from bitfinex.websockets import WssClient
bm = WssClient(key, secret)

# Authenticate and listen to account feedback
# print is the callback method. You probably want to do something else.

# Subscribe to candles (starts with a set of completed candles, then updates with last completed + updated uncompleted candle)
bm.subscribe_to_candles("BTCUSD", "1m", print)

# Send new order
bm.new_order(order_type="EXCHANGE LIMIT", pair="BTCUSD", amount="0.1", price="1", hidden=0)

For sending messages I have only implemented new_order and cancel_order.
I will add documentation for this later, for now take a look at the source code.

## Usage REST API (v1)

from bitfinex import ClientV1 as Client
client = Client(

>>>> { "mid": "562.56495",
"bid": "562.15",
"ask": "562.9799",
"last_price": "562.25",
"volume": "7842.11542563",
"timestamp": "1395552658.339936691"

## Compatibility

This code has been tested on

- Python 3.6

But the REST library will probably work on python 2.7 as well.

I haven’t tested the Websocket library on 2.7

## Tests

When continuing this project (from scottjbarr) I decided to use pytests.

so this should start your tests:

pytest -v

However... Due to the fact that Mocket (python-mocket) crashes whenever
pyopenssl is installed. Tests related to the rest library does now work unless
you uninstall pyopenssl.


- Add the rest of Websocket messages and channels.
- Possible parsing improvement for v2 responses.
- Implement all API calls that Bitfinex make available (v1).

## Contributing

Contributions are welcome and i will do my best to merge PR quickly.

Here are some guidelines that makes everything easier for everybody:

1. Fork it.
1. Create a feature branch containing only your fix or feature.
1. Preferably add/update tests. Features or fixes that don't have good tests won't be accepted before someone adds them (mostly...).
1. Create a pull request.

## References

- This project is a continuation of:
- [](
- [](
- [](

## Licence

The MIT License (MIT)

Copyright (c) 2014-2015 Scott Barr
^ Original project created by this guy.

See [](

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for bitfinex-v2, version 0.4.1
Filename, size File type Python version Upload date Hashes
Filename, size bitfinex_v2-0.4.1-py3-none-any.whl (25.7 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size bitfinex-v2-0.4.1.tar.gz (20.0 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page