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.2.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

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

photocard-0.1.2-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file photocard-0.1.2.tar.gz.

File metadata

  • Download URL: photocard-0.1.2.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.5 Darwin/24.0.0

File hashes

Hashes for photocard-0.1.2.tar.gz
Algorithm Hash digest
SHA256 c6c4742fee736a19cce4e243a6938e71c6aedc97c3a0a62a4bb56758743afd3d
MD5 3839b9ee829fd791def57905df1d5b09
BLAKE2b-256 8df17e6e25400662d474ff4705b975483a9c10630f9f69060df992bb4237f7ac

See more details on using hashes here.

File details

Details for the file photocard-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: photocard-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.5 Darwin/24.0.0

File hashes

Hashes for photocard-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4981b3c3574c56afb1d83b977a9ab989fe02eba218e61550069a83e78919aa9f
MD5 bd21e4b22408dfc9760672ad7c80e190
BLAKE2b-256 9cd0cd4eb824b765311507c8b4c754637a915e561f9147692d875a3dc4ae6185

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