Skip to main content

logo

clippercard is an unofficial python client for clippercard.com, written in Python.


Why

Not only is the clippercard web site a inaccessible by API, its behind-the-scene's HTML structure and HTTP protocol is not semantically structured. This library aims to provide an unofficial but sensible interface to the official web service.

Project Goal

I enjoy the actual user experience of ClipperCard on buses and trains. My complaints about the service are purely isolated to its web interface. I saw a problem, and I solved it for myself, that's all.

As an advocate for data accessibility, I believe our dollars, our votes, our voices and our actions can nudge institutions in the direction we'd like them to go. At Bay Area's Metropolitan Transportation Commission, I am sure there are a lot of great people doing good work to the best of their ability, and within the context of prioritization, organizational structure and resources available to them.

I encourage the staff of MTA reading this project to see this effort as a nudge for a public and official API. The moment they put up an API that obsoletes this project, I will happily direct followers to the official solution. If you'd like them to increase attention to data accessibility, you can send them an email at info@mtc.ca.gov and tell them I sent you.

Features

  • Profile Data
  • Multiple cards' data
  • For each card, multiple products and balances

I don't have access to all products loadable on the ClipperCard, so transit product variant support is limited to what I personally use for now. If you'd like me to add support for your product, see the sample-sharing instructions under Future.

Security and Privacy

It's important to point out that:

  • This project does not collect your personal information or clippercard.com login credentials.
  • This project is not a hosted service, your data is not stored or sent to any 3rd party service.

For now, this project is targeted at other software developers, who are capable of assessing my source code for security implications.

Installation

Install as a user-wide CLI tool via uv:

$ uv tool install clippercard

clippercard requires Python 3.11 or newer.

This makes the clippercard command available globally without activating a virtual environment.

Usage

import clippercard

with clippercard.Session("username", "password") as session:
    print(session.profile_info)
    for c in session.cards:
        print(c)

You also get a super convenient command line binary clippercard::

$ clippercard -h # see usage information
$ clippercard summary
+---------------------------------------------+
|            name | Go*** Ga*** Ri***         |
|           email | g***@example.com          |
| mailing_address | ***                       |
|           phone | 415-***-***-5555          |
|       alt_phone | 650-***-***-5555          |
| primary_payment | Mastercard ending in 1234 |
|  backup_payment | Amex ending in 9876       |
+---------------------------------------------+
+----------------------------------------------------------------+
| # | Name    | Serial     | Type  | Status | Cash Value | BART  |
|---+---------+------------+-------+--------+------------+-------|
| 1 | Phone   | ******4156 | Adult | Active |    $244.55 | $1.10 |
| 2 | Watch   | ******4178 | Adult | Active |    $165.40 | $1.40 |
| 3 | Primary | ******4134 | Adult | Active |     $40.00 |       |
+----------------------------------------------------------------+

Name, email, address, phone, and card serials are redacted by default. Each stored-value purse (Cash Value, BART, or another agency) gets its own column. Cards are listed highest Cash Value first. On a terminal the table is colorized (bold column headers, bold #/Name row headers, blue header bar, zebra rows, green balances); piped output and NO_COLOR stay plain ASCII as above. Pass --show-private to print unredacted details.

If you wish to use clippercard without specifying username/password on the CLI, create a file ~/.config/clippercard/credentials.ini with this format::

[default]
username = goldengate88@example.com
password = superseekrit

You may toggle accounts via the --account flag on the command line to access one of several configs in the file::

[default]
username = <replace_with_your_email>
password = <replace_with_your_password>

[other]
username = <replace_with_login_email>
password = <replace_with_login_password>

The other credentials can then be accessed via::

$ clippercard summary --account=other

Non-default accounts keep separate saved login cookies in account-specific files such as ~/.config/clippercard/auth.other.cookies.

On macOS, you can store login credentials and saved cookies in Keychain instead of local files.

First-time Keychain setup

Pass the Clipper username once on the command line. Omit --password and paste it when prompted (hidden on a TTY, or one line on stdin). After a successful password login, the CLI writes those credentials into Keychain and prints a confirmation:

$ clippercard summary --credential-store keychain --cookie-store keychain \
    --username goldengate88@example.com
Paste Clipper password for goldengate88@example.com:
Saved login credentials to macOS Keychain. You can delete the plaintext username/password from the config file if you no longer need them.

You can still pass --password if you want, but that leaves the secret in your shell history.

macOS may prompt to allow the security tool to use Keychain. Choose Allow or Always Allow.

Do not skip --username on this first run. If Keychain is empty, the CLI otherwise looks for credentials.ini or offers to create it.

If you already have a credentials.ini, you can seed Keychain from that file instead:

$ clippercard summary --credential-store keychain --cookie-store keychain

Credentials are written only after a real password login succeeds. Cookie reuse does not count, because that path never checks the username/password. If you already have a saved cookie file and this first run says it is reusing cookies, delete that file and run the command again:

$ rm ~/.config/clippercard/auth.cookies
$ clippercard summary --credential-store keychain --cookie-store keychain \
    --username goldengate88@example.com

Later runs

If there is no credentials.ini, later runs pick Keychain up automatically:

$ clippercard summary

If you keep a config file, set the stores there so you do not need the flags every time. After Keychain has the password, you can omit username / password:

[default]
credential_store = keychain
cookie_store = keychain

CLI flags still override the config file. If you omit both the flags and the config keys, the CLI keeps using credentials.ini and the cookie file when those exist, and only falls back to Keychain when the matching file is missing.

Keychain item names and cleanup

Keychain items are named clippercard.credentials and clippercard.cookies, with the account section as the Keychain account (default, other, and so on).

Cookie migration copies an existing file jar into Keychain the first time that Keychain item is missing. It does not delete credentials.ini or auth.cookies. Leave those files in place until you have confirmed Keychain login works, then delete the plaintext password if you want.

To remove saved Keychain items later:

$ security delete-generic-password -s clippercard.credentials -a default
$ security delete-generic-password -s clippercard.cookies -a default

Use -a other for a non-default --account.

For scripts and agents, request structured JSON instead of the default table output:

$ clippercard summary --output json
{
  "profile": {
    "name": "Go*** Ga*** Ri***",
    "email": "g***@example.com",
    "mailing_address": "***",
    "phone": "415-***-***-5555",
    "alt_phone": "650-***-***-5555",
    "primary_payment": "Mastercard ending in 1234",
    "backup_payment": "Amex ending in 9876"
  },
  "cards": [
    {
      "serial_number": "******4156",
      "nickname": "Phone",
      "type": "Adult",
      "status": "Active",
      "products": [
        {
          "name": "Cash Value",
          "value": "$244.55"
        },
        {
          "name": "BART",
          "value": "$1.10"
        }
      ],
      "features": []
    }
  ]
}

When stdout is piped, summary defaults to JSON for Unix tooling:

$ clippercard summary | jq .

Use --show-private with either output format to include unredacted profile and card details.

Future

Planned improvements, roughly in priority order:

  • Account health alerts — surface problems the dashboard already reports but the CLI currently drops: suspended or failed autoloads, low cash/BART balances, and passes expiring soon, in both table and JSON output.
  • Balance deltas — remember the previous balances per account and show what changed since the last check.
  • Trip and transaction history — recent trips and loads per card. This needs real page samples (see below) before it can be built reliably.

Help wanted: dashboard page samples

ClipperCard's web UI varies by account — card types, transit products, autoload setups — and the maintainer only has access to their own account. Real samples make the parser better for everyone.

If you'd like to contribute one:

  1. Log in at https://www.clippercard.com and open the dashboard.
  2. View the page source (paste view-source:https://www.clippercard.com/dashboard into your browser's address bar) and save the full page.
  3. Redact personal details: name, email, mailing address, phone numbers, and all but the last 4 digits of card serial numbers.
  4. Open a GitHub issue describing what your account has (passes, autoload, BART or other agency purses, virtual/phone cards, etc.) — without attaching the file — and the maintainer will arrange a private handoff.

Please don't paste page source into a public issue or pull request. Even redacted, treat it like a bank statement.

Contribute

  1. fork the repo to your personal GitHub account
  2. install dev dependencies: just sync
  3. make your changes in your repo
  4. for Python source, follow local style consistency and PEP8
  5. format and lint your code: just format and just lint
  6. run tests on the current Python version: just test
  7. run tests across all supported Python versions: just test-all
  8. add unit tests, make sure they pass
  9. remember to bump the version number wherever applies
  10. add a new line for your revision to CHANGES.txt describing your change
  11. send a pull request to https://github.com/clippercard/clippercard-python w/problem or goal statement and implementation details
  12. respond to all pull request code review requests in your branch and submit the requested changes in new commits
  13. communicate with the maintainers to merge the finalized pull request and publish your changes

Metadata

Release files for clippercard 202610.25.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 clippercard 202610.25.1
File Size Uploaded Provenance Actions
clippercard-202610.25.1.tar.gz 20.2 kB Without provenance Details for clippercard-202610.25.1.tar.gz

Built distribution (wheel)

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

Total release size: 42.1 kB

Release files / clippercard-202610.25.1.tar.gz

Download URL clippercard-202610.25.1.tar.gz
Size 20.2 kB
Tags Source
SHA-256 checksum
How to use checksums
025d0c81e66d2f66e947ef295bf32915f6519f6c4e6ca66bb26607858fadf38f
BLAKE2b-256 checksum
How to use checksums
46f47e1696e25d96d48ce2b8dee1b2c371a2de0d9eb9030b786981a650dd97a6
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / clippercard-202610.25.1-py3-none-any.whl

Download URL clippercard-202610.25.1-py3-none-any.whl
Size 22.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0b68832cd064ea7bf65c21d1ba2105cf173019ac198e534cf6f94e215f8de5fe
BLAKE2b-256 checksum
How to use checksums
1d309e3e96243c5495542a8338f027041e6885b89a1c3342ca2642dc2dfa3309
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.13.5 {"installer":{"name":"uv","version":"0.13.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for clippercard 202610.25.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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