Unofficial Python API for Clipper Card (transportation pass used in the SF Bay Area)
Project description
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
To install clippercard, simply:
$ pip install clippercard
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 Hacker |
| email | goldengate88@systemfu.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 #1212038022 | 1212000130 | ADULT | Active | Cash Value: $195.00 |
| | | | | | Current Passes: None |
| | | | | | Pending Passes: None |
| | | | | | Reload: $255 - Autoload |
| 2 | Backup, card #1212046165 | 1212000120 | 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 ~/.clippercardrc
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
Contribute
- fork the repo to your personal GitHub account
- make your changes in your repo
- for Python source, follow local style consistency and PEP8
- run
pyflakes
/frosted
on your diffs - add unit tests, make sure they pass (just run
pytest
😎) - remember to bump the version number wherever applies
- add a new line for your revision to
CHANGES.txt
describing your change - send a pull request to https://github.com/clippercard/clippercard-python w/ explanation of problem statement and design decisions
- respond to all pull request code review requests in your branch and submit the requested changes in new commits
- communicate with the maintainers to merge the finalized pull request and publish your changes h
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
File details
Details for the file clippercard-202104.25.1.tar.gz
.
File metadata
- Download URL: clippercard-202104.25.1.tar.gz
- Upload date:
- Size: 23.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/4.0.1 pkginfo/1.7.0 requests/2.24.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 062a96f640927050f36b683e0866bde551a23eb218b328e4176e875776d5c61e |
|
MD5 | 1740a0dccd4e6cd1cd9ce3aeddda277e |
|
BLAKE2b-256 | 3cfd1d22a0f8ca8f7fec608ec16d615b414a99924055005ace4fbb9e1764062c |