Skip to main content

pyleapcard

PyPI codecov

A Python API for accessing your current card balance and stats for Ireland's public transport Leap Card. This is an unoffical API and the author/contributors are in no way connected to Leap Card, Transport for Ireland, or any other agency. The API provides methods to:

  • Get your credit balance and card status information
  • Get a list of your recent trips & topups

For an example of this in use, see my Leap Card BitBar plugin

Installation

pip install pyleapcard

Usage

It's very easy to use. Try the following to get your card status and current balance:

from pyleapcard import *
from pprint import pprint

session = LeapSession()
session.try_login("<username>","<password>")

overview = session.get_card_overview()
pprint(vars(overview))

returns:

{'auto_topup': u'Not Enabled',
 'balance': 25.02,
 'card_label': u"<Card Label>",
 'card_num': u'<Card Number>',
 'card_status': u'Unblocked',
 'card_type': u'Adult',
 'credit_status': u'Unblocked',
 'expiry_date': u'09/12/2023 12:00:00 AM',
 'issue_date': u'02/04/2012 12:00:00 AM'}

Or to get your recent trips/topups add the following:

events = session.get_events()
for item in events:
   pprint(vars(item))

returns:

{'date': u'06/09/2017',
'event_type': u'Travel Credit Deduction',
'price': -3.52,
'provider': u'Bus Eireann',
'time': u'11:45 AM',
'was_topup': False}
{'date': u'06/09/2017',
'event_type': u'Travel Credit Top-Up',
'price': 50.0,
'provider': u'Leap Top-Up App',
'time': u'10:00 AM',
'was_topup': True}
{'date': u'02/09/2017',
'event_type': u'Travel Credit Deduction',
'price': -3.52,
'provider': u'Bus Eireann',
'time': u'12:16 PM',
'was_topup': False}

Tests

python ./tests/tests.py

Contributing

Fork this repo, make some changes and create a new pull request!

Metadata

Release files for pyleapcard 0.1.9

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

Source distribution (sdist)

Source distribution for pyleapcard 0.1.9
File Size Uploaded Provenance Actions
pyleapcard-0.1.9.tar.gz 4.7 kB Without provenance Details for pyleapcard-0.1.9.tar.gz

Release files / pyleapcard-0.1.9.tar.gz

Download URL pyleapcard-0.1.9.tar.gz
Size 4.7 kB
Tags Source
SHA-256 checksum
How to use checksums
baf6be741dfe91bd5b5b88654bcb489c8e4285a83b01eee8ef0472ab6d7d9092
BLAKE2b-256 checksum
How to use checksums
fde3c0947eff90b74be20ba0dc019f10749bab797d4217128d999159b267ea75
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.5.0.1 requests/2.20.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.50.1 CPython/3.6.12

Security for pyleapcard 0.1.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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