NAV Navbar
shell javascript java python php ruby
  • 概述
  • REST API 概述
  • WebSocket API 概述
  • 交易所收录
  • 概述

    简介

    Block.cc是专业的区块链产业信息服务平台,提供数字货币行情、数据、资讯等一站式区块链产业服务,追求更及时、更全面、更专业、更准确的行情数据,致力为区块链爱好者和数字货币投资者提供最权威最流畅的产品和服务。

    第三方应用开发者可以借助该服务,快速构建稳定高效的数字货币行情系统,为实时业务需求和产品运营提供技术支持。

    当前版本

    API Endpoint: https://data.block.cc/api/v1
    

    请求限制

    为了提供更高服务质量,限制每分钟请求次数为120次。如果某个IP地址每分钟请求次数超过120次,则该请求的IP地址将在该端点上被阻止1-60秒,并且返回HTTP状态码429。

    变量规则

    变量命名

    所有变量都使用蛇形命名法(snake_case)约定命名。这意味着单词由一个下划线_字符分隔,不使用空格,字母为小写。

    交易货币 Symbol

    Symbol 为交易货币,由符号(symbol)与名称(symbol_name)组成。

    如 bitcoin(BTC), ethereum(ETH)。

    通过 Symbols API 可以获取币种列表。

    基础货币 Currency

    Currency 为基础货币, 以货币符号表示(如:USD)。 包含法币以及作为普遍作为基础货币的数组货币(如: USDT,BTC,ETH)。

    通过 Currencies API 可以获取币种列表。

    交易对 SymbolPair

    交易对(SymbolPair)由Symbol符号和Currency组成,由下划线分割。

    symbol + 下划线(_) + currency

    交易对均为大写。

    如:BTC_USD, ETH_USD

    通过 Market API 可以指定交易所支持的交易对列表

    交易所 Market

    交易所(Market) 命名根据实际交易所域名。

    如果域名为 *.com , 那么该交易所名字为二级域名.

    如果域名不为 *.com , 那么该交易所名字为 二级域名-顶级域名.

    交易所均为小写

    如: bitfinex(bitfinex.com), gate-io(gate.io)

    通过 Markets API 可以获取所有支持的交易所列表。

    交易所-交易对 MarketPair

    交易所-交易对(MarketPair) 由交易所(Market)和交易对(SymbolPair)组成,由下划线分割。

    字符串大小写按照交易所和交易对的规定。

    如: bitfinex_BTC_USD, gate-io_BTC_USDT,

    通过 MarketPairs API 可以所有支持的交易所以及交易对的列表。

    REST API 概述

    元数据

    元数据为基础数据,一般作为请求行情数据的参数.

    Markets

    curl -X GET \
      'https://data.block.cc/api/v1/markets'
    
    const request = require("request");
    
    const options = { 
      method: 'GET',
      url: 'https://data.block.cc/api/v1/markets',
    };
    
    request(options, function (error, response, body) {
      if (error) throw new Error(error);
      console.log(body);
    });
    
    OkHttpClient client = new OkHttpClient();
    
    Request request = new Request.Builder()
      .url("https://data.block.cc/api/v1/markets")
      .get()
      .build();
    
    Response response = client.newCall(request).execute();
    
    import requests
    
    url = "https://data.block.cc/api/v1/markets"
    
    response = requests.request("GET", url)
    
    print(response.text)
    
    <?php
    $client = new http\Client;
    $request = new http\Client\Request;
    
    $request->setRequestUrl('https://data.block.cc/api/v1/markets');
    $request->setRequestMethod('GET');
    
    $client->enqueue($request)->send();
    $response = $client->getResponse();
    
    echo $response->getBody();
    
    require 'uri'
    require 'net/http'
    
    url = URI("https://data.block.cc/api/v1/markets")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Get.new(url)
    
    response = http.request(request)
    puts response.read_body
    

    将会返回以下内容:

    {
      "code": 0,
      "message": "success",
      "data": [{
        "name": "okex",
        "display_name": "OKEX",
        "home_url": "www.okex.com",
        "volume": 2490122366.2343,
        "display_volume": 2490122366.2343,
        "status": "enable",
        "ping": 1.88,
        "has_kline": true
      }, {
        "name": "bitmex",
        "display_name": "BitMEX",
        "home_url": "bitmex.com",
        "volume": 2042031024.1287,
        "display_volume": 2042031024.1287,
        "status": "enable",
        "ping": 252,
        "has_kline": true
      }]
    }
    

    获取所有支持的交易所列表

    请求URL

    GET https://data.block.cc/api/v1/markets

    请求参数

    None

    返回参数说明

    参数 说明
    name 交易所名称(ID)
    display_name 交易所显示名称
    home_url 交易所链接
    volume 根据加权计算出的交易量(USD)
    display_volume 未经加权计算出的交易量(USD)
    status 状态: [enable, disable]. disable为停止更新数据
    ping 服务器ping值
    has_kline 是否接入K线数据

    Symbols

    curl -X GET \
      'https://data.block.cc/api/v1/symbols'
    
    const request = require("request");
    
    const options = { 
      method: 'GET',
      url: 'https://data.block.cc/api/v1/symbols',
    };
    
    request(options, function (error, response, body) {
      if (error) throw new Error(error);
      console.log(body);
    });
    
    OkHttpClient client = new OkHttpClient();
    
    Request request = new Request.Builder()
      .url("https://data.block.cc/api/v1/symbols")
      .get()
      .build();
    
    Response response = client.newCall(request).execute();
    
    import requests
    
    url = "https://data.block.cc/api/v1/symbols"
    
    response = requests.request("GET", url)
    
    print(response.text)
    
    <?php
    $client = new http\Client;
    $request = new http\Client\Request;
    
    $request->setRequestUrl('https://data.block.cc/api/v1/symbols');
    $request->setRequestMethod('GET');
    
    $client->enqueue($request)->send();
    $response = $client->getResponse();
    
    echo $response->getBody();
    
    require 'uri'
    require 'net/http'
    
    url = URI("https://data.block.cc/api/v1/symbols")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Get.new(url)
    
    response = http.request(request)
    puts response.read_body
    

    将会返回以下内容:

    {
      "code": 0,
      "message": "success",
      "data": [{
        "name": "bitcoin",
        "symbol": "BTC",
        "volume_usd": 4463819005.1846,
        "alias": [
          "XBT"
        ],
        "status": "enable"
      }, {
        "name": "eos",
        "symbol": "EOS",
        "volume_usd": 1343162885.406,
        "alias": [],
        "status": "enable"
      }]
    }
    
    

    获取所有支持的币种列表

    请求URL

    GET https://data.block.cc/api/v1/symbols

    请求参数

    None

    返回参数说明

    参数 说明
    name 币种名称(ID)
    symbol 币种符号
    volume_usd 交易量(USD)
    alias 其他符号列表
    status 状态: [enable, disable]. disable为停止更新数据

    Currencies

    curl -X GET \
      'https://data.block.cc/api/v1/currencies'
    
    const request = require("request");
    
    const options = { 
      method: 'GET',
      url: 'https://data.block.cc/api/v1/currencies',
    };
    
    request(options, function (error, response, body) {
      if (error) throw new Error(error);
      console.log(body);
    });
    
    OkHttpClient client = new OkHttpClient();
    
    Request request = new Request.Builder()
      .url("https://data.block.cc/api/v1/currencies")
      .get()
      .build();
    
    Response response = client.newCall(request).execute();
    
    import requests
    
    url = "https://data.block.cc/api/v1/currencies"
    
    response = requests.request("GET", url)
    
    print(response.text)
    
    <?php
    $client = new http\Client;
    $request = new http\Client\Request;
    
    $request->setRequestUrl('https://data.block.cc/api/v1/currencies');
    $request->setRequestMethod('GET');
    
    $client->enqueue($request)->send();
    $response = $client->getResponse();
    
    echo $response->getBody();
    
    require 'uri'
    require 'net/http'
    
    url = URI("https://data.block.cc/api/v1/currencies")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Get.new(url)
    
    response = http.request(request)
    puts response.read_body
    

    将会返回以下内容:

    {
      "code": 0,
      "message": "success",
      "data": [
        "USDT",
        "USD",
        "CNY",
        "HKD",
        "KRW",
        "JPY"
      ]
    }
    
    

    获取所有支持的基础货币列表

    请求URL

    GET https://data.block.cc/api/v1/currencies

    请求参数

    None

    返回参数说明

    None

    MarketPairs

    curl -X GET \
      'https://data.block.cc/api/v1/market_pairs'
    
    const request = require("request");
    
    const options = { 
      method: 'GET',
      url: 'https://data.block.cc/api/v1/market_pairs',
    };
    
    request(options, function (error, response, body) {
      if (error) throw new Error(error);
      console.log(body);
    });
    
    OkHttpClient client = new OkHttpClient();
    
    Request request = new Request.Builder()
      .url("https://data.block.cc/api/v1/market_pairs")
      .get()
      .build();
    
    Response response = client.newCall(request).execute();
    
    import requests
    
    url = "https://data.block.cc/api/v1/market_pairs"
    
    response = requests.request("GET", url)
    
    print(response.text)
    
    <?php
    $client = new http\Client;
    $request = new http\Client\Request;
    
    $request->setRequestUrl('https://data.block.cc/api/v1/market_pairs');
    $request->setRequestMethod('GET');
    
    $client->enqueue($request)->send();
    $response = $client->getResponse();
    
    echo $response->getBody();
    
    require 'uri'
    require 'net/http'
    
    url = URI("https://data.block.cc/api/v1/market_pairs")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Get.new(url)
    
    response = http.request(request)
    puts response.read_body
    

    将会返回以下内容:

    {
      "code": 0,
      "message": "success",
      "data": [{
         "name": "bitmex",
         "display_name": "BitMEX",
         "symbol_pairs": [
           "XBT_USD",
           "BCH_XBT",
           "ETH_XBT",
           "LTC_XBT",
           "XRP_XBT",
           "ADA_XBT"
         ],
         "base_currencies": [
           "USD",
           "XBT"
         ]
       }]
    }
    
    

    获取所有支持的交易所以及支持的交易对列表

    请求URL

    GET https://data.block.cc/api/v1/market_pairs

    请求参数

    None

    返回参数说明

    参数 说明
    name 交易所名称(ID)
    display_name 交易所显示名称
    home_url 交易所链接
    symbol_pairs 该交易所支持的交易对列表
    base_currencies 该交易所支持的币种列表

    Market

    curl -X GET \
      'https://data.block.cc/api/v1/market/bitfinex'
    
    const request = require("request");
    
    const options = { 
      method: 'GET',
      url: 'https://data.block.cc/api/v1/market/bitfinex',
    };
    
    request(options, function (error, response, body) {
      if (error) throw new Error(error);
      console.log(body);
    });
    
    OkHttpClient client = new OkHttpClient();
    
    Request request = new Request.Builder()
      .url("https://data.block.cc/api/v1/market/bitfinex")
      .get()
      .build();
    
    Response response = client.newCall(request).execute();
    
    import requests
    
    url = "https://data.block.cc/api/v1/market/bitfinex"
    
    response = requests.request("GET", url)
    
    print(response.text)
    
    <?php
    $client = new http\Client;
    $request = new http\Client\Request;
    
    $request->setRequestUrl('https://data.block.cc/api/v1/market/bitfinex');
    $request->setRequestMethod('GET');
    
    $client->enqueue($request)->send();
    $response = $client->getResponse();
    
    echo $response->getBody();
    
    require 'uri'
    require 'net/http'
    
    url = URI("https://data.block.cc/api/v1/market/bitfinex")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Get.new(url)
    
    response = http.request(request)
    puts response.read_body
    

    将会返回以下内容:

    {
      "code": 0,
      "message": "success",
      "data": {
         "name": "bitfinex",
         "display_name": "Bitfinex",
         "volume": 768242461.6057,
         "display_volume": 768242461.6057,
         "home_url": "bitfinex.com",
         "symbol_pairs": [
           "BTC_USD",
           "EOS_USD",
           "ETH_USD"
          ]
      }
    }
    
    

    获取制定交易所信息

    请求URL

    GET https://data.block.cc/api/v1/market/{market_name}

    请求参数 parmas

    参数 传输方式 必选 说明
    market_name URL Params 交易所名称(ID)

    返回参数说明

    参数 说明
    name 交易所名称(ID)
    display_name 交易所显示名称
    home_url 交易所链接
    volume 根据加权计算出的交易量(USD)
    display_volume 未经加权计算出的交易量(USD)
    symbol_pairs 该交易所支持的交易对列表

    行情数据

    ExchangeRate

    curl -X GET \
      'https://data.block.cc/api/v1/exchange_rate'
    
    const request = require("request");
    
    const options = { 
      method: 'GET',
      url: 'https://data.block.cc/api/v1/exchange_rate',
    };
    
    request(options, function (error, response, body) {
      if (error) throw new Error(error);
      console.log(body);
    });
    
    OkHttpClient client = new OkHttpClient();
    
    Request request = new Request.Builder()
      .url("https://data.block.cc/api/v1/exchange_rate")
      .get()
      .build();
    
    Response response = client.newCall(request).execute();
    
    import requests
    
    url = "https://data.block.cc/api/v1/exchange_rate"
    
    response = requests.request("GET", url)
    
    print(response.text)
    
    <?php
    $client = new http\Client;
    $request = new http\Client\Request;
    
    $request->setRequestUrl('https://data.block.cc/api/v1/exchange_rate');
    $request->setRequestMethod('GET');
    
    $client->enqueue($request)->send();
    $response = $client->getResponse();
    
    echo $response->getBody();
    
    require 'uri'
    require 'net/http'
    
    url = URI("https://data.block.cc/api/v1/exchange_rate")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Get.new(url)
    
    response = http.request(request)
    puts response.read_body
    

    将会返回以下内容:

    {
      "code": 0,
      "message": "success",
      "data": {
         "base": "USD",
         "timestamp": 1526649591621,
         "rates": {
           "USDT": 1.00000086,
           "USD": 1,
           "CNY": 6.37805,
           "HKD": 7.85005,
           "KRW": 1081.57,
           "JPY": 110.94767712,
           "EUR": 0.848582,
           "AUD": 1.330482,
           "BRL": 3.69931,
           "CAD": 1.280865,
           "CHF": 0.999304,
           "CLP": 632.6,
           "CZK": 21.715925,
           "DKK": 6.320165,
           "GBP": 0.740933
         }
       }
    }
    
    

    获取汇率

    请求URL

    GET https://data.block.cc/api/v1/exchange_rate

    请求参数

    参数 传输方式 必选 说明
    base QueryString 基础兑换货币,默认USD
    symbols QueryString 目标兑换货币,可传多个币种,逗号分割,默认返回全部Currency的汇率
    format QueryString Enum('array','object'), 默认object, 决定返回参数中的rates的类型.

    返回参数说明

    参数 说明
    base 基础兑换货币
    timestamp 时间戳
    rates 目标兑换货币以及汇率,如基础货币为USD,CNY下的数字为USDCNY的汇率。

    Price

    curl -X GET \
      'https://data.block.cc/api/v1/price?symbol_name=bitcoin,filecoin'
    
    const request = require("request");
    
    const options = { 
      method: 'GET',
      url: 'https://data.block.cc/api/v1/price?symbol_name=bitcoin,filecoin',
    };
    
    request(options, function (error, response, body) {
      if (error) throw new Error(error);
      console.log(body);
    });
    
    OkHttpClient client = new OkHttpClient();
    
    Request request = new Request.Builder()
      .url("https://data.block.cc/api/v1/price?symbol_name=bitcoin,filecoin")
      .get()
      .build();
    
    Response response = client.newCall(request).execute();
    
    import requests
    
    url = "https://data.block.cc/api/v1/price?symbol_name=bitcoin,filecoin"
    
    response = requests.request("GET", url)
    
    print(response.text)
    
    <?php
    $client = new http\Client;
    $request = new http\Client\Request;
    
    $request->setRequestUrl('https://data.block.cc/api/v1/price?symbol_name=bitcoin,filecoin');
    $request->setRequestMethod('GET');
    
    $client->enqueue($request)->send();
    $response = $client->getResponse();
    
    echo $response->getBody();
    
    require 'uri'
    require 'net/http'
    
    url = URI("https://data.block.cc/api/v1/price?symbol_name=bitcoin,filecoin")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Get.new(url)
    
    response = http.request(request)
    puts response.read_body
    

    将会返回以下内容:

    {
      "code": 0,
      "message": "success",
      "data": [{
        "name": "bitcoin",
        "symbol": "BTC",
        "price": 8134.85601071,
        "high": 8368.41733741,
        "low": 7972.64470958,
        "timestamps": 1526650745300,
        "volume": 550321.8613,
        "change_hourly": 0.0003,
        "change_daily": -0.0195,
        "change_weekly": -0.0486,
        "change_monthly": 0.008
      }, {
        "name": "filecoin",
        "symbol": "FIL",
        "price": 10.40686482,
        "high": 13.97451729,
        "low": 10.21612566,
        "timestamps": 1526650745791,
        "volume": 147065.6292,
        "change_hourly": -0.003,
        "change_daily": -0.067,
        "change_weekly": -0.1028,
        "change_monthly": -0.2838
      }]
    }
    
    

    获取币种价格

    请求URL

    GET https://data.block.cc/api/v1/price

    请求参数

    参数名称 传输方式 必选 说明
    symbol_name QueryString 币种名称,可传多个币种,逗号分割。
    symbol QueryString 币种符号,可传多个币种,逗号分割。一个符号可能对应多个币种。

    两种参数必须存在一种, 优先级 symbol_name > symbol, 按照交易量大小降序返回。

    返回参数说明

    参数 说明
    name 币种名称
    symbol 币种符号
    price 当前价格
    high 24小时最高价
    low 24小时最低价
    timestamps 时间戳
    volume 交易量(单位为当前币种)
    change_hourly 最近一小时涨幅
    change_daily 最近一天涨幅
    change_weekly 最近一周涨幅
    change_monthly 最近一月涨幅

    PriceHistory

    curl -X GET \
      'https://data.block.cc/api/v1/price/history?symbol_name=bitcoin'
    
    const request = require("request");
    
    const options = { 
      method: 'GET',
      url: 'https://data.block.cc/api/v1/price/history?symbol_name=bitcoin',
    };
    
    request(options, function (error, response, body) {
      if (error) throw new Error(error);
      console.log(body);
    });
    
    OkHttpClient client = new OkHttpClient();
    
    Request request = new Request.Builder()
      .url("https://data.block.cc/api/v1/price/history?symbol_name=bitcoin")
      .get()
      .build();
    
    Response response = client.newCall(request).execute();
    
    import requests
    
    url = "https://data.block.cc/api/v1/price/history?symbol_name=bitcoin"
    
    response = requests.request("GET", url)
    
    print(response.text)
    
    <?php
    $client = new http\Client;
    $request = new http\Client\Request;
    
    $request->setRequestUrl('https://data.block.cc/api/v1/price/history?symbol_name=bitcoin');
    $request->setRequestMethod('GET');
    
    $client->enqueue($request)->send();
    $response = $client->getResponse();
    
    echo $response->getBody();
    
    require 'uri'
    require 'net/http'
    
    url = URI("https://data.block.cc/api/v1/price/history?symbol_name=bitcoin")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Get.new(url)
    
    response = http.request(request)
    puts response.read_body
    

    将会返回以下内容:

    {
      "code": 0,
      "message": "success",
      "data": [
        [
          1526207400000,
          8619.23666414,
          642602.5106
        ],
        [
          1526207700000,
          8617.18583899,
          638979.2457
        ],
        [
          1526208000000,
          8607.39468638,
          637886.6039
        ],
        [
          1526208300000,
          8599.51394863,
          650563.7065
        ]
      ]
    }
    
    

    获取币种历史价格

    请求URL

    GET https://data.block.cc/api/v1/price/history

    请求参数

    参数名称 传输方式 必选 说明
    symbol_name QueryString 币种名称。
    symbol QueryString 币种符号。如果一个符号对应多个币种选择交易量大的返回。
    limit QueryString 返回数据量, 默认1000,最大返回2000条数据。

    symbol_name symbol 两种参数必须存在一种, 优先级 symbol_name > symbol

    返回参数说明

    参数 说明
    0 时间戳
    1 当时币种价格
    2 当时24小时交易量(单位为当前币种)

    Ticker

    curl -X GET \
      'https://data.block.cc/api/v1/ticker?market=bitfinex&symbol_pair=BTC_USD'
    
    const request = require("request");
    
    const options = { 
      method: 'GET',
      url: 'https://data.block.cc/api/v1/ticker?market=bitfinex&symbol_pair=BTC_USD',
    };
    
    request(options, function (error, response, body) {
      if (error) throw new Error(error);
      console.log(body);
    });
    
    OkHttpClient client = new OkHttpClient();
    
    Request request = new Request.Builder()
      .url("https://data.block.cc/api/v1/ticker?market=bitfinex&symbol_pair=BTC_USD")
      .get()
      .build();
    
    Response response = client.newCall(request).execute();
    
    import requests
    
    url = "https://data.block.cc/api/v1/ticker?market=bitfinex&symbol_pair=BTC_USD"
    
    response = requests.request("GET", url)
    
    print(response.text)
    
    <?php
    $client = new http\Client;
    $request = new http\Client\Request;
    
    $request->setRequestUrl('https://data.block.cc/api/v1/ticker?market=bitfinex&symbol_pair=BTC_USD');
    $request->setRequestMethod('GET');
    
    $client->enqueue($request)->send();
    $response = $client->getResponse();
    
    echo $response->getBody();
    
    require 'uri'
    require 'net/http'
    
    url = URI("https://data.block.cc/api/v1/ticker?market=bitfinex&symbol_pair=BTC_USD")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Get.new(url)
    
    response = http.request(request)
    puts response.read_body
    

    将会返回以下内容:

    {
      "code": 0,
      "message": "success",
      "data": {
        "timestamps": 1526669069706,
        "last": 8120.6,
        "bid": 8132.7,
        "ask": 8132.8,
        "high": 8232,
        "low": 7925,
        "vol": 26668.8,
        "base_volume": 216566657.28,
        "change_daily": -0.0067,
        "market": "bitfinex",
        "symbol_name": "bitcoin",
        "symbol_pair": "BTC_USD",
        "has_kline": true,
        "usd_rate": 1
      }
    }
    
    

    获取交易对Ticker

    请求URL

    GET https://data.block.cc/api/v1/ticker

    请求参数

    参数名称 传输方式 必选 说明
    market QueryString 交易所名称。
    symbol_pair QueryString 交易对。

    返回参数说明

    参数 说明
    timestamps 数据更新时间
    last 最新价格
    bid 买一价
    ask 卖一价
    high 24小时最高价
    low 24小时最低价
    vol 24小时交易货币交易量
    base_volume 24小时基础货币交易量
    change_daily 24小时涨幅
    market 交易所名称
    symbol_name 币种名称
    symbol_pair 交易对
    has_kline 是否接入K线数据
    usd_rate 基础转货币转美元的汇率

    Tickers

    curl -X GET \
      'https://data.block.cc/api/v1/tickers?market=bitfinex'
    
    const request = require("request");
    
    const options = { 
      method: 'GET',
      url: 'https://data.block.cc/api/v1/tickers?market=bitfinex',
    };
    
    request(options, function (error, response, body) {
      if (error) throw new Error(error);
      console.log(body);
    });
    
    OkHttpClient client = new OkHttpClient();
    
    Request request = new Request.Builder()
      .url("https://data.block.cc/api/v1/tickers?market=bitfinex")
      .get()
      .build();
    
    Response response = client.newCall(request).execute();
    
    import requests
    
    url = "https://data.block.cc/api/v1/tickers?market=bitfinex"
    
    response = requests.request("GET", url)
    
    print(response.text)
    
    <?php
    $client = new http\Client;
    $request = new http\Client\Request;
    
    $request->setRequestUrl('https://data.block.cc/api/v1/tickers?market=bitfinex');
    $request->setRequestMethod('GET');
    
    $client->enqueue($request)->send();
    $response = $client->getResponse();
    
    echo $response->getBody();
    
    require 'uri'
    require 'net/http'
    
    url = URI("https://data.block.cc/api/v1/tickers?market=bitfinex")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Get.new(url)
    
    response = http.request(request)
    puts response.read_body
    

    将会返回以下内容:

    {
      "code": 0,
      "message": "success",
      "data": {
        "page": 1,
        "size": 20,
        "total_page": 10,
        "total_count": 192,
        "list": [
          {
          "timestamps": 1526705478225,
          "last": 8226.9,
          "bid": 8226.8,
          "ask": 8226.9,
          "high": 8277.8,
          "low": 7950.8,
          "vol": 20326.7168,
          "base_volume": 167225866.8097,
          "change_daily": 0.0235,
          "market": "bitfinex",
          "symbol_name": "bitcoin",
          "symbol_pair": "BTC_USD",
          "rating": 3,
          "has_kline": true,
          "usd_rate": 1
        }]
      }
    }
    
    

    批量获取交易对Tickers

    请求URL

    GET https://data.block.cc/api/v1/tickers

    请求参数

    参数名称 传输方式 必选 说明
    market QueryString 交易所名称,可传多个,逗号分割
    symbol QueryString 币种符号,可传多个,逗号分割
    symbol_name QueryString 币种名称,可传多个,逗号分割
    currency QueryString 基础货币,可传多个,逗号分割
    market_pair QueryString 交易所-交易对,可传多个,逗号分割
    page QueryString 当前页数,默认 1, (>=1)
    size QueryString 每页数据量,默认 20 (>=1)

    例如:

    返回参数说明

    参数 说明
    page 当前页码
    size 每页数据量
    total_page 最大页码
    total_count 总数据量
    list ticker数据,格式与 Ticker API 相同

    Depth

    curl -X GET \
      'https://data.block.cc/api/v1/depth?market=bitfinex&symbol_pair=BTC_USD'
    
    const request = require("request");
    
    const options = { 
      method: 'GET',
      url: 'https://data.block.cc/api/v1/depth?market=bitfinex&symbol_pair=BTC_USD',
    };
    
    request(options, function (error, response, body) {
      if (error) throw new Error(error);
      console.log(body);
    });
    
    OkHttpClient client = new OkHttpClient();
    
    Request request = new Request.Builder()
      .url("https://data.block.cc/api/v1/depth?market=bitfinex&symbol_pair=BTC_USD")
      .get()
      .build();
    
    Response response = client.newCall(request).execute();
    
    import requests
    
    url = "https://data.block.cc/api/v1/depth?market=bitfinex&symbol_pair=BTC_USD"
    
    response = requests.request("GET", url)
    
    print(response.text)
    
    <?php
    $client = new http\Client;
    $request = new http\Client\Request;
    
    $request->setRequestUrl('https://data.block.cc/api/v1/depth?market=bitfinex&symbol_pair=BTC_USD');
    $request->setRequestMethod('GET');
    
    $client->enqueue($request)->send();
    $response = $client->getResponse();
    
    echo $response->getBody();
    
    require 'uri'
    require 'net/http'
    
    url = URI("https://data.block.cc/api/v1/depth?market=bitfinex&symbol_pair=BTC_USD")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Get.new(url)
    
    response = http.request(request)
    puts response.read_body
    

    将会返回以下内容:

    {
      "code": 0,
      "message": "success",
      "data": {
        "timestamps": 1526706175469,
        "bids": [
          [
            8221.6,
            4.99792
          ],
          [
            8221.2,
            1.212
          ],
          [
            8220.6,
            0.04144752
          ]
        ],
        "asks": [
          [
            8221.7,
            1.10182386
          ],
          [
            8222.1,
            2.78535112
          ],
          [
            8223.2,
            4.21445703
          ]
        ]
      }
    }
    
    

    获取交易对深度

    请求URL

    GET https://data.block.cc/api/v1/depth

    请求参数

    参数名称 传输方式 必选 说明
    market QueryString 交易所名称。
    symbol_pair QueryString 交易对。
    limit QueryString 深度档位,默认25。

    返回参数说明

    参数 说明
    timestamps 更新时间戳
    bids 买单列表
    asks 卖单列表
    --------- -----------
    0 价格
    1 挂单量

    Trades

    curl -X GET \
      'https://data.block.cc/api/v1/trade?market=bitfinex&symbol_pair=BTC_USD'
    
    const request = require("request");
    
    const options = { 
      method: 'GET',
      url: 'https://data.block.cc/api/v1/trade?market=bitfinex&symbol_pair=BTC_USD',
    };
    
    request(options, function (error, response, body) {
      if (error) throw new Error(error);
      console.log(body);
    });
    
    OkHttpClient client = new OkHttpClient();
    
    Request request = new Request.Builder()
      .url("https://data.block.cc/api/v1/trade?market=bitfinex&symbol_pair=BTC_USD")
      .get()
      .build();
    
    Response response = client.newCall(request).execute();
    
    import requests
    
    url = "https://data.block.cc/api/v1/trade?market=bitfinex&symbol_pair=BTC_USD"
    
    response = requests.request("GET", url)
    
    print(response.text)
    
    <?php
    $client = new http\Client;
    $request = new http\Client\Request;
    
    $request->setRequestUrl('https://data.block.cc/api/v1/trade?market=bitfinex&symbol_pair=BTC_USD');
    $request->setRequestMethod('GET');
    
    $client->enqueue($request)->send();
    $response = $client->getResponse();
    
    echo $response->getBody();
    
    require 'uri'
    require 'net/http'
    
    url = URI("https://data.block.cc/api/v1/trade?market=bitfinex&symbol_pair=BTC_USD")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Get.new(url)
    
    response = http.request(request)
    puts response.read_body
    

    将会返回以下内容:

    {
      "code": 0,
      "message": "success",
      "data": [
        {
        "trade_id": 247137292,
        "time": 1526706772046,
        "price": 8227,
        "amount": 0.1,
        "type": "sell"
        },
        {
        "trade_id": 247137270,
        "time": 1526706757113,
        "price": 8227,
        "amount": 0.1,
        "type": "sell"
        }
      ]
    }
    
    

    获取交易对成交记录

    请求URL

    GET https://data.block.cc/api/v1/trade

    请求参数

    参数名称 传输方式 必选 说明
    market QueryString 交易所名称
    symbol_pair QueryString 交易对
    limit QueryString 返回数据量,默认50

    返回参数说明

    参数 说明
    trade_id 交易ID
    time 交易成交时间戳
    price 成交价格
    amount 成交量
    type 成交类型ENUM[buy,sell,none],为taker操作方向

    Kline

    curl -X GET \
      'https://data.block.cc/api/v1/kline?market=bitfinex&symbol_pair=BTC_USD&type=5m'
    
    const request = require("request");
    
    const options = { 
      method: 'GET',
      url: 'https://data.block.cc/api/v1/kline?market=bitfinex&symbol_pair=BTC_USD&type=5m',
    };
    
    request(options, function (error, response, body) {
      if (error) throw new Error(error);
      console.log(body);
    });
    
    OkHttpClient client = new OkHttpClient();
    
    Request request = new Request.Builder()
      .url("https://data.block.cc/api/v1/kline?market=bitfinex&symbol_pair=BTC_USD&type=5m")
      .get()
      .build();
    
    Response response = client.newCall(request).execute();
    
    import requests
    
    url = "https://data.block.cc/api/v1/kline?market=bitfinex&symbol_pair=BTC_USD&type=5m"
    
    response = requests.request("GET", url)
    
    print(response.text)
    
    <?php
    $client = new http\Client;
    $request = new http\Client\Request;
    
    $request->setRequestUrl('https://data.block.cc/api/v1/kline?market=bitfinex&symbol_pair=BTC_USD&type=5m');
    $request->setRequestMethod('GET');
    
    $client->enqueue($request)->send();
    $response = $client->getResponse();
    
    echo $response->getBody();
    
    require 'uri'
    require 'net/http'
    
    url = URI("https://data.block.cc/api/v1/kline?market=bitfinex&symbol_pair=BTC_USD&type=5m")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Get.new(url)
    
    response = http.request(request)
    puts response.read_body
    

    将会返回以下内容:

    {
      "code": 0,
      "message": "success",
      "data": [
        [
          1526406900000,
          8557.56,
          8567.54,
          8540.45,
          8567.77,
          0.62115947
        ],
        [
          1526407200000,
          8543.75,
          8558.71,
          8531,
          8558.91,
          0.04962919
        ]
      ]
    }
    
    

    获取交易对K线数据(OHLCV)

    请求URL

    GET https://data.block.cc/api/v1/kline

    请求参数

    参数名称 传输方式 必选 说明
    market QueryString 交易所名称
    symbol_pair QueryString 交易对
    type QueryString K线类型ENUM[5m,15m,30m,1h,6h,1d],默认5m
    limit QueryString 返回数据量,默认1000

    返回参数说明

    参数 说明
    0 timestamp
    1 open
    2 close
    3 low
    4 high
    5 volume

    区块数据

    Address

    TxHash

    其他数据

    IP2Location

    curl -X GET \
      'https://data.block.cc/api/v1/ip/8.8.8.8'
    
    const request = require("request");
    
    const options = { 
      method: 'GET',
      url: 'https://data.block.cc/api/v1/ip/8.8.8.8',
    };
    
    request(options, function (error, response, body) {
      if (error) throw new Error(error);
      console.log(body);
    });
    
    OkHttpClient client = new OkHttpClient();
    
    Request request = new Request.Builder()
      .url("https://data.block.cc/api/v1/ip/8.8.8.8")
      .get()
      .build();
    
    Response response = client.newCall(request).execute();
    
    import requests
    
    url = "https://data.block.cc/api/v1/ip/8.8.8.8"
    
    response = requests.request("GET", url)
    
    print(response.text)
    
    <?php
    $client = new http\Client;
    $request = new http\Client\Request;
    
    $request->setRequestUrl('https://data.block.cc/api/v1/ip/8.8.8.8');
    $request->setRequestMethod('GET');
    
    $client->enqueue($request)->send();
    $response = $client->getResponse();
    
    echo $response->getBody();
    
    require 'uri'
    require 'net/http'
    
    url = URI("https://data.block.cc/api/v1/ip/8.8.8.8")
    
    http = Net::HTTP.new(url.host, url.port)
    
    request = Net::HTTP::Get.new(url)
    
    response = http.request(request)
    puts response.read_body
    

    将会返回以下内容:

    {
      "code": 0,
      "message": "success",
      "data": {
        "ip": "8.8.8.8",
        "country_code": "US",
        "country_name": "United States",
        "region_name": "California",
        "city_name": "Mountain View",
        "latitude": 37.405992,
        "longitude": -122.078515,
        "zip_code": "94043",
        "time_zone": "-08:00"
      }
    }
    
    

    根据IP获取定位

    请求URL

    GET https://data.block.cc/api/v1/ip/{ip_address}

    请求参数

    参数名称 传输方式 必选 说明
    ip_address URL Params IP地址,如果为空则返回客户端地址信息

    返回参数说明

    参数 说明
    ip 当前查询的IP
    country_code 国家代码
    country_name 国家全称
    region_name 省/州 名称
    city_name 城市名称
    latitude 纬度
    longitude 经度
    zip_code 邮政编码
    time_zone 时区

    WebSocket API 概述

    暂不开放

    交易所收录

    API 建议

    1. 请使用QueryString或者URLParams方式传参。
    2. 公共行情接口请不要通过加密,白名单保护
    3. 请提供批量获取ticker的接口,以便批量更新价格和交易对。
    4. 如果暂时不能提供批量获取ticker的接口, 请提供获取所有交易对的接口。(不推荐,请求频率高,更新速度慢)
    5. 交易对请尽量使用符号分割或者固定长度。
    6. 正常情况下每分钟请求次数为10次左右。
    7. 接口数据保证稳定真实。

    点此连接 进入交易所收录表单