Skip to content

Commit

Permalink
Update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
MtkN1 committed May 14, 2024
1 parent 585f865 commit 72f572f
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
8 changes: 4 additions & 4 deletions docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@ GMO Coin

:class:`.helpers.GMOCoinHelper` を利用したサンプルコードです。

:meth:`.helpers.GMOCoinHelper.manage_ws_token` を利用することで、`Private WebSocket のアクセストークン <https://api.coin.z.com/docs/#ws-auth-post>`_ を管理します。
デフォルトでは 5 分ごとにアクセストークンを延長します。 延長が失敗した場合は、アクセストークンを作成します
このメソッドは無限ループとなっているので、 :meth:`asyncio.create_task` でタスクスケジュールしてください
:meth:`~.helpers.GMOCoinHelper.manage_ws_token` を利用することで、`Private WebSocket のアクセストークン <https://api.coin.z.com/docs/#ws-auth-post>`_ を管理します。
デフォルトでは 5 分ごとにアクセストークンを延長します。 延長が失敗した場合は、アクセストークンを新しく作成します
このメソッドは無限ループとなっているので、 :meth:`asyncio.create_task` でタスクとしてスケジュールしてください

以下は適当なチャンネルを購読して、アクセストークンの管理タスクスケジュールするサンプルコードです
以下は適当なチャンネルを購読して、アクセストークン管理ヘルパーのタスクをスケジュールするサンプルコードです

.. literalinclude:: ../example/helpers/gmocoin.py
10 changes: 7 additions & 3 deletions docs/exchanges.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ Authentication

https://api.coin.z.com/docs/#authentication-private
* WebSocket 認証
GMO Coin はトークン認証方式の為、ユーザーコードで URL に「アクセストークン」含める必要があります
GMO Coin はトークン認証方式の為、ユーザーコードで「アクセストークン」を取得して、それを含めた Private WebSocket URL を構築する必要があります

https://api.coin.z.com/docs/#authentication-private-ws

Expand All @@ -66,8 +66,12 @@ Authentication

また DataStore 側で「アクセストークンを延長」の定期リクエストが有効になる為、ユーザーコードでの延長処理は不要です。

:class:`.helpers.GMOCoinHelper` は「アクセストークンを延長」と「アクセストークンを取得」を自動で実行して、さらに Private WebSocket の URL を自動で更新する機能があります。
`GMO コインの定期メンテナンス <https://support.coin.z.com/hc/ja/articles/115007815487-%E3%82%B7%E3%82%B9%E3%83%86%E3%83%A0%E3%83%A1%E3%83%B3%E3%83%86%E3%83%8A%E3%83%B3%E3%82%B9%E6%99%82%E9%96%93%E3%81%AB%E3%81%A4%E3%81%84%E3%81%A6%E6%95%99%E3%81%88%E3%81%A6%E3%81%8F%E3%81%A0%E3%81%95%E3%81%84>`_ 後は通常、アクセストークンは失効しています。 このヘルパーを使ってアクセストークンを管理することによって、メンテナンス後の接続を確率するのに役に立ちます。
:class:`.helpers.GMOCoinHelper` を利用すると「アクセストークンを延長」と「アクセストークンを取得」を自動で実行します。
さらに取得したアクセストークンから Private WebSocket URL を構築して :attr:`.WebSocketApp.url` を自動で更新します。
通常、 `GMO コインの定期メンテナンス <https://support.coin.z.com/hc/ja/articles/115007815487-%E3%82%B7%E3%82%B9%E3%83%86%E3%83%A0%E3%83%A1%E3%83%B3%E3%83%86%E3%83%8A%E3%83%B3%E3%82%B9%E6%99%82%E9%96%93%E3%81%AB%E3%81%A4%E3%81%84%E3%81%A6%E6%95%99%E3%81%88%E3%81%A6%E3%81%8F%E3%81%A0%E3%81%95%E3%81%84>`_
後はアクセストークンは失効して Private WebSocket の再接続は失敗してしまいます。
このヘルパーを使うと、失効したアクセストークンを自動で再取得するので、メンテナンス後の再接続を確立するのに便利です。

利用可能なコードは :ref:`Examples GMOCoinHelper <GMOCoinHelper>` をご覧ください。

WebSocket
Expand Down
4 changes: 4 additions & 0 deletions example/helpers/gmocoin.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ async def main():

async with pybotters.Client(apis=apis) as client:
store = pybotters.GMOCoinDataStore()

# Create a helper instance for GMOCoin.
gmohelper = GMOCoinHelper(client)

# Alias for POST /private/v1/ws-auth .
token = await gmohelper.create_access_token()

ws = client.ws_connect(
# Build the Private WebSocket URL.
f"wss://api.coin.z.com/ws/private/v1/{token}",
send_json={
"command": "subscribe",
Expand Down

0 comments on commit 72f572f

Please sign in to comment.