Skip to main content

A Pythonic interface for TfL's Photocard service

Project description

photocard

A Pythonic interface for TfL's Photocard service.

TfL couldn't be bothered to add photocard support to their app, so I made an API for their photocard service in half a day. Not too difficult after all, huh?

Benefits

  • Full read access to TfL's Photocard service
  • 11-15 Photocard support

Limitations:

  • All API endpoints, require logging on.
  • All API endpoints are read only
  • Limited support for 5-10, 16+, 18+, and 60+ photocards. If you need support for these please provide screenshots of the network inspector calling the card endpoint for these, please open an issue in the issues tab.

CLI

A CLI tool is available.

python -m photocard

Usage

Logon

Logon requires email and password.

Try not to get the password wrong - TfL has been known to lock you out of your account for 30 minutes if you get your password wrong just once.

Example: Getting People & Cards

from photocard import PhotocardService

photocard = PhotocardService()
photocard.logon(input("Enter email: "), input("Enter password: "))

# Gets all people associated with the web account
people = photocard.get_people()
for person in people:
    # Get cards for person
    cards = photocard.cards_for_person(person)  # More than one card can be associated with a person
    for card in cards:
        print(f"Balance for card {card.oyster_card_number}: £{card.prepaid_balance:.2f}")
        # Example output (censored PII): Balance for card 0*********5: £3.50

Disclaimer

This doesn't appear to break any T&C, but I'm not a lawyer, so get one to read TfL's: https://tfl.gov.uk/corporate/terms-and-conditions/

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

photocard-0.1.0.tar.gz (6.0 kB view hashes)

Uploaded Source

Built Distribution

photocard-0.1.0-py3-none-any.whl (6.4 kB view hashes)

Uploaded Python 3

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