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
- Retrieve Orders
- Submit Order
- Order Update
- Cancel Order
- Order Multi-OP
- Cancel Order Multi
- Orders History
- Order Trades
- Trades
- Ledgers
Positions
- Margin Info
- Retrieve Positions
- Claim Position
- Increase Position
- Increase Position Info
- Positions History
- Positions Snapshot
- Positions Audit
- Derivative Position Collateral
- Derivative Position Collateral Limits
Margin Funding
- Active Funding Offers
- Submit Funding Offer
- Cancel Funding Offer
- Cancel All Funding Offers
- Funding Close
- Funding Auto-renew
- Keep Funding
- Funding Offers History
- Funding Loans
- Funding Loans History
- Funding Credits
- Funding Credits History
- Funding Trades
- Funding Info
Account Actions
- User Info
- Summary
- Login History
- Key Permissions
- Generate Token
- Changelog
- Transfer Between Wallets
- Deposit Address
- Generate Invoice
- Withdrawal
- Movements
- Alert List
- Alert Set
- Alert Delete
- Balance Available for Orders/Offers
- User Settings Write
- User Settings Read
- User Settings Delete
Pulse
Merchants
Partner Coupons
Updated 8 months ago