Skip to main content

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/

Metadata

Release files for photocard 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for photocard 0.1.2
File Size Uploaded
photocard-0.1.2.tar.gz 6.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for photocard 0.1.2
File Interpreter ABI Platform
photocard-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 13.7 kB

Release files / photocard-0.1.2.tar.gz

Download URL photocard-0.1.2.tar.gz
Size 6.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c6c4742fee736a19cce4e243a6938e71c6aedc97c3a0a62a4bb56758743afd3d
BLAKE2b-256 checksum
How to use checksums
8df17e6e25400662d474ff4705b975483a9c10630f9f69060df992bb4237f7ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.11.5 Darwin/24.0.0

Release files / photocard-0.1.2-py3-none-any.whl

Download URL photocard-0.1.2-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4981b3c3574c56afb1d83b977a9ab989fe02eba218e61550069a83e78919aa9f
BLAKE2b-256 checksum
How to use checksums
9cd0cd4eb824b765311507c8b4c754637a915e561f9147692d875a3dc4ae6185
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.6.1 CPython/3.11.5 Darwin/24.0.0

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page