Binance API
api.binance.com · Finance
World's largest crypto exchange by volume — real-time prices, order books, trades, OHLCV candles, account management, and order execution. Free API key, testnet available.
Authentication
API Key
Free API key from binance.com/en/my/settings/api-management. Public market data needs no key. Trading needs key+secret passed as X-MBX-APIKEY header.
Sample Requests
GET
Get BTC price
Get current Bitcoin price in USDT. No API key needed.
https://api.binance.com/api/v3/ticker/price?symbol=BTCUSDT
Hover any highlighted part to learn what it does
curl -X GET "https://api.binance.com/api/v3/ticker/price?symbol=BTCUSDT"
import requests
params = {
"symbol": "BTCUSDT"
}
response = requests.get(
"https://api.binance.com/api/v3/ticker/price",
params=params,
)
print(response.json())const url = new URL('https://api.binance.com/api/v3/ticker/price');
url.searchParams.set('symbol', 'BTCUSDT');
const response = await fetch(url);
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
baseURL, _ := url.Parse("https://api.binance.com/api/v3/ticker/price")
q := baseURL.Query()
q.Set("symbol", "BTCUSDT")
baseURL.RawQuery = q.Encode()
targetURL := baseURL.String()
req, _ := http.NewRequest("GET", targetURL, nil)
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://api.binance.com/api/v3/ticker/price")
uri.query = URI.encode_www_form({
"symbol" => "BTCUSDT"
})
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.binance.com/api/v3/ticker/price?" . http_build_query([
"symbol" => "BTCUSDT"
]);
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));
GET
Get candlestick data
Get 24 hours of hourly ETH/USDT candles.
https://api.binance.com/api/v3/klines?limit=24&symbol=ETHUSDT&interval=1h
Hover any highlighted part to learn what it does
curl -X GET "https://api.binance.com/api/v3/klines?limit=24&symbol=ETHUSDT&interval=1h"
import requests
params = {
"limit": "24",
"symbol": "ETHUSDT",
"interval": "1h"
}
response = requests.get(
"https://api.binance.com/api/v3/klines",
params=params,
)
print(response.json())const url = new URL('https://api.binance.com/api/v3/klines');
url.searchParams.set('limit', '24');
url.searchParams.set('symbol', 'ETHUSDT');
url.searchParams.set('interval', '1h');
const response = await fetch(url);
const data = await response.json();
console.log(data);package main
import (
"fmt"
"io"
"net/http"
"net/url"
)
func main() {
baseURL, _ := url.Parse("https://api.binance.com/api/v3/klines")
q := baseURL.Query()
q.Set("limit", "24")
q.Set("symbol", "ETHUSDT")
q.Set("interval", "1h")
baseURL.RawQuery = q.Encode()
targetURL := baseURL.String()
req, _ := http.NewRequest("GET", targetURL, nil)
client := &http.Client{}
resp, _ := client.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Println(string(body))
}require "net/http"
require "json"
uri = URI("https://api.binance.com/api/v3/klines")
uri.query = URI.encode_www_form({
"limit" => "24",
"symbol" => "ETHUSDT",
"interval" => "1h"
})
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = uri.scheme == "https"
req = Net::HTTP::Get.new(uri)
res = http.request(req)
puts JSON.parse(res.body)<?php
$url = "https://api.binance.com/api/v3/klines?" . http_build_query([
"limit" => "24",
"symbol" => "ETHUSDT",
"interval" => "1h"
]);
$opts = ["http" => [
"method" => "GET",
]];
$ctx = stream_context_create($opts);
$res = file_get_contents($url, false, $ctx);
print_r(json_decode($res, true));Postman Setup Guide
- Public data needs no API key
- Try GET https://api.binance.com/api/v3/ticker/price?symbol=BTCUSDT
- All symbols: GET /api/v3/ticker/price (returns all ~2000 pairs)
- Order book: GET /api/v3/depth?symbol=BTCUSDT&limit=5
- Testnet for trading: testnet.binance.vision (free)