├── PublicApi.md └── PublicApi_CN.md /PublicApi.md: -------------------------------------------------------------------------------- 1 | # FeiXiaoHao PublicAPI 2 | 3 | The FeiXiaoHao API is a suite of high-performance RESTful JSON endpoints that are specifically designed to meet the mission-critical demands of application developers, data scientists, and enterprise business platforms. 4 | 5 | ## Endpoint Overview 6 | 7 | The FeiXiaoHao API only have 1 top-level category right now. 8 | 9 | Endpoint Category | Description 10 | :- | :-- 11 | [https://fxhapi.feixiaohao.com/public/v1/ticker/*](https://fxhapi.feixiaohao.com/public/v1/ticker) | Endpoints that return data around cryptocurrencies such as ordered cryptocurrency lists or price and volume data. 12 | 13 | ## Quick Start 14 | 15 | ### Tickers 16 | 17 | > Update per minute 18 | 19 | * **Method:** 20 | 21 | `GET` 22 | 23 | * **URL Params** 24 | 25 | **Optional:** 26 | 27 | `start=[integer](return results from rank "start" and above)`
28 | 29 | `limit=[integer](return a maximum of "limit" results, default is 100, use 0 to return all results)`
30 | 31 | `convert=[alphanumeric](return price, 24h volume, and market cap in terms of another currency. Valid values are: "AUD", "BRL", "CAD", "CHF", "CLP", "CNY", "CZK", "DKK", "EUR", "GBP", "HKD", "HUF", "IDR", "ILS", "INR", "JPY", "KRW", "MXN", "MYR", "NOK", "NZD", "PHP", "PKR", "PLN", "RUB", "SEK", "SGD", "THB", "TRY", "TWD", "ZAR")` 32 | 33 | * **Success Response:** 34 | 35 | * **Code:** 200
36 | **Content:** 37 | 38 | ```json 39 | [ 40 | { 41 | "id": "bitcoin", 42 | "name": "Bitcoin", 43 | "symbol": "BTC", 44 | "rank": 1, 45 | "logo": "https://s1.bqiapp.com/coin/20181030_72_webp/bitcoin_200_200.webp", 46 | "logo_png": "https://s1.bqiapp.com/coin/20181030_72_png/bitcoin_200_200.png", 47 | "price_usd": 5225, 48 | "price_btc": 1, 49 | "volume_24h_usd": 5150321567, 50 | "market_cap_usd": 92163602317, 51 | "available_supply": 17637575, 52 | "total_supply": 17637575, 53 | "max_supply": 21000000, 54 | "percent_change_1h": 0.21, 55 | "percent_change_24h": 0.64, 56 | "percent_change_7d": 6, 57 | "last_updated": 1554886833 58 | }, 59 | { 60 | "id": "ethereum", 61 | "name": "Ethereum", 62 | "symbol": "ETH", 63 | "rank": 2, 64 | "logo": "https://s1.bqiapp.com/coin/20181030_72_webp/ethereum_200_200.webp", 65 | "logo_png": "https://s1.bqiapp.com/coin/20181030_72_png/ethereum_200_200.png", 66 | "price_usd": 179.65, 67 | "price_btc": 0.0344, 68 | "volume_24h_usd": 2766496907, 69 | "market_cap_usd": 18971178569, 70 | "available_supply": 105598041, 71 | "total_supply": 105598041, 72 | "max_supply": 105598041, 73 | "percent_change_1h": 0.35, 74 | "percent_change_24h": 2.18, 75 | "percent_change_7d": 8.42, 76 | "last_updated": 1554886833 77 | } 78 | ] 79 | ``` 80 | 81 | * **Error Response:** 82 | 83 | * **Code:** 401/403 or 429
84 | **Content:** `{"message":"API rate limit exceeded"}` 85 | 86 | * **Sample Call:** 87 | 88 | * **CURL:**
89 | ```bash 90 | curl -H "Accept: application/json" -G "https://fxhapi.feixiaohao.com/public/v1/ticker?limit=5" 91 | ``` 92 | 93 | * **C#:**
94 | ```csharp 95 | using System; 96 | using System.Net; 97 | using System.Web; 98 | 99 | class CSharpExample 100 | { 101 | public static void Main(string[] args) 102 | { 103 | try 104 | { 105 | Console.WriteLine(makeAPICall()); 106 | } 107 | catch (WebException e) 108 | { 109 | Console.WriteLine(e.Message); 110 | } 111 | } 112 | 113 | static string makeAPICall() 114 | { 115 | var URL = new UriBuilder("https://fxhapi.feixiaohao.com/public/v1/ticker"); 116 | 117 | var queryString = System.Web.HttpUtility.ParseQueryString(string.Empty); 118 | queryString["start"] = "5"; 119 | queryString["limit"] = "5"; 120 | queryString["convert"] = "USD"; 121 | 122 | URL.Query = queryString.ToString(); 123 | 124 | var client = new System.Net.WebClient(); 125 | client.Headers.Add("Accepts", "application/json"); 126 | return client.DownloadString(URL.ToString()); 127 | } 128 | 129 | } 130 | 131 | ``` 132 | * **Java:**
133 | 134 | ```java 135 | import java.io.IOException; 136 | import java.net.URISyntaxException; 137 | import java.util.ArrayList; 138 | import java.util.List; 139 | 140 | public class JavaExample { 141 | 142 | public static void main(String[] args) { 143 | String uri = "https://fxhapi.feixiaohao.com/public/v1/ticker"; 144 | List paratmers = new ArrayList(); 145 | paratmers.add(new BasicNameValuePair("start","5")); 146 | paratmers.add(new BasicNameValuePair("limit","5")); 147 | paratmers.add(new BasicNameValuePair("convert","USD")); 148 | 149 | try { 150 | String result = makeAPICall(uri, paratmers); 151 | System.out.println(result); 152 | } catch (IOException e) { 153 | System.out.println("Error: cannont access content - " + e.toString()); 154 | } catch (URISyntaxException e) { 155 | System.out.println("Error: Invalid URL " + e.toString()); 156 | } 157 | } 158 | 159 | public static String makeAPICall(String uri, List parameters) 160 | throws URISyntaxException, IOException { 161 | String response_content = ""; 162 | 163 | URIBuilder query = new URIBuilder(uri); 164 | query.addParameters(parameters); 165 | 166 | CloseableHttpClient client = HttpClients.createDefault(); 167 | HttpGet request = new HttpGet(query.build()); 168 | 169 | request.setHeader(HttpHeaders.ACCEPT, "application/json"); 170 | 171 | CloseableHttpResponse response = client.execute(request); 172 | 173 | try { 174 | System.out.println(response.getStatusLine()); 175 | HttpEntity entity = response.getEntity(); 176 | response_content = EntityUtils.toString(entity); 177 | EntityUtils.consume(entity); 178 | } finally { 179 | response.close(); 180 | } 181 | 182 | return response_content; 183 | } 184 | 185 | } 186 | 187 | ``` 188 | * **Golang:**
189 | ```go 190 | package main 191 | 192 | import ( 193 | "fmt" 194 | "io/ioutil" 195 | "log" 196 | "net/http" 197 | "net/url" 198 | "os" 199 | ) 200 | 201 | 202 | func main() { 203 | client := &http.Client{} 204 | req, err := http.NewRequest("GET","https://fxhapi.feixiaohao.com/public/v1/ticker", nil) 205 | if err != nil { 206 | log.Print(err) 207 | os.Exit(1) 208 | } 209 | 210 | q := url.Values{} 211 | q.Add("start", "5") 212 | q.Add("limit", "5") 213 | q.Add("convert", "USD") 214 | 215 | req.Header.Set("Accepts", "application/json") 216 | req.URL.RawQuery = q.Encode() 217 | 218 | 219 | resp, err := client.Do(req); 220 | if err != nil { 221 | fmt.Println("Error sending request to server") 222 | os.Exit(1) 223 | } 224 | fmt.Println(resp.Status); 225 | respBody, _ := ioutil.ReadAll(resp.Body) 226 | fmt.Println(string(respBody)); 227 | 228 | } 229 | ``` 230 | 231 | -------------------------------------------------------------------------------- /PublicApi_CN.md: -------------------------------------------------------------------------------- 1 | # 非小号公共API 2 | 3 | Feixiaohao API是一套高性能的RESTful接口,专门设计用于满足应用程序开发人员、数据科学家和企业业务平台的需求。 4 | 5 | ## 终结点 6 | 7 | Feixiaohao API目前只有1个顶级目录。 8 | 9 | 目录 | 描述 10 | :- | :-- 11 | [https://fxhapi.feixiaohao.com/public/v1/ticker/*](https://fxhapi.feixiaohao.com/public/v1/ticker) | 返回加密货币数据,如有序加密货币列表或价格和数量数据。 12 | 13 | ## 快速开始 14 | 15 | ### Ticker(行情) 16 | 17 | > 更新频率:1分钟更新一次 18 | 19 | * **访问方式:** 20 | 21 | `GET` 22 | 23 | * **URL 参数** 24 | 25 | **可选:** 26 | 27 | `start=[integer](指定结果集的开始排名)`
28 | 29 | `limit=[integer](指定结果集的最大数量)`
30 | 31 | `convert=[string](将返回的 price, 24h volume, 和 market cap 字段转换到指定货币单位并补充到结果对象. 可用的货币单位有: "AUD", "BRL", "CAD", "CHF", "CLP", "CNY", "CZK", "DKK", "EUR", "GBP", "HKD", "HUF", "IDR", "ILS", "INR", "JPY", "KRW", "MXN", "MYR", "NOK", "NZD", "PHP", "PKR", "PLN", "RUB", "SEK", "SGD", "THB", "TRY", "TWD", "ZAR")` 32 | 33 | * **访问成功:** 34 | 35 | * **返回码:** 200
36 | **返回内容:** 37 | 38 | ```json 39 | [ 40 | { 41 | "id": "bitcoin", 42 | "name": "Bitcoin", 43 | "symbol": "BTC", 44 | "rank": 1, 45 | "logo": "https://s1.bqiapp.com/coin/20181030_72_webp/bitcoin_200_200.webp", 46 | "logo_png": "https://s1.bqiapp.com/coin/20181030_72_png/bitcoin_200_200.png", 47 | "price_usd": 5225, 48 | "price_btc": 1, 49 | "volume_24h_usd": 5150321567, 50 | "market_cap_usd": 92163602317, 51 | "available_supply": 17637575, 52 | "total_supply": 17637575, 53 | "max_supply": 21000000, 54 | "percent_change_1h": 0.21, 55 | "percent_change_24h": 0.64, 56 | "percent_change_7d": 6, 57 | "last_updated": 1554886833 58 | }, 59 | { 60 | "id": "ethereum", 61 | "name": "Ethereum", 62 | "symbol": "ETH", 63 | "rank": 2, 64 | "logo": "https://s1.bqiapp.com/coin/20181030_72_webp/ethereum_200_200.webp", 65 | "logo_png": "https://s1.bqiapp.com/coin/20181030_72_png/ethereum_200_200.png", 66 | "price_usd": 179.65, 67 | "price_btc": 0.0344, 68 | "volume_24h_usd": 2766496907, 69 | "market_cap_usd": 18971178569, 70 | "available_supply": 105598041, 71 | "total_supply": 105598041, 72 | "max_supply": 105598041, 73 | "percent_change_1h": 0.35, 74 | "percent_change_24h": 2.18, 75 | "percent_change_7d": 8.42, 76 | "last_updated": 1554886833 77 | } 78 | ] 79 | ``` 80 | ``` 81 | 其中各字段的说明如下: 82 | "id": "币种代码(唯一主键)", 83 | "name": "币种英文名称", 84 | "symbol": "币种的简称", 85 | "rank": 币种的排名, 86 | "logo": "币种的logo(webp格式)", 87 | "logo_png": "币种的logo(非webp格式)", 88 | "price_usd": 最新价格(单位:美元), 89 | "price_btc": 最新价格(单位:BTC), 90 | "volume_24h_usd": 24h的成交额(单位:美元), 91 | "market_cap_usd": 流通市值(单位:美元), 92 | "available_supply": 流通数量, 93 | "total_supply": 总发行量, 94 | "max_supply": 最大发行量(最大发行量可能>总发行量,譬如有些币种会主动销毁一部分数量), 95 | "percent_change_1h": 1小时涨跌幅, 96 | "percent_change_24h":24小时涨跌幅, 97 | "percent_change_7d":7天涨跌幅, 98 | "last_updated": 行情更新时间(10位unix时间戳) 99 | ``` 100 | 101 | * **访问失败:** 102 | 103 | * **返回码:** 401/403 或者 429
104 | **内容:** `{"message":"API rate limit exceeded"}` 105 | 106 | * **示例请求:** 107 | 108 | * **CURL:**
109 | ```bash 110 | curl -H "Accept: application/json" -G "https://fxhapi.feixiaohao.com/public/v1/ticker?limit=5" 111 | ``` 112 | 113 | * **C#:**
114 | ```csharp 115 | using System; 116 | using System.Net; 117 | using System.Web; 118 | 119 | class CSharpExample 120 | { 121 | public static void Main(string[] args) 122 | { 123 | try 124 | { 125 | Console.WriteLine(makeAPICall()); 126 | } 127 | catch (WebException e) 128 | { 129 | Console.WriteLine(e.Message); 130 | } 131 | } 132 | 133 | static string makeAPICall() 134 | { 135 | var URL = new UriBuilder("https://fxhapi.feixiaohao.com/public/v1/ticker"); 136 | 137 | var queryString = System.Web.HttpUtility.ParseQueryString(string.Empty); 138 | queryString["start"] = "5"; 139 | queryString["limit"] = "5"; 140 | queryString["convert"] = "USD"; 141 | 142 | URL.Query = queryString.ToString(); 143 | 144 | var client = new System.Net.WebClient(); 145 | client.Headers.Add("Accepts", "application/json"); 146 | return client.DownloadString(URL.ToString()); 147 | } 148 | 149 | } 150 | 151 | ``` 152 | * **Java:**
153 | 154 | ```java 155 | import java.io.IOException; 156 | import java.net.URISyntaxException; 157 | import java.util.ArrayList; 158 | import java.util.List; 159 | 160 | public class JavaExample { 161 | 162 | public static void main(String[] args) { 163 | String uri = "https://fxhapi.feixiaohao.com/public/v1/ticker"; 164 | List paratmers = new ArrayList(); 165 | paratmers.add(new BasicNameValuePair("start","5")); 166 | paratmers.add(new BasicNameValuePair("limit","5")); 167 | paratmers.add(new BasicNameValuePair("convert","USD")); 168 | 169 | try { 170 | String result = makeAPICall(uri, paratmers); 171 | System.out.println(result); 172 | } catch (IOException e) { 173 | System.out.println("Error: cannont access content - " + e.toString()); 174 | } catch (URISyntaxException e) { 175 | System.out.println("Error: Invalid URL " + e.toString()); 176 | } 177 | } 178 | 179 | public static String makeAPICall(String uri, List parameters) 180 | throws URISyntaxException, IOException { 181 | String response_content = ""; 182 | 183 | URIBuilder query = new URIBuilder(uri); 184 | query.addParameters(parameters); 185 | 186 | CloseableHttpClient client = HttpClients.createDefault(); 187 | HttpGet request = new HttpGet(query.build()); 188 | 189 | request.setHeader(HttpHeaders.ACCEPT, "application/json"); 190 | 191 | CloseableHttpResponse response = client.execute(request); 192 | 193 | try { 194 | System.out.println(response.getStatusLine()); 195 | HttpEntity entity = response.getEntity(); 196 | response_content = EntityUtils.toString(entity); 197 | EntityUtils.consume(entity); 198 | } finally { 199 | response.close(); 200 | } 201 | 202 | return response_content; 203 | } 204 | 205 | } 206 | 207 | ``` 208 | * **Golang:**
209 | ```go 210 | package main 211 | 212 | import ( 213 | "fmt" 214 | "io/ioutil" 215 | "log" 216 | "net/http" 217 | "net/url" 218 | "os" 219 | ) 220 | 221 | 222 | func main() { 223 | client := &http.Client{} 224 | req, err := http.NewRequest("GET","https://fxhapi.feixiaohao.com/public/v1/ticker", nil) 225 | if err != nil { 226 | log.Print(err) 227 | os.Exit(1) 228 | } 229 | 230 | q := url.Values{} 231 | q.Add("start", "5") 232 | q.Add("limit", "5") 233 | q.Add("convert", "USD") 234 | 235 | req.Header.Set("Accepts", "application/json") 236 | req.URL.RawQuery = q.Encode() 237 | 238 | 239 | resp, err := client.Do(req); 240 | if err != nil { 241 | fmt.Println("Error sending request to server") 242 | os.Exit(1) 243 | } 244 | fmt.Println(resp.Status); 245 | respBody, _ := ioutil.ReadAll(resp.Body) 246 | fmt.Println(string(respBody)); 247 | 248 | } 249 | ``` 250 | --------------------------------------------------------------------------------