Skip to main content

pyzaim

PyPI version All Contributors

logo

Zaimのデータを取得・操作するPythonパッケージ

概要

大きくわけて2つの処理を行うパッケージです。

  • Zaim APIのラッパークラス
    • Zaim APIのアクセストークンの発行
    • Rest APIとして提供されている処理の実行
  • Seleniumを用いたデータ取得
    • Zaimにはクレジットカードや銀行口座から自動でデータ取得する機能があるが、APIではそれらのデータにはアクセスできない
    • これらの情報を取得するため、Seleniumのwebdriver(Chrome)を用いてデータを取得

インストール

pip install pyzaim

準備

  • Zaimアカウントの作成
  • Zaim Developersでのアプリケーションの登録 (コンシューマID、コンシューマシークレットの発行)
  • Google Chromeおよびseleniumの導入

使い方

Zaim APIのラッパークラスの使い方

  • アクセストークンの発行
from pyzaim import get_access_token

get_access_token()

# コンシューマIDとコンシューマシークレットを聞かれるので入力
# 認証ページのURLが表示されるので、アクセスして許可
# 遷移先ページのソースコードから「oauth_verifier」と書いてあるコードをコピーして入力
# 問題なければアクセストークンとアクセスシークレットが表示される
  • APIを利用してデータを取得・操作
from pyzaim import ZaimAPI

api = ZaimAPI('コンシューマID', 'コンシューマシークレット',
              'アクセストークン', 'アクセスシークレット', 'verifier')

# 動作確認 (ユーザーID等のデータが取得されて、表示されればOK)
print(api.verify())

# データの取得
data = api.get_data()

# 支払いデータの登録
api.insert_payment_simple('日付(datetime.date型)', '金額(int)', 'ジャンル名',
                          '口座名', 'コメント', '品名', '店舗名') # 後半4つは任意入力

# 使用できるジャンル名は以下で確認できる
print(api.genre_itos)

# 使用できる口座名は以下で確認できる
print(api.account_itos)

# 支払いデータの更新 (更新対象データのIDはapi.get_data()で確認)
api.update_payment_simple('更新対象データのID', '日付(datetime.date型)', '金額(int)',
                          'ジャンル名', '口座名', 'コメント', '品名', '店舗名') # 後半4つは任意入力

# 支払いデータの削除
api.delete_payment('削除対象のデータのID')

seleniumを用いたデータ取得

from pyzaim import ZaimCrawler

# Chrome Driverの起動とZaimへのログイン、ログインには少し時間がかかります
crawler = ZaimCrawler('ログインID', 'ログインパスワード',
                    driver_path='Chrome Driverのパス'(PATHが通っていれば省略可),
                    headless=False) # headlessをTrueにするとヘッドレスブラウザで実行できる

# データの取得 (データの取得には少し時間がかかります、時間はデータ件数による)
data = crawler.get_data('取得する年(int)', '取得する月(int)', progress=True) # progressをFalseにするとプログレスバーを非表示にできる

# 終了処理
crawler.close()

ブランチの運用について

本リポジトリのブランチについては以下の運用といたします。

main

  • リリース用ブランチ。
  • このブランチにマージした時点で新たにタグを打ち、PyPIにアップロードします。
  • このブランチには直接PRを出さないでください。

develop

  • 開発用の常駐ブランチ。
  • すべてのコミットはこのブランチに一度マージし、動作を確認した上でmainにマージします。
  • PRはこのブランチに対して行ってください。

feature-*

  • 新規開発用のブランチ。
  • 必ずdevelopから分岐し、developにマージする。
  • *には開発やバグ修正などの対応内容を簡潔に記入。
    • 例: feature-add-headless-mode

Contributors ✨

Thanks goes to these wonderful people (emoji key):

りーべ
りーべ

📆 👀 💻 📖
Ponk02
Ponk02

💻
zenjiro
zenjiro

💻 👀
omatsu555
omatsu555

💻
Y.Tory
Y.Tory

💻
o-matsu
o-matsu

💻
kefi550
kefi550

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

Release files for pyzaim 1.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pyzaim 1.1.0
File Size Uploaded
pyzaim-1.1.0.tar.gz 10.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyzaim 1.1.0
File Interpreter ABI Platform
pyzaim-1.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 19.1 kB

Release files / pyzaim-1.1.0.tar.gz

Download URL pyzaim-1.1.0.tar.gz
Size 10.4 kB
Tags Source
SHA-256 checksum
How to use checksums
fe21581c03af6ac52bb4a57add0a0573f2cc1738b353a72db308d168a8ed09bb
BLAKE2b-256 checksum
How to use checksums
3a9ebb86ed92f157ac8ab7458512769ac368bd0d290a141add70545414ae169a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.10.12 Linux/5.15.146.1-microsoft-standard-WSL2

Release files / pyzaim-1.1.0-py3-none-any.whl

Download URL pyzaim-1.1.0-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
df67e7789f11fc9509956d5842ca4b3d541da95bec77180b1db8e526e6176d42
BLAKE2b-256 checksum
How to use checksums
c97bc0daff080f137036d262577fa789b92b0f1805eeaf2b955bc75057f64479
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.8.2 CPython/3.10.12 Linux/5.15.146.1-microsoft-standard-WSL2

Release history Release notifications | RSS feed

This release

1.1.0 This release

2 release files

1.0.11

2 release files

1.0.10

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page