当サイトに記載されている会社名、製品名などは一般に各社または団体の商標または登録商標です。
当サイトの資料により直接的および間接的障害が生じても一切責任を負いません。
あらかじめご了承ください。
PowerShellを使ってbitFlyerのマーケットの一覧APIの使用例を以下に記します。
HTTP Public APIなのでbitFlyerに取引口座を開設していなくても使用することができます。
マーケットの一覧API仕様(bitFlyer APIページから抜粋)
GET /v1/getmarkets GET /v1/markets
[
{ "product_code": "BTC_JPY" },
{ "product_code": "FX_BTC_JPY" },
{ "product_code": "ETH_BTC" },
{
"product_code": "BTCJPY28APR2017",
"alias": "BTCJPY_MAT1WK"
},
{
"product_code": "BTCJPY05MAY2017",
"alias": "BTCJPY_MAT2WK"
}
]
alias: 以下の呼出で product_code を指定するときに、代わりに使用できます。GETなのでブラウザでマーケットの一覧を取得することができます。
以下のようなURLになります。
https://api.bitflyer.jp/v1/getmarkets
以下ブラウザから上記URLにアクセスしたときの出力です。
FirefoxではJSONが整形され表示されています。
見やすいですね。
(生データをクリックすると上記同様にJSON形式の返却された文字列が表示されます。)

PS C:\> $markets_api = "https://api.bitflyer.jp/v1/getmarkets"
$markets = Invoke-RestMethod -UseBasicParsing -Uri $markets_api
PS C:\> $markets product_code ------------ BTC_JPY FX_BTC_JPY ETH_BTC BCH_BTC BTCJPY29JUN2018 BTCJPY18MAY2018 BTCJPY25MAY2018
PS C:\> $markets[0] product_code ------------ BTC_JPY PS C:\> $markets[1] product_code ------------ FX_BTC_JPY PS C:\> $markets.Count 7
上記では、Invoke-RestMethodにてJSONをPowerShellで扱いやすい状態に変換してくれます。 しかし、Webサーバから返却された値を変換せず、取得後JSONを別のコマンドレットで変換する操作手順を以下に記します。
PS C:\> $markets_api = "https://api.bitflyer.jp/v1/getmarkets"
PS C:\> $res = Invoke-WebRequest -UseBasicParsing -Uri $markets_api
PS C:\> $res
StatusCode : 200
StatusDescription : OK
Content : [{"product_code":"BTC_JPY"},{"product_code":"FX_BTC_JPY"},{"product_code":"ETH_BTC"},{"product_code
":"BCH_BTC"},{"product_code":"BTCJPY29JUN2018","alias":"BTCJPY_MAT3M"},{"product_code":"BTCJPY18MAY
20...
RawContent : HTTP/1.1 200 OK
Connection: keep-alive
Pragma: no-cache
Request-Context: appId=cid-v1:e4fbc941-a2df-48ac-bbac-f2180e904002
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
X-Frame...
Forms :
Headers : {[Connection, keep-alive], [Pragma, no-cache], [Request-Context, appId=cid-v1:e4fbc941-a2df-48ac-bb
ac-f2180e904002], [X-Content-Type-Options, nosniff]...}
Images : {}
InputFields : {}
Links : {}
ParsedHtml :
RawContentLength : 288PS C:\> $res.StatusCode 200
PS C:\> $json = ($res.Content | ConvertFrom-Json) PS C:\> $json product_code ------------ BTC_JPY FX_BTC_JPY ETH_BTC BCH_BTC BTCJPY29JUN2018 BTCJPY18MAY2018 BTCJPY25MAY2018以上、PowerShellを使って、bitFlyerのマーケットの一覧を取得・getmarketsからの返却値を表示する方法でした。