/?

Introduction

The Bitfinex API’s are designed to allow access to all of the features of the Bitfinex platform. The end goal is to allow people to potentially recreate the entire platform on their own.

If you would like to suggest changes to the documentation, please see the github at https://github.com/bitfinexcom/api_docs

Open Source Libraries

The following open source projects are works in progress. We will be continually improving them, but we want to release them early so that the community can take a look, make use of them, and offer pull requests. Nothing in the Bitcoin world exists in isolation.

Get Started    

Authenticated Endpoints

URL

Authenticated endpoints should use the domain:
https://api.bitfinex.com

All authenticated examples assume the following:

  • You are using the ‘fetch’ HTTP library
  • You are using your API key and API Secret key
  • Your “signature”, “sig” and “nonce” variables follow the same format that is listed below
  • Your "headers" follow the same format listed below and include the 'Content-Type', ‘bfx-nonce’, ‘bfx-apikey’, and ‘bfx-signature’.

Below is the example code for authenticated endpoints. The example code uses the v2/auth/r/wallets endpoint.

const CryptoJS = require('crypto-js') // Standard JavaScript cryptography library
const fetch = require('node-fetch') // "Fetch" HTTP req library

const apiKey = '' // const apiKey = 'paste key here'
const apiSecret = '' // const apiSecret = 'paste secret here'

const apiPath = 'v2/auth/r/wallets'// Example path

const nonce = (Date.now() * 1000).toString() // Standard nonce generator. Timestamp * 1000
const body = {
} // Field you may change depending on endpoint

let signature = `/api/${apiPath}${nonce}${JSON.stringify(body)}` 
// Consists of the complete url, nonce, and request body

const sig = CryptoJS.HmacSHA384(signature, apiSecret).toString() 
// The authentication signature is hashed using the private key

fetch(`https://api.bitfinex.com/${apiPath}`, {
  method: 'POST',
  body: JSON.stringify(body),
  headers: {
    'Content-Type': 'application/json',
    'bfx-nonce': nonce,
    'bfx-apikey': apiKey,
    'bfx-signature': sig
  }
})
.then(res => res.json())
.then(json => console.log(json)) //Logs the response body
.catch(err => {
    console.log(err)
 })

Path and Path Parameters

If you wish to retrieve data from or send data to a different endpoint, simply change the apiPath variable in the example code. Any Path Parameters that you would like to use are appended to the apiPath variable.

Form Data and Query Parameters

Other parameters (listed in the documentation as “Form Data” or “Query Params”) are added to the body object as key: value pairs. Here’s an example of the code used to place an order through the API using "v2/auth/w/order/submit” and a body object:

const CryptoJS = require('crypto-js') // Standard JavaScript cryptography library
const fetch = require('node-fetch') // "Fetch" HTTP req library
   
const apiKey = '' // const apiKey = 'paste key here'
const apiSecret = '' // const apiSecret = 'paste secret here'

const apiPath = 'v2/auth/w/order/submit'// Example path

const nonce = (Date.now() * 1000).toString() // Standard nonce generator. Timestamp * 1000
const body = {
        type: 'LIMIT',
    symbol: 'tBTCUSD',
    price: '15',
    amount: '0.1'
} // Field you may change depending on endpoint

let signature = `/api/${apiPath}${nonce}${JSON.stringify(body)}` 
// Consists of the complete url, nonce, and request body

const sig = CryptoJS.HmacSHA384(signature, apiSecret).toString() 
// The authentication signature is hashed using the private key

fetch(`https://api.bitfinex.com/${apiPath}`, {
  method: 'POST',
  body: JSON.stringify(body),
  headers: {
    'Content-Type': 'application/json',
    'bfx-nonce': nonce,
    'bfx-apikey': apiKey,
    'bfx-signature': sig
  }
})
.then(res => res.json())
.then(json => console.log(json)) //Logs the response body
.catch(err => {
    console.log(err)
 })

REST Authenticated Endpoints

Wallets

Orders

Positions

Margin Funding

Account Actions

Updated 5 months ago

Authenticated Endpoints


Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.