Skip to content

Python wrapper for RTL API. Implemented by intercepting traffic from RTL app. You can use this to purchase tickets programmatically or check the location of RTL buses live.

Notifications You must be signed in to change notification settings

arkangel-dev/py-rtl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

py-rtl

Python wrapper for RTL API (https://bo.rtl.mv). Implemented by intercepting traffic from RTL app. You can use this to purchase tickets programatically or check the location of RTL buses live.

Usage

Purchasing a ticket

from rtl import RtlWrapper, Constants

client = RtlWrapper('your-email-here', 'and-your-password-here')
client.LoginIfExpired()

product = client.GetProduct(
    route='Vilimale Ferry', 
    product='Villimale Single Trip',
    type=Constants.VehicleType.VESSEL
)
# Purchase a ticket
product.PurchaseTicket() 

# Turn this into a QR code to use it with the terminals
# on the buses / ferry terminals
print(product.tickets[0].qrContent) 

Example to monitor live location and call a function when vehicle enters a specific location

from rtl import RtlWrapper, Constants, LiveMonitoring

client = RtlWrapper('your-email-here', 'and-your-password-here')
client.LoginIfExpired()

def OnEntryOfRange(event:LiveMonitoring.Event):
    print("Bus {} is within range".format(event.vehicleCode))

if __name__ == '__main__':
    param = LiveMonitoring.Parameter()
    param.routes = ['145', '131']               # Select the routes to monitor
    param.coordinates = (4.174107, 73.486815)   # Select the point to monitor
    param.distance = 0.05                      # Trigger radius (In KM, defaults to 35 meters) 
    param.callback = OnEntryOfRange             # Method to call when bus enters 
    client.OnBusEntry(param)                    # Register the event
    input()                                     # Wait it out

Note

The additonal optional parameters for constructor (login_enc_key and login_enc_iv) are the encryption parameters for the login and registration endpoint. What's happening is that before the login endpoint is called the payload is encrypted with the aforementioned encryption key and the server decrypts the payload to verify the login and send a JWT token. The key was extracted from an Android build of the RTL app.

About

Python wrapper for RTL API. Implemented by intercepting traffic from RTL app. You can use this to purchase tickets programmatically or check the location of RTL buses live.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages