从plaid下载金融交易作为qif文件。

plaid2qif的Python项目详细描述


CircleCI

说明

提供从各种金融机构下载交易的机制(由Plaid支持),并转换为金融软件(特别是gnucash)可用的格式(特别是qif&csv,但可扩展)。

小结

  # Save a long-lived access token (one-time only)
  plaid2qif save-access-token --institution=<name> --public-token=<token> --credentials=<file> [--verbose]

  # List out accunts that have been linked to Plaid
  plaid2qif list-accounts --institution=<name> --credentials=<file> [--verbose]

  # Download transactions in various formats (default QIF) from Plaid
  plaid2qif download \
    --institution=<name> \
    --account=<account-name> \
    --account-type=<type> \
    --account-id=<acct-id> \
    --from=<from-date> \
    --to=<to-date> \
    --credentials=<file> \
    [--output-format=<format>] \
    [--output-dir=<path>] \
    [--ignore-pending] \
    [--suppress-warnings=<tf>] \
    [--verbose]

使用量

  1. 使用pip
  2. 安装plaid2qif命令
$ pip install plaid2qif
  1. 验证并与您的金融机构链接(仅限第一次)--请参阅下面的“验证先决条件”。

  2. 配置好后,就可以下载事务并将其保存为qif文件:

plaid2qif download \
    --from=<yyyy-mm-dd> \
    --to=<yyyy-mm-dd> \
    --institution=<name> \
    --account-type=<type> \
    --account=<account-name> \
    --account-id=<plaid-account-id> \
    --credentials=<file>
  • account是指向gnucash分类帐中最终要将交易导入的帐户的路径。这将添加到qif文件中的!Account头中。例如:Assets: Checking Accounts:Personal Checking Account。如果名称有空格,请务必引用此参数。
  • account-type是帐户标识符类型,documented here
  • account-id是要下载的帐户的plaid帐户id,通过上面的list-accounts获得。
  • 默认情况下,输出将转到要重定向的stdout。如果要将其写入某个位置,请使用output-dir参数。

认证先决条件

  • 获取您自己的格子花纹个人凭证并将其保存到本地文件中,例如./plaid-credentials.json。此json文件应包含以下键的值:
    {
      "client_id" : "<censored>",
      "public_key" : "<censored>",
      "secret" : "<censored>"
    }
  • 为要存储的机构配置数据创建一个./cfg目录。
  • 向您的金融机构认证。

向您的金融机构进行身份验证的步骤

  1. 本地保存此HTML,例如auth.html
<html>
<body>
<button id='linkButton'>Open Link - Institution Select</button>
<script src="https://cdn.plaid.com/link/v2/stable/link-initialize.js"></script>
<script>
  var linkHandler = Plaid.create({
    env: 'development',
    clientName: 'Plaid2QIF',
    key: '[PUBLIC_KEY]', // Replace with your public_key from plaid-credentials.json
    product: 'auth',
    apiVersion: 'v2',
    onLoad: function() {
      // The Link module finished loading.
    },
    onSuccess: function(public_token, metadata) {
      // Send the public_token to your app server here.
      // The metadata object contains info about the institution the
      // user selected and the account ID, if selectAccount is enabled.
      console.log('public_token: '+public_token+', metadata: '+JSON.stringify(metadata));
    },
    onExit: function(err, metadata) {
      // The user exited the Link flow.
      if (err != null) {
        // The user encountered a Plaid API error prior to exiting.
      }
      // metadata contains information about the institution
      // that the user selected and the most recent API request IDs.
      // Storing this information can be helpful for support.
    }
  });

  // Trigger the standard institution select view
  document.getElementById('linkButton').onclick = function() {
    linkHandler.open();
  };
</script>
</body>
</html>
  1. 打开根目录上的Web服务器并打开auth.html
$ python3 -m http.server
$ open auth.html # edit first to add the public token from plaid-credentials.json
  1. 跟随instructions here使用ui将您的金融机构链接到plaid。

  2. 成功链接后,请查看浏览器控制台(例如在chrome上使用⌘-⌥-i),然后复制public_tokenpublic_token是一个短期凭证。

  3. 使用public_token,生成并保存长寿命access_token凭据:

$ plaid2qif save-access-token --institution=<name> --public-token=<token> --credentials=<plaid-credentials-file>
  • institution应该是可以用作有效(即:[a-zA-Z0-9_])文件名的字符串,用于存储access_token
  1. 列出与该机构相关的账户,以便获得格纹account_id
$ plaid2qif list-accounts --institution=<name> --credentials=<plaid-credentials-file>

分布

# increment version in `plaid2qif/__init__.py`
# commit everything & push
$ git tag -s vX.Y.Z
$ git push --tags
$ python3 setup.py sdist bdist_wheel
$ twine upload dist/*

GitHub watchersCrates.ioPyPi

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java IntelliJ找不到依赖项选项卡   java向字符串数组string[]添加元素并在Junit中测试结果   如何在eclipse中获取活动java项目的名称   如何使用java在mysql中插入时间   java ArrayList更新了插入一行,但Jtable仍然没有刷新   如何在JavaSwing中命名坐标(点)   java Matcher/模式不打印   java错误地设置了arraylist   使用UsernamePasswordCredential提供程序的java列表Azure AD   java在HTTP请求中设置UTC时间   未加载事件:jquery完整日历Java集成   java Maven插件依赖项无法从内部repo解析依赖项   Maven更新重置Java版本   java如何向中添加图片。带有Apache POI XWPF的docx,但不指定其大小   Java最大函数递归