API/CoinExchange.io/指定した通貨の通貨情報を取得する・getcurrency(PowerShell)
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
開始行:
#navi(../)
* PowerShellでCoinExchange.ioで扱う通貨の情報を取得する方...
getcurrency APIは、getcurrencies APIにより返却されたCurre...
指定したID(CurrencyID), コード(TickerCode)の通貨情報を返...
以下、PowerShellによる、TickerCode, CurrencyIDを指定して...
----
&htmlinsert(coinexchange.io.html);へのリンク~
#htmlinsert(coinexchange.io.logo.html)
----
#contents
* 追記 [#i3c708c3]
-2018/7/5~
''「サーバーによってプロトコル違反が発生しました. Section...
が出力されるようであれば、以下リンク記事を参考にしてくだ...
-[[Section=ResponseHeader Detail=CR の後には LF...の対処...
* 関連資料・記事 [#qba74c6c]
-[[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...
* CurrencyID, TickerCodeは、getcurrencies APIにより一覧を...
getcurrencies APIについては、以下のリンク先の記事を参照し...
-[[仮想通貨一覧を取得・getcurrencies>API/CoinExchange.io/...
メジャーな仮想通貨のCurrencyID, TickerCodeを取得してみま...
PS C:\> [Net.ServicePointManager]::SecurityProtocol = [N...
PS C:\> $currencies = Invoke-RestMethod -UseBasicParsing...
PS C:\> $target = @("bitcoin", "bitcoin cash", "litecoin...
PS C:\> $currencies.result | % { if ($target -contains $...
CurrencyID Name TickerCode WalletStatus Type
---------- ---- ---------- ------------ ----
344 Bitcoin Cash BCH online currency
1 Bitcoin BTC online currency
70 Ethereum ETH online currency
2 Litecoin LTC online currency
上記の出力をみると、CurrencyID, TickerCode が取得できてい...
以下、このCurrencyID, TickerCodeを利用します。
* getcurrency APIの仕様 [#o171eb42]
[[CoinExchange.io API v1 Reference>http://coinexchangeio....
Get Currency
This endpoint retrieves information about a single curr...
HTTP Request
GET https://www.coinexchange.io/api/v1/getcurrency?curre...
or
GET https://www.coinexchange.io/api/v1/getcurrency?ticke...
Query Parameters
Parameter Type Description
currency_id integer Determines the currency to be retu...
ticker_code string Dtermines the currency to be retur...
'getcurrency’ returns JSON structured like this:
{
"success":"1",
"request":"\/api\/v1\/getcurrency",
"message":"",
"result":{
"CurrencyID":"1",
"Name":"Bitcoin",
"TickerCode":"BTC",
"WalletStatus":"online",
"Type":"currency"
}
}
* CurrencyID, TickerCodeを指定して通貨情報を取得 [#t2c222...
以下、CurrencyID, TickerCodeを指定して通貨情報を取得しま...
- currency_id = 1 (=BTC)
PS C:\> [Net.ServicePointManager]::SecurityProtocol = [N...
PS C:\> $currency = Invoke-RestMethod -UseBasicParsing "...
PS C:\> $currency
success request message result
------- ------- ------- ------
1 /api/v1/getcurrency @{CurrencyID=1; Name...
PS C:\> $currency.result
CurrencyID : 1
Name : Bitcoin
TickerCode : BTC
WalletStatus : online
Type : currency
- ticker_code=ETH
PS C:\> $currency = Invoke-RestMethod -UseBasicParsing "...
PS C:\> $currency
success request message result
------- ------- ------- ------
1 /api/v1/getcurrency @{CurrencyID=70; Nam...
PS C:\> $currency.result
CurrencyID : 70
Name : Ethereum
TickerCode : ETH
WalletStatus : online
Type : currency
上記の出力の通り、BTCとETHの通貨情報が取得できました。
* HTTPステータスなどを一緒に取得したい場合はInvoke-WebReq...
上記では、Invoke-RestMethodにてJSONをPowerShellで扱いやす...
Webサーバから返却された値を変換せずに取得したい場合は、In...
また、取得後にJSONをPowerShellで扱いやすいオブジェクトに...
+セキュリティプロトコルをTLS1.2に変更します。(2018/5/31時...
PS C:\> [Net.ServicePointManager]::SecurityProtocol = [N...
+Invoke-WebRequestコマンドレットでAPIを呼び出し返却された...
PS C:\> $response = Invoke-WebRequest -UseBasicParsing "...
+返却された情報を表示してみます。
PS C:\> $response
StatusCode : 200
StatusDescription : OK
Content : {"success":"1","request":"\/api\/v1\...
Ethereum","TickerCode":"ETH","Wallet...
RawContent : HTTP/1.1 200 OK
Connection: keep-alive
x-frame-options: SAMEORIGIN
Content-Length: 171
Cache-Control: no-cache
Content-Type: application/json
Date: Wed, 20 Jun 2018 05:34:43 GMT
Set-Cookie: vis...
Forms :
Headers : {[Connection, keep-alive], [x-frame-...
-cache]...}
Images : {}
InputFields : {}
Links : {}
ParsedHtml :
RawContentLength : 171
+ 各種HTTPの情報が簡単に取得できます。
PS C:\> $response.StatusCode
200
PS C:\> $response.Headers.'Content-Type'
application/json
+ConvertFrom-Jsonを使うとContentの内容をInvoke-RestMethod...
PS C:\> $json = ConvertFrom-Json($response.Content)
PS C:\> $json
success request message result
------- ------- ------- ------
1 /api/v1/getcurrency @{CurrencyID=70; Nam...
PS C:\> $json.result
CurrencyID : 70
Name : Ethereum
TickerCode : ETH
WalletStatus : online
Type : currency
* Webの応答を読み取っています。(Waiting for response)を非...
上記のコマンドレットを実行すると、APIサーバとのやり取りの...
#ref(02.png)
これを非表示にしたい場合は、以下のようにしてください。
非表示にするには、$ProgressPreferenceにSilentlyContinueを...
変更前は以下のように Continue が設定されています。
PS C:\> $ProgressPreference
Continue
非表示にするには、以下のように変更します。
PS C:\> $ProgressPreference = "SilentlyContinue"
以上、PowerShellを使って、&htmlinsert(coinexchange.io.htm...
通貨情報を取得する操作例でした。
----
&htmlinsert(coinexchange.io.html);へのリンク~
#htmlinsert(coinexchange.io.logo.html)
終了行:
#navi(../)
* PowerShellでCoinExchange.ioで扱う通貨の情報を取得する方...
getcurrency APIは、getcurrencies APIにより返却されたCurre...
指定したID(CurrencyID), コード(TickerCode)の通貨情報を返...
以下、PowerShellによる、TickerCode, CurrencyIDを指定して...
----
&htmlinsert(coinexchange.io.html);へのリンク~
#htmlinsert(coinexchange.io.logo.html)
----
#contents
* 追記 [#i3c708c3]
-2018/7/5~
''「サーバーによってプロトコル違反が発生しました. Section...
が出力されるようであれば、以下リンク記事を参考にしてくだ...
-[[Section=ResponseHeader Detail=CR の後には LF...の対処...
* 関連資料・記事 [#qba74c6c]
-[[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...
* CurrencyID, TickerCodeは、getcurrencies APIにより一覧を...
getcurrencies APIについては、以下のリンク先の記事を参照し...
-[[仮想通貨一覧を取得・getcurrencies>API/CoinExchange.io/...
メジャーな仮想通貨のCurrencyID, TickerCodeを取得してみま...
PS C:\> [Net.ServicePointManager]::SecurityProtocol = [N...
PS C:\> $currencies = Invoke-RestMethod -UseBasicParsing...
PS C:\> $target = @("bitcoin", "bitcoin cash", "litecoin...
PS C:\> $currencies.result | % { if ($target -contains $...
CurrencyID Name TickerCode WalletStatus Type
---------- ---- ---------- ------------ ----
344 Bitcoin Cash BCH online currency
1 Bitcoin BTC online currency
70 Ethereum ETH online currency
2 Litecoin LTC online currency
上記の出力をみると、CurrencyID, TickerCode が取得できてい...
以下、このCurrencyID, TickerCodeを利用します。
* getcurrency APIの仕様 [#o171eb42]
[[CoinExchange.io API v1 Reference>http://coinexchangeio....
Get Currency
This endpoint retrieves information about a single curr...
HTTP Request
GET https://www.coinexchange.io/api/v1/getcurrency?curre...
or
GET https://www.coinexchange.io/api/v1/getcurrency?ticke...
Query Parameters
Parameter Type Description
currency_id integer Determines the currency to be retu...
ticker_code string Dtermines the currency to be retur...
'getcurrency’ returns JSON structured like this:
{
"success":"1",
"request":"\/api\/v1\/getcurrency",
"message":"",
"result":{
"CurrencyID":"1",
"Name":"Bitcoin",
"TickerCode":"BTC",
"WalletStatus":"online",
"Type":"currency"
}
}
* CurrencyID, TickerCodeを指定して通貨情報を取得 [#t2c222...
以下、CurrencyID, TickerCodeを指定して通貨情報を取得しま...
- currency_id = 1 (=BTC)
PS C:\> [Net.ServicePointManager]::SecurityProtocol = [N...
PS C:\> $currency = Invoke-RestMethod -UseBasicParsing "...
PS C:\> $currency
success request message result
------- ------- ------- ------
1 /api/v1/getcurrency @{CurrencyID=1; Name...
PS C:\> $currency.result
CurrencyID : 1
Name : Bitcoin
TickerCode : BTC
WalletStatus : online
Type : currency
- ticker_code=ETH
PS C:\> $currency = Invoke-RestMethod -UseBasicParsing "...
PS C:\> $currency
success request message result
------- ------- ------- ------
1 /api/v1/getcurrency @{CurrencyID=70; Nam...
PS C:\> $currency.result
CurrencyID : 70
Name : Ethereum
TickerCode : ETH
WalletStatus : online
Type : currency
上記の出力の通り、BTCとETHの通貨情報が取得できました。
* HTTPステータスなどを一緒に取得したい場合はInvoke-WebReq...
上記では、Invoke-RestMethodにてJSONをPowerShellで扱いやす...
Webサーバから返却された値を変換せずに取得したい場合は、In...
また、取得後にJSONをPowerShellで扱いやすいオブジェクトに...
+セキュリティプロトコルをTLS1.2に変更します。(2018/5/31時...
PS C:\> [Net.ServicePointManager]::SecurityProtocol = [N...
+Invoke-WebRequestコマンドレットでAPIを呼び出し返却された...
PS C:\> $response = Invoke-WebRequest -UseBasicParsing "...
+返却された情報を表示してみます。
PS C:\> $response
StatusCode : 200
StatusDescription : OK
Content : {"success":"1","request":"\/api\/v1\...
Ethereum","TickerCode":"ETH","Wallet...
RawContent : HTTP/1.1 200 OK
Connection: keep-alive
x-frame-options: SAMEORIGIN
Content-Length: 171
Cache-Control: no-cache
Content-Type: application/json
Date: Wed, 20 Jun 2018 05:34:43 GMT
Set-Cookie: vis...
Forms :
Headers : {[Connection, keep-alive], [x-frame-...
-cache]...}
Images : {}
InputFields : {}
Links : {}
ParsedHtml :
RawContentLength : 171
+ 各種HTTPの情報が簡単に取得できます。
PS C:\> $response.StatusCode
200
PS C:\> $response.Headers.'Content-Type'
application/json
+ConvertFrom-Jsonを使うとContentの内容をInvoke-RestMethod...
PS C:\> $json = ConvertFrom-Json($response.Content)
PS C:\> $json
success request message result
------- ------- ------- ------
1 /api/v1/getcurrency @{CurrencyID=70; Nam...
PS C:\> $json.result
CurrencyID : 70
Name : Ethereum
TickerCode : ETH
WalletStatus : online
Type : currency
* Webの応答を読み取っています。(Waiting for response)を非...
上記のコマンドレットを実行すると、APIサーバとのやり取りの...
#ref(02.png)
これを非表示にしたい場合は、以下のようにしてください。
非表示にするには、$ProgressPreferenceにSilentlyContinueを...
変更前は以下のように Continue が設定されています。
PS C:\> $ProgressPreference
Continue
非表示にするには、以下のように変更します。
PS C:\> $ProgressPreference = "SilentlyContinue"
以上、PowerShellを使って、&htmlinsert(coinexchange.io.htm...
通貨情報を取得する操作例でした。
----
&htmlinsert(coinexchange.io.html);へのリンク~
#htmlinsert(coinexchange.io.logo.html)
ページ名: