API/bitFlyer/Tickerの取得(PowerShell)
をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
]
開始行:
#navi(../)
* PowerShellでbitFlyerのTickerを取得・getticker [#h1c47038]
&color(red){当サイトに記載されている会社名、製品名などは...
----
PowerShellを使ってbitFlyerの[[Ticker>https://lightning.bi...
#contents
#htmlinsert(bitflyer_full.html)
* 関連記事 [#vcaccade]
-[[板情報(PowerShell)>API/bitFlyer/板情報の取得(PowerShel...
-[[マーケットの一覧(PowerShell)>API/bitFlyer/マーケットの...
-[[Ticker(PowerShell)>API/bitFlyer/Tickerの取得(PowerShel...
* TickerAPIの仕様など [#ie9464f3]
HTTP Public APIなのでbitFlyerに取引口座を開設していなくて...
TickerAPI仕様(bitFlyer APIページから抜粋) ~
リクエスト
GET /v1/getticker
GET /v1/ticker
クエリパラメータ
product_code: マーケットの一覧で取得できる product_cod...
省略した場合の値は BTC_JPY です。
レスポンス
{
"product_code": "BTC_JPY",
"timestamp": "2015-07-08T02:50:59.97",
"tick_id": 3579,
"best_bid": 30000,
"best_ask": 36640,
"best_bid_size": 0.1,
"best_ask_size": 5,
"total_bid_depth": 15.13,
"total_ask_depth": 20,
"ltp": 31690,
"volume": 16819.26,
"volume_by_product": 6819.26
}
timestamp: 時刻は UTC(協定世界時)で表されます。
ltp: 最終取引価格
volume: 24 時間の取引量
* ブラウザでTicker(getmarkets)を取得する [#af13928a]
GETなのでブラウザでTickerを取得することができます。~
以下のようなURLになります。~
product_codeを指定しています。
- BTC_JPY~
https://api.bitflyer.jp/v1/getticker?product_code=BTC_JPY
-FX_BTC_JPY~
https://api.bitflyer.jp/v1/getticker?product_code=FX_BTC_...
-ETH_BTC~
https://api.bitflyer.jp/v1/getticker?product_code=ETH_BTC
-BCH_BTC~
https://api.bitflyer.jp/v1/getticker?product_code=BCH_BTC
product_codeに関しては以下の記事を参照してください。~
-[[マーケットの一覧(PowerShell)>API/bitFlyer/マーケットの...
* ブラウザでTicker APIにアクセスした結果 [#ef984bc9]
上記のURLをブラウザでクリックした結果は以下の通りです。~
FirefoxではJSONが整形され表示されています。~
見やすいですね。~
(生データをクリックすると上記同様にJSON形式の返却された文...
- BTC_JPY~
https://api.bitflyer.jp/v1/getticker?product_code=BTC_JPY
#ref(01.png)
#br
-FX_BTC_JPY~
https://api.bitflyer.jp/v1/getticker?product_code=FX_BTC_...
#ref(02.png)
#br
-ETH_BTC~
https://api.bitflyer.jp/v1/getticker?product_code=ETH_BTC
#ref(03.png)
#br
-BCH_BTC~
https://api.bitflyer.jp/v1/getticker?product_code=BCH_BTC
#ref(04.png)
#br
* Invoke-RestMethodコマンドレットでbitFlyerのTickerを取得...
+Tickerを取得するURL(API)を設定します。
PS C:\> $ticker_api = "https://api.bitflyer.jp/v1/gettic...
+product_codeにBTC_JPYを指定します。
PS C:\> $product_code = "BTC_JPY"
+Invoke-RestMethodコマンドレットを使用し、返却されたTicke...
PS C:\> $ticker = Invoke-RestMethod -UseBasicParsing -Ur...
+取得したTicker情報を表示しています。
PS C:\> $ticker
product_code : BTC_JPY
timestamp : 2018-05-17T11:05:12.143
tick_id : 1387764
best_bid : 921501.0
best_ask : 921586.0
best_bid_size : 0.02804128
best_ask_size : 0.02
total_bid_depth : 2051.2378956
total_ask_depth : 3858.77283227
ltp : 921501.0
volume : 211785.4498822
volume_by_product : 15084.44930353
*HTTPステータスなどを一緒に取得したい場合 [#i880c368]
上記では、Invoke-RestMethodにてJSONをPowerShellで扱いやす...
しかし、Webサーバから返却された値を変換せず、取得後JSONを...
+Tickerを取得するURL(API)を設定します。
PS C:\> $ticker_api = "https://api.bitflyer.jp/v1/gettic...
+product_codeにBTC_JPYを指定します。
PS C:\> $product_code = "BTC_JPY"
+ Invoke-WebRequestコマンドレットでサーバからのレスポンス...
PS C:\> $res = Invoke-WebRequest -UseBasicParsing -Uri (...
+ 取得したレスポンスは以下の通りです。
PS C:\> $res
StatusCode : 200
StatusDescription : OK
Content : {"product_code":"BTC_JPY","timestamp...
.0,"best_ask":921515.0,"best_bid_siz...
ot...
RawContent : HTTP/1.1 200 OK
Connection: keep-alive
Pragma: no-cache
Request-Context: appId=cid-v1:e4fbc9...
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
X-Frame...
Forms :
Headers : {[Connection, keep-alive], [Pragma, ...
ac-f2180e904002], [X-Content-Type-Op...
Images : {}
InputFields : {}
Links : {}
ParsedHtml :
RawContentLength : 303
+HTTPステイタスを取得しています。
PS C:\> $res.StatusCode
200
+Contentに取得した情報が格納されています。
PS C:\> $json = ($res.Content | ConvertFrom-Json)
PS C:\> $json
product_code : BTC_JPY
timestamp : 2018-05-17T11:11:12.047
tick_id : 1395884
best_bid : 920920.0
best_ask : 921515.0
best_bid_size : 0.01
best_ask_size : 0.04
total_bid_depth : 2109.47686593
total_ask_depth : 3852.16647046
ltp : 920915.0
volume : 211442.00348458
volume_by_product : 15059.23366309
以上、PowerShellを使って、bitFlyerのTickerを取得・gettick...
#htmlinsert(bitflyer_full.html)
終了行:
#navi(../)
* PowerShellでbitFlyerのTickerを取得・getticker [#h1c47038]
&color(red){当サイトに記載されている会社名、製品名などは...
----
PowerShellを使ってbitFlyerの[[Ticker>https://lightning.bi...
#contents
#htmlinsert(bitflyer_full.html)
* 関連記事 [#vcaccade]
-[[板情報(PowerShell)>API/bitFlyer/板情報の取得(PowerShel...
-[[マーケットの一覧(PowerShell)>API/bitFlyer/マーケットの...
-[[Ticker(PowerShell)>API/bitFlyer/Tickerの取得(PowerShel...
* TickerAPIの仕様など [#ie9464f3]
HTTP Public APIなのでbitFlyerに取引口座を開設していなくて...
TickerAPI仕様(bitFlyer APIページから抜粋) ~
リクエスト
GET /v1/getticker
GET /v1/ticker
クエリパラメータ
product_code: マーケットの一覧で取得できる product_cod...
省略した場合の値は BTC_JPY です。
レスポンス
{
"product_code": "BTC_JPY",
"timestamp": "2015-07-08T02:50:59.97",
"tick_id": 3579,
"best_bid": 30000,
"best_ask": 36640,
"best_bid_size": 0.1,
"best_ask_size": 5,
"total_bid_depth": 15.13,
"total_ask_depth": 20,
"ltp": 31690,
"volume": 16819.26,
"volume_by_product": 6819.26
}
timestamp: 時刻は UTC(協定世界時)で表されます。
ltp: 最終取引価格
volume: 24 時間の取引量
* ブラウザでTicker(getmarkets)を取得する [#af13928a]
GETなのでブラウザでTickerを取得することができます。~
以下のようなURLになります。~
product_codeを指定しています。
- BTC_JPY~
https://api.bitflyer.jp/v1/getticker?product_code=BTC_JPY
-FX_BTC_JPY~
https://api.bitflyer.jp/v1/getticker?product_code=FX_BTC_...
-ETH_BTC~
https://api.bitflyer.jp/v1/getticker?product_code=ETH_BTC
-BCH_BTC~
https://api.bitflyer.jp/v1/getticker?product_code=BCH_BTC
product_codeに関しては以下の記事を参照してください。~
-[[マーケットの一覧(PowerShell)>API/bitFlyer/マーケットの...
* ブラウザでTicker APIにアクセスした結果 [#ef984bc9]
上記のURLをブラウザでクリックした結果は以下の通りです。~
FirefoxではJSONが整形され表示されています。~
見やすいですね。~
(生データをクリックすると上記同様にJSON形式の返却された文...
- BTC_JPY~
https://api.bitflyer.jp/v1/getticker?product_code=BTC_JPY
#ref(01.png)
#br
-FX_BTC_JPY~
https://api.bitflyer.jp/v1/getticker?product_code=FX_BTC_...
#ref(02.png)
#br
-ETH_BTC~
https://api.bitflyer.jp/v1/getticker?product_code=ETH_BTC
#ref(03.png)
#br
-BCH_BTC~
https://api.bitflyer.jp/v1/getticker?product_code=BCH_BTC
#ref(04.png)
#br
* Invoke-RestMethodコマンドレットでbitFlyerのTickerを取得...
+Tickerを取得するURL(API)を設定します。
PS C:\> $ticker_api = "https://api.bitflyer.jp/v1/gettic...
+product_codeにBTC_JPYを指定します。
PS C:\> $product_code = "BTC_JPY"
+Invoke-RestMethodコマンドレットを使用し、返却されたTicke...
PS C:\> $ticker = Invoke-RestMethod -UseBasicParsing -Ur...
+取得したTicker情報を表示しています。
PS C:\> $ticker
product_code : BTC_JPY
timestamp : 2018-05-17T11:05:12.143
tick_id : 1387764
best_bid : 921501.0
best_ask : 921586.0
best_bid_size : 0.02804128
best_ask_size : 0.02
total_bid_depth : 2051.2378956
total_ask_depth : 3858.77283227
ltp : 921501.0
volume : 211785.4498822
volume_by_product : 15084.44930353
*HTTPステータスなどを一緒に取得したい場合 [#i880c368]
上記では、Invoke-RestMethodにてJSONをPowerShellで扱いやす...
しかし、Webサーバから返却された値を変換せず、取得後JSONを...
+Tickerを取得するURL(API)を設定します。
PS C:\> $ticker_api = "https://api.bitflyer.jp/v1/gettic...
+product_codeにBTC_JPYを指定します。
PS C:\> $product_code = "BTC_JPY"
+ Invoke-WebRequestコマンドレットでサーバからのレスポンス...
PS C:\> $res = Invoke-WebRequest -UseBasicParsing -Uri (...
+ 取得したレスポンスは以下の通りです。
PS C:\> $res
StatusCode : 200
StatusDescription : OK
Content : {"product_code":"BTC_JPY","timestamp...
.0,"best_ask":921515.0,"best_bid_siz...
ot...
RawContent : HTTP/1.1 200 OK
Connection: keep-alive
Pragma: no-cache
Request-Context: appId=cid-v1:e4fbc9...
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
X-Frame...
Forms :
Headers : {[Connection, keep-alive], [Pragma, ...
ac-f2180e904002], [X-Content-Type-Op...
Images : {}
InputFields : {}
Links : {}
ParsedHtml :
RawContentLength : 303
+HTTPステイタスを取得しています。
PS C:\> $res.StatusCode
200
+Contentに取得した情報が格納されています。
PS C:\> $json = ($res.Content | ConvertFrom-Json)
PS C:\> $json
product_code : BTC_JPY
timestamp : 2018-05-17T11:11:12.047
tick_id : 1395884
best_bid : 920920.0
best_ask : 921515.0
best_bid_size : 0.01
best_ask_size : 0.04
total_bid_depth : 2109.47686593
total_ask_depth : 3852.16647046
ltp : 920915.0
volume : 211442.00348458
volume_by_product : 15059.23366309
以上、PowerShellを使って、bitFlyerのTickerを取得・gettick...
#htmlinsert(bitflyer_full.html)
ページ名: