API/CoinExchange.io/マーケットサマリ情報取得・getmarketsummaries(PowerShell)
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
開始行:
#navi(../)
* PowerShellでCoinExchange.ioのgetmarketsummaries APIにア...
&htmlinsert(coinexchange.io.html);の''getmarketsummaries'...
#contents
----
&htmlinsert(coinexchange.io.html);へのリンク~
#htmlinsert(coinexchange.io.logo.html)
----
* 追記 [#bf9fe5e3]
-2018/7/5~
''「サーバーによってプロトコル違反が発生しました. Section...
が出力されるようであれば、以下リンク記事を参考にしてくだ...
-[[Section=ResponseHeader Detail=CR の後には LF...の対処...
* 関連資料・記事 [#f398779b]
-[[CoinExchange.io API v1 Reference>http://coinexchangeio...
-[[マーケット一覧情報取得・getmarkets(PowerShell)>API/Coi...
-[[マーケットサマリ情報取得・getmarketsummaries(PowerShel...
-[[指定した通貨ペアのマーケットサマリ情報を取得・getmarke...
-[[MarketID一覧情報を取得する>API/CoinExchange.io/MarketI...
-[[仮想通貨一覧を取得・getcurrencies>API/CoinExchange.io/...
-[[指定した通貨の通貨情報を取得する・getcurrency>API/Coin...
* ''getmarketsummaries''の仕様 [#e655e8ae]
以下、[[CoinExchange.io API v1 Reference>http://coinexcha...
Get Market Summaries
This endpoint retrieves summaries for all markets.
HTTP Request
GET https://www.coinexchange.io/api/v1/getmarketsummaries
'getmarketsummaries' returns JSON structured like this:
{
"success": "1",
"request": "/api/v1/public/getmarketsummaries",
"message": "",
"result": [
{
"MarketID": "1",
"LastPrice": "0.00902321",
"Change": "2.01",
"HighPrice": "0.00961681",
"LowPrice": "0.00853751",
"Volume": "3043.78746852",
"BTCVolume": "3043.78746852",
"TradeCount": "1332",
"BidPrice": "0.00902321",
"AskPrice": "0.00928729",
"BuyOrderCount": "7796",
"SellOrderCount": "7671"
},
{
"MarketID": "3",
"LastPrice": "0.05000000",
"Change": "0.00",
"HighPrice": "0.00000000",
"LowPrice": "0.00000000",
"Volume": "0.00000000",
"BTCVolume": "0.00000000",
"TradeCount": "0",
"BidPrice": "0.00000000",
"AskPrice": "0.02000000",
"BuyOrderCount": "0",
"SellOrderCount": "1"
}
]
}
* getmarketsummaries APIをブラウザでアクセスしてみる [#o9...
以下のURLにブラウザでアクセスしてみます。~
- https://www.coinexchange.io/api/v1/getmarketsummaries
FirefoxだとJSON形式で確認することができます。~
|''JSON''|''生データ''|
|&ref(01.png);|&ref(02.png);|
* PowerShellのInvoke-RestMethodを使用してAPIを呼び出して...
実際に、&htmlinsert(coinexchange.io.html);の''getmarketsu...
+ セキュリティプロトコルをTLS1.2に変更します。(2018/5/31...
PS C:\> [Net.ServicePointManager]::SecurityProtocol = [N...
+呼び出し元のURL情報を各変数に設定しています。
PS C:\> $base_url = "https://www.coinexchange.io/api/"
PS C:\> $version = "v1"
PS C:\> $method = "getmarketsummaries"
+''getmarketsummaries'' APIのURLをInvoke-RestMethodの引数...
PS C:\> $response = Invoke-RestMethod -UseBasicParsing "...
+''getmarkets''から返却された値を表示しています。
PS C:\> $response
success request message result
------- ------- ------- ------
1 /api/v1/getmarketsummaries {@{MarketID=1...
** 取得した値から各種値を抽出する [#t7869ca8]
上記で取得し、$responseに格納した値を操作してみます。
+取得したレスポンスは以下のようになっています。
PS C:\> $response
success request message result
------- ------- ------- ------
1 /api/v1/getmarketsummaries {@{MarketID=1...
+ success, request, resultを表示してみます。
PS C:\> $response.success
1
PS C:\> $response.request
/api/v1/getmarketsummaries
PS C:\> $response.result.Count
689
PS C:\> $response.result[0]
MarketID : 18
LastPrice : 0.01584000
Change : 0.32
HighPrice : 0.01599963
LowPrice : 0.01562021
Volume : 4.41002465
BTCVolume : 4.41002465
TradeCount : 404
BidPrice : 0.01584000
AskPrice : 0.01590000
BuyOrderCount : 251
SellOrderCount : 841
上記のresult配列内の情報を見るとMarketIDとなっており、ど...
以下に、銘柄をgetmarkets APIから検索しMarketIDを取得し、...
getmarketsについては、以下のリンクに記事を公開しています。
-[[マーケット一覧情報取得・getmarkets(PowerShell)>API/Coi...
** getmarketsとgetmarketsummaries APIを使用し任意の通貨ペ...
getmarketsummaries APIだとMarketIDしかないので、知りたい...
MarketIDを調べるには、getmarkets APIを使用します。
*** XSH/DOGEペアのマーケット情報を取得してみる [#zfa9850b]
以下の操作例は、XSH/DOGEのマーケット情報する操作例です。
+ APIのエンドポイントとバージョン文字列を変数に設定してい...
PS C:\> $base_url = "https://www.coinexchange.io/api/"
PS C:\> $version = "v1"
+通貨ペアを指定しています。(XSH/DOGE)
PS C:\> $MarketAssetCode = "XSH"
PS C:\> $BaseCurrencyCode = "DOGE"
+APIメソッド名を設定しています。
PS C:\> $method = "getmarkets"
+ セキュリティプロトコルをTLS1.2に変更します。(2018/5/31...
PS C:\> [Net.ServicePointManager]::SecurityProtocol = [N...
+ Invoke-RestMethodでgetmarkets APIを呼び出しています。
PS C:\> $markets = Invoke-RestMethod -UseBasicParsing "$...
+getmarketsで取得した情報は以下の通りです。
PS C:\> $markets
success request message result
------- ------- ------- ------
1 /api/v1/getmarkets {@{MarketID=18; Marke...
+XSH/DOGEのMarketIDを取得します。
PS C:\> $markets.result | % { if ($_.MarketAssetCode -eq...
+ 取得した情報を表示しています。~
MarketIDが705であるのが確認できます。
MarketID : 705
MarketAssetName : Shield
MarketAssetCode : XSH
MarketAssetID : 532
MarketAssetType : currency
BaseCurrency : Dogecoin
BaseCurrencyCode : DOGE
BaseCurrencyID : 4
Active : True
尚、上記の1ラインで$MarketID変数にMarketIDの値(今回は705)...
PS C:\> $MarketID
705
+getmarketsummaries APIでマーケット情報を取得します。
+APIメソッド名を指定しています。
PS C:\> $method = "getmarketsummaries"
+ Invoke-RestMethodでgetmarketsummaries APIを呼び出してい...
PS C:\> $response = Invoke-RestMethod -UseBasicParsing "...
+getmarketsummariesで取得した情報は以下の通りです。
PS C:\> $response
success request message result
------- ------- ------- ------
1 /api/v1/getmarketsummaries {@{MarketID=1...
+上記で取得した(getmarkets API)MarketID(この例では705)を...
PS C:\> $response.result | % { if ($_.MarketId -eq $Mark...
MarketID : 705
LastPrice : 9.03501247
Change : -9.65
HighPrice : 9.99999973
LowPrice : 9.01202065
Volume : 50527.55224379
BTCVolume : 0.02273740
TradeCount : 21
BidPrice : 9.03501250
AskPrice : 9.75998861
BuyOrderCount : 348
SellOrderCount : 292
以下のスクリーンショットを見ると、同じ値が取得されている...
#ref(04.png)
* HTTPステータスなどを一緒に取得したい場合はInvoke-WebReq...
上記では、Invoke-RestMethodにてJSONをPowerShellで扱いやす...
Webサーバから返却された値を変換せずに取得したい場合は、In...
また、取得後にJSONをPowerShellで扱いやすいオブジェクトに...
以下に実行例を記します。
+ セキュリティプロトコルをTLS1.2に変更します。(2018/5/31...
PS C:\> [Net.ServicePointManager]::SecurityProtocol = [N...
+ APIのURL作成用の文字列を変数に格納しています。
PS C:\> $base_url = "https://www.coinexchange.io/api/"
PS C:\> $version = "v1"
PS C:\> $method = "getmarketsummaries"
+ Invoke-WebRequestコマンドレットでAPIを呼び出し返却され...
PS C:\> $response = Invoke-WebRequest -UseBasicParsing "...
+返却された情報を表示してみます。
PS C:\> $response
StatusCode : 200
StatusDescription : OK
Content : {"success":"1","request":"\/api\/v1\...
astPrice":"0.01582001","Change":"0.4...
.3...
RawContent : HTTP/1.1 200 OK
Transfer-Encoding: chunked
Connection: keep-alive
x-frame-options: SAMEORIGIN
Cache-Control: no-cache
Content-Type: application/json
Date: Fri, 01 Jun 2018 15:22:18 GMT
Set-Cook...
Forms :
Headers : {[Transfer-Encoding, chunked], [Conn...
rol, no-cache]...}
Images : {}
InputFields : {}
Links : {}
ParsedHtml :
RawContentLength : 183771
+ HTTPステータスやContent-Typeを簡単に取得することができ...
PS C:\> $response.StatusCode
200
PS C:\> $response.Headers.'Content-Type'
application/json
+ ConvertFrom-Jsonを使ってみます。
PS C:\> $json = ConvertFrom-Json($response.Content)
PS C:\> $json
success request message result
------- ------- ------- ------
1 /api/v1/getmarketsummaries {@{MarketID=1...
PS C:\> $json.result[0]
MarketID : 18
LastPrice : 0.01582001
Change : 0.42
HighPrice : 0.01599963
LowPrice : 0.01562021
Volume : 4.32781232
BTCVolume : 4.32781232
TradeCount : 405
BidPrice : 0.01583001
AskPrice : 0.01590000
BuyOrderCount : 248
SellOrderCount : 842
** Webの応答を読み取っています。(Waiting for response)を...
上記のコマンドレットを実行すると、APIサーバとのやり取りの...
#ref(03.png)
これを非表示にしたい場合は、以下のようにしてください。
非表示にするには、$ProgressPreferenceにSilentlyContinueを...
変更前は以下のように Continue が設定されています。
PS C:\> $ProgressPreference
Continue
非表示にするには、以下のように変更します。
PS C:\> $ProgressPreference = "SilentlyContinue"
以上、PowerShellを使って、&htmlinsert(coinexchang.io.html...
任意の通貨ペアのマーケット情報を取得する操作例でした。
----
&htmlinsert(coinexchange.io.html);へのリンク~
#htmlinsert(coinexchange.io.logo.html)
終了行:
#navi(../)
* PowerShellでCoinExchange.ioのgetmarketsummaries APIにア...
&htmlinsert(coinexchange.io.html);の''getmarketsummaries'...
#contents
----
&htmlinsert(coinexchange.io.html);へのリンク~
#htmlinsert(coinexchange.io.logo.html)
----
* 追記 [#bf9fe5e3]
-2018/7/5~
''「サーバーによってプロトコル違反が発生しました. Section...
が出力されるようであれば、以下リンク記事を参考にしてくだ...
-[[Section=ResponseHeader Detail=CR の後には LF...の対処...
* 関連資料・記事 [#f398779b]
-[[CoinExchange.io API v1 Reference>http://coinexchangeio...
-[[マーケット一覧情報取得・getmarkets(PowerShell)>API/Coi...
-[[マーケットサマリ情報取得・getmarketsummaries(PowerShel...
-[[指定した通貨ペアのマーケットサマリ情報を取得・getmarke...
-[[MarketID一覧情報を取得する>API/CoinExchange.io/MarketI...
-[[仮想通貨一覧を取得・getcurrencies>API/CoinExchange.io/...
-[[指定した通貨の通貨情報を取得する・getcurrency>API/Coin...
* ''getmarketsummaries''の仕様 [#e655e8ae]
以下、[[CoinExchange.io API v1 Reference>http://coinexcha...
Get Market Summaries
This endpoint retrieves summaries for all markets.
HTTP Request
GET https://www.coinexchange.io/api/v1/getmarketsummaries
'getmarketsummaries' returns JSON structured like this:
{
"success": "1",
"request": "/api/v1/public/getmarketsummaries",
"message": "",
"result": [
{
"MarketID": "1",
"LastPrice": "0.00902321",
"Change": "2.01",
"HighPrice": "0.00961681",
"LowPrice": "0.00853751",
"Volume": "3043.78746852",
"BTCVolume": "3043.78746852",
"TradeCount": "1332",
"BidPrice": "0.00902321",
"AskPrice": "0.00928729",
"BuyOrderCount": "7796",
"SellOrderCount": "7671"
},
{
"MarketID": "3",
"LastPrice": "0.05000000",
"Change": "0.00",
"HighPrice": "0.00000000",
"LowPrice": "0.00000000",
"Volume": "0.00000000",
"BTCVolume": "0.00000000",
"TradeCount": "0",
"BidPrice": "0.00000000",
"AskPrice": "0.02000000",
"BuyOrderCount": "0",
"SellOrderCount": "1"
}
]
}
* getmarketsummaries APIをブラウザでアクセスしてみる [#o9...
以下のURLにブラウザでアクセスしてみます。~
- https://www.coinexchange.io/api/v1/getmarketsummaries
FirefoxだとJSON形式で確認することができます。~
|''JSON''|''生データ''|
|&ref(01.png);|&ref(02.png);|
* PowerShellのInvoke-RestMethodを使用してAPIを呼び出して...
実際に、&htmlinsert(coinexchange.io.html);の''getmarketsu...
+ セキュリティプロトコルをTLS1.2に変更します。(2018/5/31...
PS C:\> [Net.ServicePointManager]::SecurityProtocol = [N...
+呼び出し元のURL情報を各変数に設定しています。
PS C:\> $base_url = "https://www.coinexchange.io/api/"
PS C:\> $version = "v1"
PS C:\> $method = "getmarketsummaries"
+''getmarketsummaries'' APIのURLをInvoke-RestMethodの引数...
PS C:\> $response = Invoke-RestMethod -UseBasicParsing "...
+''getmarkets''から返却された値を表示しています。
PS C:\> $response
success request message result
------- ------- ------- ------
1 /api/v1/getmarketsummaries {@{MarketID=1...
** 取得した値から各種値を抽出する [#t7869ca8]
上記で取得し、$responseに格納した値を操作してみます。
+取得したレスポンスは以下のようになっています。
PS C:\> $response
success request message result
------- ------- ------- ------
1 /api/v1/getmarketsummaries {@{MarketID=1...
+ success, request, resultを表示してみます。
PS C:\> $response.success
1
PS C:\> $response.request
/api/v1/getmarketsummaries
PS C:\> $response.result.Count
689
PS C:\> $response.result[0]
MarketID : 18
LastPrice : 0.01584000
Change : 0.32
HighPrice : 0.01599963
LowPrice : 0.01562021
Volume : 4.41002465
BTCVolume : 4.41002465
TradeCount : 404
BidPrice : 0.01584000
AskPrice : 0.01590000
BuyOrderCount : 251
SellOrderCount : 841
上記のresult配列内の情報を見るとMarketIDとなっており、ど...
以下に、銘柄をgetmarkets APIから検索しMarketIDを取得し、...
getmarketsについては、以下のリンクに記事を公開しています。
-[[マーケット一覧情報取得・getmarkets(PowerShell)>API/Coi...
** getmarketsとgetmarketsummaries APIを使用し任意の通貨ペ...
getmarketsummaries APIだとMarketIDしかないので、知りたい...
MarketIDを調べるには、getmarkets APIを使用します。
*** XSH/DOGEペアのマーケット情報を取得してみる [#zfa9850b]
以下の操作例は、XSH/DOGEのマーケット情報する操作例です。
+ APIのエンドポイントとバージョン文字列を変数に設定してい...
PS C:\> $base_url = "https://www.coinexchange.io/api/"
PS C:\> $version = "v1"
+通貨ペアを指定しています。(XSH/DOGE)
PS C:\> $MarketAssetCode = "XSH"
PS C:\> $BaseCurrencyCode = "DOGE"
+APIメソッド名を設定しています。
PS C:\> $method = "getmarkets"
+ セキュリティプロトコルをTLS1.2に変更します。(2018/5/31...
PS C:\> [Net.ServicePointManager]::SecurityProtocol = [N...
+ Invoke-RestMethodでgetmarkets APIを呼び出しています。
PS C:\> $markets = Invoke-RestMethod -UseBasicParsing "$...
+getmarketsで取得した情報は以下の通りです。
PS C:\> $markets
success request message result
------- ------- ------- ------
1 /api/v1/getmarkets {@{MarketID=18; Marke...
+XSH/DOGEのMarketIDを取得します。
PS C:\> $markets.result | % { if ($_.MarketAssetCode -eq...
+ 取得した情報を表示しています。~
MarketIDが705であるのが確認できます。
MarketID : 705
MarketAssetName : Shield
MarketAssetCode : XSH
MarketAssetID : 532
MarketAssetType : currency
BaseCurrency : Dogecoin
BaseCurrencyCode : DOGE
BaseCurrencyID : 4
Active : True
尚、上記の1ラインで$MarketID変数にMarketIDの値(今回は705)...
PS C:\> $MarketID
705
+getmarketsummaries APIでマーケット情報を取得します。
+APIメソッド名を指定しています。
PS C:\> $method = "getmarketsummaries"
+ Invoke-RestMethodでgetmarketsummaries APIを呼び出してい...
PS C:\> $response = Invoke-RestMethod -UseBasicParsing "...
+getmarketsummariesで取得した情報は以下の通りです。
PS C:\> $response
success request message result
------- ------- ------- ------
1 /api/v1/getmarketsummaries {@{MarketID=1...
+上記で取得した(getmarkets API)MarketID(この例では705)を...
PS C:\> $response.result | % { if ($_.MarketId -eq $Mark...
MarketID : 705
LastPrice : 9.03501247
Change : -9.65
HighPrice : 9.99999973
LowPrice : 9.01202065
Volume : 50527.55224379
BTCVolume : 0.02273740
TradeCount : 21
BidPrice : 9.03501250
AskPrice : 9.75998861
BuyOrderCount : 348
SellOrderCount : 292
以下のスクリーンショットを見ると、同じ値が取得されている...
#ref(04.png)
* HTTPステータスなどを一緒に取得したい場合はInvoke-WebReq...
上記では、Invoke-RestMethodにてJSONをPowerShellで扱いやす...
Webサーバから返却された値を変換せずに取得したい場合は、In...
また、取得後にJSONをPowerShellで扱いやすいオブジェクトに...
以下に実行例を記します。
+ セキュリティプロトコルをTLS1.2に変更します。(2018/5/31...
PS C:\> [Net.ServicePointManager]::SecurityProtocol = [N...
+ APIのURL作成用の文字列を変数に格納しています。
PS C:\> $base_url = "https://www.coinexchange.io/api/"
PS C:\> $version = "v1"
PS C:\> $method = "getmarketsummaries"
+ Invoke-WebRequestコマンドレットでAPIを呼び出し返却され...
PS C:\> $response = Invoke-WebRequest -UseBasicParsing "...
+返却された情報を表示してみます。
PS C:\> $response
StatusCode : 200
StatusDescription : OK
Content : {"success":"1","request":"\/api\/v1\...
astPrice":"0.01582001","Change":"0.4...
.3...
RawContent : HTTP/1.1 200 OK
Transfer-Encoding: chunked
Connection: keep-alive
x-frame-options: SAMEORIGIN
Cache-Control: no-cache
Content-Type: application/json
Date: Fri, 01 Jun 2018 15:22:18 GMT
Set-Cook...
Forms :
Headers : {[Transfer-Encoding, chunked], [Conn...
rol, no-cache]...}
Images : {}
InputFields : {}
Links : {}
ParsedHtml :
RawContentLength : 183771
+ HTTPステータスやContent-Typeを簡単に取得することができ...
PS C:\> $response.StatusCode
200
PS C:\> $response.Headers.'Content-Type'
application/json
+ ConvertFrom-Jsonを使ってみます。
PS C:\> $json = ConvertFrom-Json($response.Content)
PS C:\> $json
success request message result
------- ------- ------- ------
1 /api/v1/getmarketsummaries {@{MarketID=1...
PS C:\> $json.result[0]
MarketID : 18
LastPrice : 0.01582001
Change : 0.42
HighPrice : 0.01599963
LowPrice : 0.01562021
Volume : 4.32781232
BTCVolume : 4.32781232
TradeCount : 405
BidPrice : 0.01583001
AskPrice : 0.01590000
BuyOrderCount : 248
SellOrderCount : 842
** Webの応答を読み取っています。(Waiting for response)を...
上記のコマンドレットを実行すると、APIサーバとのやり取りの...
#ref(03.png)
これを非表示にしたい場合は、以下のようにしてください。
非表示にするには、$ProgressPreferenceにSilentlyContinueを...
変更前は以下のように Continue が設定されています。
PS C:\> $ProgressPreference
Continue
非表示にするには、以下のように変更します。
PS C:\> $ProgressPreference = "SilentlyContinue"
以上、PowerShellを使って、&htmlinsert(coinexchang.io.html...
任意の通貨ペアのマーケット情報を取得する操作例でした。
----
&htmlinsert(coinexchange.io.html);へのリンク~
#htmlinsert(coinexchange.io.logo.html)
ページ名: