Skip to main content

Unofficial Python API for Clipper Card (transportation pass used in the San Francisco 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 total UX/UI disaster, its behind-the-scene's HTML structure and HTTP protocol is a complete exercise in palmface. 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/ClipperCard/dashboard.jsf

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.user_profile)
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 | JOHN SMITH                                |
|   email | jsmith@example.com                        |
| address | 1 Main St, San Francisco, CA 94103        |
|   phone | 415-555-5555                              |
+---------+-------------------------------------------+
+---------------+------------+-------+--------+----------------+--------+
| Card          | Serial     | Type  | Status | Product        | Value  |
+---------------+------------+-------+--------+----------------+--------+
| GGB75         | 1234567890 | ADULT | Active | BART HVD 60/64 | $16.20 |
| GGB75         | 1234567890 | ADULT | Active | Cash value     | $32.40 |
| Standard Card | 1234567891 | ADULT | Active | Cash value     | $64.80 |
+---------------+------------+-------+--------+----------------+--------+

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

[default]
username = jsmith@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

  1. fork the repo to your personal GitHub account
  2. make your changes in your repo
  3. for Python source, follow local style consistency and PEP8
  4. run pyflakes/frosted on your diffs
  5. add unit tests, make sure they pass (just run pytest 😎)
  6. remember to bump the version number wherever applies
  7. add a new line for your revision to CHANGES.txt describing your change
  8. send a pull request to https://github.com/clippercard/clippercard-python w/ explanation of problem statement and design decisions
  9. respond to all pull request code review requests in your branch and submit the requested changes in new commits
  10. 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-0.5.0.tar.gz (9.7 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: clippercard-0.5.0.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.4.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.8

File hashes

Hashes for clippercard-0.5.0.tar.gz
Algorithm Hash digest
SHA256 26f84a376a373aaada4dbb2d8976735edd8e2276c86c62efbc6f4dc856e7ad5f
MD5 c9d1d2674e0d51e8e91a1be49e525464
BLAKE2b-256 e4b647ac5d51a65d70486ddbbe79a8554a31bef5dd870624effaabe09a57d46e

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page