- 追加された行はこの色です。
- 削除された行はこの色です。
#author("2018-06-17T02:04:21+09:00","","")
#author("2018-06-20T14:46:52+09:00","","")
#navi(../)
* CoinExchange.ioのMarketID一覧を取得する(PowerShell) [#g5fd0a61]
&htmlinsert(coinexchange.io.html);のAPIで、getmarketsummary, getorderbook APIでは、market_idが必要となります。~
そこで、getmarkets APIからMarketID(market_id)一覧を取得し表形式とCSV出力する手順を以下に記します。
#contents
----
&htmlinsert(coinexchange.io.html);へのリンク~
#htmlinsert(coinexchange.io.logo.html)
----
* 関連資料・記事 [#ied9425c]
-[[CoinExchange.io API v1 Reference>http://coinexchangeio.github.io/slate/]]
-[[マーケット一覧情報取得・getmarkets(PowerShell)>API/CoinExchange.io/マーケット一覧情報取得・getmarkets(PowerShell)]]
-[[マーケットサマリ情報取得・getmarketsummaries(PowerShell)>API/CoinExchange.io/マーケットサマリ情報取得・getmarketsummaries(PowerShell)]]
-[[指定した通貨ペアのマーケットサマリ情報を取得・getmarketsummary(PowerShell)>API/CoinExchange.io/指定した通貨ペアのマーケットサマリ情報を取得・getmarketsummary(PowerShell)]]
-[[MarketID一覧情報を取得する>API/CoinExchange.io/MarketID一覧を取得する・getmarkets(PowerShell)]]
-[[仮想通貨一覧を取得・getcurrencies>API/CoinExchange.io/仮想通貨一覧を取得・getcurrencies(PowerShell)]]
-[[指定した通貨の通貨情報を取得する・getcurrency>API/CoinExchange.io/指定した通貨の通貨情報を取得する・getcurrency(PowerShell)]]
* MarketIDの一覧を取得し表形式に表示する方法 [#ee52be42]
getmarkets APIにより取得したMarketID一覧情報を表形式に表示する場合は、以下の手順となります。
//[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
//$getmarkets_url = "https://www.coinexchange.io/api/v1/getmarkets"
//$markets = Invoke-RestMethod -UseBasicParsing $getmarkets_url
//$markets.result | Format-Table
PS C:\> [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
PS C:\> $getmarkets_url = "https://www.coinexchange.io/api/v1/getmarkets"
PS C:\> $markets = Invoke-RestMethod -UseBasicParsing $getmarkets_url
PS C:\> $markets.result | Format-Table
MarketID MarketAssetName MarketAssetCode MarketAssetID MarketAssetType BaseCurrency BaseCurrencyCode BaseCurrencyID Active
-------- --------------- --------------- ------------- --------------- ------------ ---------------- -------------- ------
18 Litecoin LTC 2 currency Bitcoin BTC 1 True
19 Unobtanium UNO 3 currency Bitcoin BTC 1 True
20 Syscoin SYS 5 currency Bitcoin BTC 1 False
21 Dogecoin DOGE 4 currency Bitcoin BTC 1 True
22 Kobocoin KOBO 6 currency Bitcoin BTC 1 True
23 Bitz BITZ 7 currency Bitcoin BTC 1 False
24 Digitalcoin DGC 8 currency Bitcoin BTC 1 True
25 Megacoin MEC 9 currency Bitcoin BTC 1 True
26 Bigup BIGUP 10 currency Bitcoin BTC 1 True
27 Memetic MEME 11 currency Bitcoin BTC 1 True
28 Lootcoin LOOT 12 currency Bitcoin BTC 1 False
29 FootyCash FOOT 13 currency Bitcoin BTC 1 False
30 Procom PCM 14 currency Bitcoin BTC 1 False
<省略>
* MarketIDの一覧を取得しCSVとして出力する方法 [#s648fc9c]
上記で取得したMarketID一覧情報をCSVに出力する手順は以下の通りです。~
csvファイルはデスクトップにmarket_id.csvとして出力されます。
PS C:\> [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
PS C:\> $getmarkets_url = "https://www.coinexchange.io/api/v1/getmarkets"
PS C:\> $markets = Invoke-RestMethod -UseBasicParsing $getmarkets_url
PS C:\> $markets.result.GetEnumerator() | Export-Csv -Encoding Default -Path $HOME\Desktop\market_id.csv
#ref(01.png)
上記Excelスクリーンショットの最上行にある ''#TYPE System...''を消したい場合は以下のように記述します。~
-方法1~
オプション ''-NoTypeInformation'' を追加~
以下のようになります。
$markets.result.GetEnumerator() | Export-Csv -NoTypeInformation -Encoding Default -Path $HOME\Desktop\market_id.csv
-方法2~
出力行のスキップ~
ConvertTo-CsvとSelect-Objectの-Skipオプションを使用して実現する~
以下のようになります。
$markets.result.GetEnumerator() | ConvertTo-Csv | Select-Object -Skip 1 | Out-File -Encoding default $HOME\market_id.csv
CSVのヘッダも消したい場合は、-Skipに2を指定すればデータ部のみのCSVとなります。
以上、&htmlinsert(coinexchange.io.html);のMarketID一覧情報をPowerShellで取得する手順でした。
----
&htmlinsert(coinexchange.io.html);へのリンク~
#htmlinsert(coinexchange.io.logo.html)