Skip to main content

Python client library for AXIS real-time information delivery service by Prioris

Project description

axis.py

AXIS リアルタイム情報配信サービス用のPythonクライアントライブラリです。

特徴

  • シンプルなデコレータAPI@client.on("channel") でメッセージハンドラを登録
  • 自動再接続 — Exponential Backoff アルゴリズムによる再接続
  • 型付きメッセージモデル — 各チャンネルのメッセージを dataclass で型定義
  • トークン管理 — トークンリフレッシュAPIに対応

対応チャンネル

チャンネル 説明 モデル
eew 緊急地震速報 (beta) EEWMessage
quake-one 地震概要・震度情報 QuakeOneMessage
breaking-news ニュース速報 (beta) BreakingNewsMessage
jmx-seismology 気象庁電文(地震) JMXSeismologyMessage
jmx-meteorology 気象庁電文(気象) JMXMeteorologyMessage
jmx-volcanology 気象庁電文(火山) JMXVolcanologyMessage

インストール

pip install axis-prioris

使い方

基本

from axis import AxisClient

client = AxisClient(token="YOUR_TOKEN")

@client.on("eew")
def on_eew(message):
    print(f"緊急地震速報: M{message.Magnitude} {message.Hypocenter.Name}")

@client.on("quake-one")
def on_quake(message):
    print(f"地震情報: {message.headline}")

@client.on("breaking-news")
def on_news(message):
    print(f"速報: {message.Title}")
    for line in message.Text:
        print(f"  {line}")

client.start()  # ブロッキング接続

全チャンネルの受信

@client.on_all
def on_any(channel, message):
    print(f"[{channel}] {message}")

非ブロッキング接続

thread = client.start_async()

# ... 他の処理 ...

client.stop()
thread.join()

接続イベント

@client.on_connect
def connected():
    print("AXIS に接続しました")

@client.on_error
def error(err):
    print(f"エラー: {err}")

@client.on_close
def closed(code, msg):
    print(f"切断 (code={code})")

トークンリフレッシュ

try:
    new_token = client.refresh_token()
    print(f"トークンを更新しました")
except AxisTokenExpiredError:
    print("契約が期限切れです。Webサイトで再発行してください。")

設定オプション

client = AxisClient(
    token="YOUR_TOKEN",
    auto_reconnect=True,   # 自動再接続 (デフォルト: True)
    max_retries=10,        # 最大再接続回数 (デフォルト: 10)
    ping_interval=60,      # Heartbeat間隔 秒 (デフォルト: 60)
)

ログ

標準の logging モジュールを使用しています:

import logging
logging.basicConfig(level=logging.INFO)

ライセンス

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

axis_prioris-0.2.1.tar.gz (11.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

axis_prioris-0.2.1-py3-none-any.whl (11.5 kB view details)

Uploaded Python 3

File details

Details for the file axis_prioris-0.2.1.tar.gz.

File metadata

  • Download URL: axis_prioris-0.2.1.tar.gz
  • Upload date:
  • Size: 11.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for axis_prioris-0.2.1.tar.gz
Algorithm Hash digest
SHA256 46fab9bfd7886309e347471eb6284e5c83a0618e5eb11aa94c5ad65ac6be1125
MD5 051277a6460c1e365be13552d9cad2c7
BLAKE2b-256 3629efd1d85e7cd8978526b430394280599b3c33785f632b3db24732ea7b6471

See more details on using hashes here.

Provenance

The following attestation bundles were made for axis_prioris-0.2.1.tar.gz:

Publisher: publish.yml on mugicomugi/axis.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file axis_prioris-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: axis_prioris-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 11.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for axis_prioris-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7c946db97205b7ae7b8659471ec25f83da1f92dc36834ad23a962c1d915a204c
MD5 08fa24871bfa33d2636eaad8f015b46d
BLAKE2b-256 9a89f9e8deb9e90df1e804f143e9825da2de58babd71a63a1dff7024afbbb927

See more details on using hashes here.

Provenance

The following attestation bundles were made for axis_prioris-0.2.1-py3-none-any.whl:

Publisher: publish.yml on mugicomugi/axis.py

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page