# bitfinex > Bitfinex cryptocurrency exchange API for trading, funding, wallets, and market data. Supports REST and WebSocket APIs for both public and authenticated endpoints. Use this skill when integrating with Bitfinex exchange for trading bots, portfolio management, or market data analysis. - Author: John Chang - Repository: JOHNBASS/bitfinex-api-skill - Version: 20260123112339 - Stars: 0 - Forks: 0 - Last Updated: 2026-02-06 - Source: https://github.com/JOHNBASS/bitfinex-api-skill - Web: https://mule.run/skillshub/@@JOHNBASS/bitfinex-api-skill~bitfinex:20260123112339 --- --- name: bitfinex description: Bitfinex cryptocurrency exchange API for trading, funding, wallets, and market data. Supports REST and WebSocket APIs for both public and authenticated endpoints. Use this skill when integrating with Bitfinex exchange for trading bots, portfolio management, or market data analysis. --- # Bitfinex API Skill Comprehensive API documentation for Bitfinex cryptocurrency exchange, covering REST and WebSocket APIs for trading, funding, and market data. ## When to Use This Skill This skill should be triggered when: - Building trading bots or automated trading systems for Bitfinex - Integrating Bitfinex market data into applications - Managing cryptocurrency portfolios on Bitfinex - Implementing margin trading or funding operations - Working with WebSocket real-time data streams - Querying order books, trades, tickers, or candles - Managing deposits, withdrawals, and wallet operations ## Quick Reference ### Base URLs ``` REST Public: https://api-pub.bitfinex.com/v2 REST Auth: https://api.bitfinex.com/v2 WebSocket: wss://api.bitfinex.com/ws/2 ``` ### Authentication All authenticated endpoints require: - **API Key**: Your Bitfinex API key - **API Secret**: Your Bitfinex API secret - **Signature**: HMAC-SHA384 signature of the payload - **Nonce**: Unique timestamp for each request ```javascript // Authentication header example const crypto = require('crypto'); const apiKey = 'YOUR_API_KEY'; const apiSecret = 'YOUR_API_SECRET'; const nonce = Date.now().toString(); const body = {}; const signature = `/api/v2${path}${nonce}${JSON.stringify(body)}`; const sig = crypto.createHmac('sha384', apiSecret).update(signature).digest('hex'); headers = { 'bfx-nonce': nonce, 'bfx-apikey': apiKey, 'bfx-signature': sig, 'content-type': 'application/json' }; ``` ### Symbol Format - **Trading pairs**: Prepend with 't' (e.g., `tBTCUSD`, `tETHBTC`) - **Funding currencies**: Prepend with 'f' (e.g., `fUSD`, `fBTC`) - **Derivatives**: Use format `tBTCF0:USTF0` ### Common REST Endpoints | Endpoint | Method | Description | |----------|--------|-------------| | `/v2/platform/status` | GET | Platform operational status | | `/v2/tickers` | GET | Multiple tickers | | `/v2/ticker/{symbol}` | GET | Single ticker | | `/v2/trades/{symbol}/hist` | GET | Historical trades | | `/v2/book/{symbol}/{precision}` | GET | Order book | | `/v2/candles/trade:{timeframe}:{symbol}/{section}` | GET | OHLCV candles | | `/v2/auth/r/wallets` | POST | User wallets | | `/v2/auth/r/orders` | POST | Active orders | | `/v2/auth/w/order/submit` | POST | Submit new order | | `/v2/auth/w/order/cancel` | POST | Cancel order | ### Candle Timeframes Available timeframes for candles endpoint: - `1m`, `5m`, `15m`, `30m` (minutes) - `1h`, `3h`, `6h`, `12h` (hours) - `1D`, `1W`, `1M` (day, week, month) ### Order Types | Type | Description | |------|-------------| | `LIMIT` | Limit order at specified price | | `MARKET` | Market order at best available price | | `STOP` | Stop order triggered at stop price | | `STOP LIMIT` | Stop limit order | | `TRAILING STOP` | Trailing stop order | | `FOK` | Fill or Kill | | `IOC` | Immediate or Cancel | ### WebSocket Subscription Example ```javascript // Subscribe to ticker channel const ws = new WebSocket('wss://api.bitfinex.com/ws/2'); ws.on('open', () => { ws.send(JSON.stringify({ event: 'subscribe', channel: 'ticker', symbol: 'tBTCUSD' })); }); ws.on('message', (data) => { const msg = JSON.parse(data); console.log(msg); }); ``` ### WebSocket Channels | Channel | Description | |---------|-------------| | `ticker` | Real-time ticker updates | | `trades` | Real-time trade executions | | `book` | Order book updates | | `candles` | Real-time OHLCV updates | | `status` | Derivatives status | ### Rate Limits - **REST API**: 90 requests/minute for public endpoints - **Authenticated**: Varies by endpoint - **WebSocket**: 20 subscriptions per connection ## Reference Files This skill includes comprehensive documentation in `references/`: ### Getting Started - **getting_started.md** - Introduction, requirements, limitations, and setup guides ### REST API - Public - **rest_public.md** - Public endpoints (29 pages): tickers, trades, order books, candles, stats, derivatives status, liquidations, leaderboards, funding stats ### REST API - Authenticated - **rest_auth_orders.md** - Order management (11 pages): submit, update, cancel orders, order history, order trades - **rest_auth_positions.md** - Position management (10 pages): positions, claims, increase, history, audit, collateral - **rest_auth_funding.md** - Funding operations (14 pages): offers, loans, credits, auto-renew, funding info - **rest_auth_account.md** - Account management (14 pages): wallets, user info, summary, login history, settings - **rest_auth_transfers.md** - Transfers (9 pages): deposits, withdrawals, movements, Thalex integration - **rest_auth_alerts.md** - Price alerts (3 pages): create, delete, list alerts ### WebSocket API - **websocket_general.md** - General WebSocket documentation (4 pages) - **websocket_public.md** - Public channels: ticker, trades, books, candles, status - **websocket_auth.md** - Authenticated channels (6 pages): orders, positions, wallets, funding, notifications ### Additional Resources - **rest_general.md** - General REST API information - **other.md** - Changelog, glossary, flag values, deprecated endpoints ## Key Concepts ### Array Format Responses Bitfinex API returns data in array format for efficiency: ```javascript // Ticker response: [BID, BID_SIZE, ASK, ASK_SIZE, DAILY_CHANGE, DAILY_CHANGE_RELATIVE, LAST_PRICE, VOLUME, HIGH, LOW] [6935.2, 100.5, 6936, 150.3, -150, -0.0211, 6935.5, 15000, 7100, 6800] ``` ### Abbreviations Common abbreviations used in responses: - `mts` - Millisecond timestamp - `qty` - Quantity - `px` - Price - `amt` - Amount - `pos` - Position - `exec` - Execution ### Flag Values Order flags (bitwise OR to combine): - `64` - Hidden order - `512` - Close position - `4096` - Post-only - `16384` - Reduce-only ## Working with This Skill ### For Trading Bot Development 1. Start with `rest_auth_orders.md` for order management 2. Use `websocket_public.md` for real-time market data 3. Reference `rest_auth_positions.md` for position tracking ### For Market Data Integration 1. Use `rest_public.md` for historical data queries 2. Subscribe to WebSocket channels for real-time updates 3. Check `candles` endpoint for OHLCV data ### For Portfolio Management 1. Reference `rest_auth_account.md` for wallet operations 2. Use `rest_auth_transfers.md` for deposits/withdrawals 3. Monitor positions with `rest_auth_positions.md` ## Code Examples ### Get Ticker ```bash curl "https://api-pub.bitfinex.com/v2/ticker/tBTCUSD" ``` ### Get Order Book ```bash curl "https://api-pub.bitfinex.com/v2/book/tBTCUSD/P0" ``` ### Get Candles ```bash curl "https://api-pub.bitfinex.com/v2/candles/trade:1h:tBTCUSD/hist?limit=100" ``` ### Submit Order (Authenticated) ```python import hashlib import hmac import json import requests import time api_key = 'YOUR_API_KEY' api_secret = 'YOUR_API_SECRET' nonce = str(int(time.time() * 1000)) body = { 'type': 'LIMIT', 'symbol': 'tBTCUSD', 'amount': '0.01', 'price': '50000' } path = '/v2/auth/w/order/submit' signature = f'/api{path}{nonce}{json.dumps(body)}' sig = hmac.new(api_secret.encode(), signature.encode(), hashlib.sha384).hexdigest() headers = { 'bfx-nonce': nonce, 'bfx-apikey': api_key, 'bfx-signature': sig, 'content-type': 'application/json' } response = requests.post(f'https://api.bitfinex.com{path}', headers=headers, json=body) print(response.json()) ``` ## Resources - **Official Documentation**: https://docs.bitfinex.com - **API Status**: https://api-pub.bitfinex.com/v2/platform/status - **Open Source Libraries**: Check `getting_started.md` for official SDK links ## Notes - This skill was automatically generated from 122 pages of official Bitfinex documentation - Reference files preserve the structure and examples from source docs - Includes both current and deprecated endpoints for backwards compatibility - Last updated: January 2025