Skip to main content

Unofficial Python API for Clipper Card (transportation pass used in the SF Bay Area)

Project description

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, send me the page source from your account home page: https://www.clippercard.com/ClipperWeb/account.html

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
session = clippercard.Session('username', 'password')
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 | Golden Gate Rider                  |
|           email | goldengate-rider@example.com       |
| mailing_address | 1 Main St, San Francisco, CA 94105 |
|           phone | 415-555-5555                       |
|       alt_phone | 650-555-5555                       |
| primary_payment | Mastercard ending in 1234          |
|  backup_payment | Amex ending in 9876                |
+------------------------------------------------------+
+---------------------------------------------------------------------------------------+
| # | Name                      | Serial     | Type  | Status | Products                |
|---+---------------------------+------------+-------+--------+-------------------------|
| 1 | Primary, card #2021234134 | 2021234134 | ADULT | Active | Cash Value: $195.00     |
|   |                           |            |       |        | Current Passes: None    |
|   |                           |            |       |        | Pending Passes: None    |
|   |                           |            |       |        | Reload: $255 - Autoload |
| 2 | Backup, card #2021234156  | 2021234156 | ADULT | Active | Cash Value: $200.00     |
|   |                           |            |       |        | Current Passes: None    |
|   |                           |            |       |        | Pending Passes: None    |
|   |                           |            |       |        | Reload: $200 - Autoload |
+---------------------------------------------------------------------------------------+

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.

More examples

If you have a transit pass that isn't recognized by this tool, you can privately share a copy of your account page view-source: with the maintainer.

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

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

clippercard-202606.1.2.tar.gz (14.6 kB view details)

Uploaded Source

Built Distribution

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

clippercard-202606.1.2-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file clippercard-202606.1.2.tar.gz.

File metadata

  • Download URL: clippercard-202606.1.2.tar.gz
  • Upload date:
  • Size: 14.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.9 {"installer":{"name":"uv","version":"0.11.9","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}

File hashes

Hashes for clippercard-202606.1.2.tar.gz
Algorithm Hash digest
SHA256 24a31ff81c9b8387c3ee590641ca6f0e0e18d8c293d751efa0dd99b7e33d4a82
MD5 897eeae136b3ac0eb6bb12baac5e10d2
BLAKE2b-256 8e221015a55ea431f68ebc78cc14645b4ad6466dea089af415828fdac98b4017

See more details on using hashes here.

File details

Details for the file clippercard-202606.1.2-py3-none-any.whl.

File metadata

  • Download URL: clippercard-202606.1.2-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.9 {"installer":{"name":"uv","version":"0.11.9","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}

File hashes

Hashes for clippercard-202606.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 20b0c7381c752f0642bb0f1f57e4f02e9f1777f0eae5ba00ee0b7de40b022a95
MD5 c5ebc6c2aa0f02771ac2a665b02a9b8c
BLAKE2b-256 dff3acab3208e1b8a72c80b0b2e23a9c6e1590381d0ae433476d02dde3e2f257

See more details on using hashes here.

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