Skip to main content

pocketsmith-web-client

A web-based client for Pocketsmith, which adds support for a few things missing from the API:

  • Searching transactions
  • Syncing institutions, including those requiring MFA!
  • Real-time events through Pusher (just like the web UI)

Installation

pip install pocketsmith-web-client

Usage

import asyncio
from pocketsmith_web import PocketsmithWebClient

pwc = PocketsmithWebClient(
    username='hambob',
    password='Myspace123',
    # If 2fa is enabled on the account — NOTE: this is the KEY, not a one-time code!
    totp_key='81r0dq0815u88qi2',
)

async def main():
    # Check login — NOTE: API methods requiring auth will automatically call this
    await pwc.login()

    # Search for some transactions and print them out
    async for transaction in pwc.search_transactions('Merchant, inc'):
        print(f'[{transaction["id"]:>8}] {transaction["date"]:%Y-%m-%d} ${transaction["amount"]:.2f}')

    # Sync some institutions
    # NOTE: these parameters can be scraped from the Account Summary page, 
    #       in URLs of the format: "/feeds/user_institutions/<uys_id>/refresh?item_ids%5B%5D=<item_id>
    await pwc.sync_institution(162303, 91821548)

asyncio.run(main())

If you have an institution requiring MFA info, the Pusher client can be used to provide this info when requested. It's up to you to figure out how to acquire the MFA info, though — whether it's from user input, a generated TOTP, a text message, email, etc.

import asyncio
import json
from pocketsmith_web import PocketsmithWebClient, PusherEvent

pwc = PocketsmithWebClient('hambob', 'Myspace123', totp_key='81r0dq0815u88qi2')


async def sync_my_mfa_bank():
    uys_id = 162303
    item_id = 91821548

    await pwc.sync_institution(uys_id, item_id)

    async with pwc.pusher() as pusher:
        # Wait for an MFA event for our bank
        await pusher.events.expect(
            PusherEvent.MfaChanged(pwc.pusher_channel),
            matches_uys_item(uys_id, item_id),
        )

        # Grab the MFA popup form details
        mfa_req = await pwc.get_mfa_form_info()

        # Ask the user for the MFA deets, please
        print(f'MFA deets required: {mfa_req["label"]}')
        token = input('Token: ')

        # Now shoot the token back to Pocketsmith
        await pwc.provide_feed_mfa(uys_id, item_id, token)


def matches_uys_item(uys_id, item_id):
    uys_id = str(uys_id)
    item_id = str(item_id)

    def does_event_match_uys_item(event: PusherEvent):
        if not isinstance(event.data, dict):
            return False

        event_uys_id = event.data.get('user_yodlee_site_id')

        event_items = event.data.get('new_mfa_items', ())
        if isinstance(event_items, str):
            try:
                event_items = json.loads(event_items)
            except (TypeError, ValueError):
                pass

        return uys_id == event_uys_id and item_id in event_items

    return does_event_match_uys_item


asyncio.run(sync_my_mfa_bank())

Metadata

Release files for pocketsmith-web-client 0.1.1

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

Source distribution (sdist)

Source distribution for pocketsmith-web-client 0.1.1
File Size Uploaded
pocketsmith-web-client-0.1.1.tar.gz 13.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pocketsmith-web-client 0.1.1
File Interpreter ABI Platform
pocketsmith_web_client-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 27.0 kB

Release files / pocketsmith-web-client-0.1.1.tar.gz

Download URL pocketsmith-web-client-0.1.1.tar.gz
Size 13.6 kB
Tags Source
SHA-256 checksum
How to use checksums
77e64748fb11cb9b135e3e77cb3e01ba2641f1e55fe5dd908784d79737a12c9e
BLAKE2b-256 checksum
How to use checksums
faf754c6e66df32ad53792be578931c1ab3b16576df202f4264d94d707626c32
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.2 CPython/3.8.5 Linux/5.4.0-52-generic

Release files / pocketsmith_web_client-0.1.1-py3-none-any.whl

Download URL pocketsmith_web_client-0.1.1-py3-none-any.whl
Size 13.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b6dcd37547558b41776e5ae3734500123329d5b225cbddd6da6cd16be22eff41
BLAKE2b-256 checksum
How to use checksums
2412aa5c916a6bbb9773996aba7b4dc0e5b98f25a3676e9c05656994d12fa4cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.2 CPython/3.8.5 Linux/5.4.0-52-generic

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

0.1.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