Skip to main content

No project description provided

Project description

citybussin

WIP, will eat your underfunded bus

CityBus (of West Lafayette)'s API wrapped up in a Python library

Usage

Import library and use

Example

from citybussin import Citybussin
c = Citybussin()

target_route = c.get_route_by_short_name("4B")
# {'key': '7de23591-ec36-4ba9-bc17-ccafeafb95c4', 'name': 'Purdue West', 'shortName': '4B', 'directionList': [{'direction': {'key': '191819d0-9173-4a89-855f-2e1e42decae1', 'name': 'to CityBus Center'}, 'destination': 'to Campus & CityBus Center', 'lineColor': '#007F49', 'textColor': '#FFFFFF', 'patternList': [{'key': 'cf0c64a3-7b5e-4c68-a012-2029aed9d7f8', 'isDisplay': True}], 'serviceInterruptionKeys': [3274]}, {'direction': {'key': '91801df8-8e37-44e2-8029-0662a713a619', 'name': 'to WL Walmart'}, 'destination': 'to Campus & WL Walmart', 'lineColor': '#007F49', 'textColor': '#FFFFFF', 'patternList': [{'key': 'b7e2e890-98a4-421c-8917-683467c8db03', 'isDisplay': True}], 'serviceInterruptionKeys': []}]}
target_route_stops = c.get_route_stops(target_route["key"])
# [{'name': 'Walmart West Lafayette (at Shelter): BUS403', 'stopCode': 'BUS403', 'stopType': 0}, {'name': 'Slim Chickens-Cumberland Ave (SE Corner):  BUS922', 'stopCode': 'BUS922', 'stopType': 0}, {'name': 'Northwestern Ave & Neil Armstrong Dr (NW): BUS162', 'stopCode': 'BUS162', 'stopType': 0}, {'name': 'Northwestern Ave & Yeager Rd (NW Corner): BUS161', 'stopCode': 'BUS161', 'stopType': 0}, {'name': 'Northwestern Ave & Windsor DR: BUS897', 'stopCode': 'BUS897', 'stopType': 0}, {'name': 'Northwestern Ave & Lindberg Rd: BUS375W', 'stopCode': 'BUS375W', 'stopType': 0}, {'name': 'Lindberg Rd & Kestral Blvd (NE Corner): BUS205', 'stopCode': 'BUS205', 'stopType': 0}, {'name': 'Village West Apts on Lindberg (at Shelter): BUS308', 'stopCode': 'BUS308', 'stopType': 0}, {'name': 'Station 21 on Lindberg (@ Shelter): BUS300', 'stopCode': 'BUS300', 'stopType': 0}, {'name': 'Blackbird Farms 2 on McCormick Rd: BUS304', 'stopCode': 'BUS304', 'stopType': 0}, {'name': 'SW Blackbird Farms Apt Buildings (W): BUS394', 'stopCode': 'BUS394', 'stopType': 0}, {'name': 'Schwartz Tennis Cntr on McCormick Rd: BUS906W', 'stopCode': 'BUS906W', 'stopType': 0}, {'name': 'McCormick Rd & Stadium Ave (NW Corner): BUS251W', 'stopCode': 'BUS251W', 'stopType': 0}, {'name': 'McCormick Rd & 3rd St: BUS501', 'stopCode': 'BUS501', 'stopType': 0}, {'name': 'Purdue West on Mitch Daniels Blvd (South): BUS566S', 'stopCode': 'BUS566S', 'stopType': 0}, {'name': 'Aspire Apts at Discovery Park: BUS011', 'stopCode': 'BUS011', 'stopType': 0}, {'name': 'Lilly Hall on Mitch Daniels Blvd (shelter): BUS345', 'stopCode': 'BUS345', 'stopType': 0}, {'name': 'Krannert Grad School: BUS260', 'stopCode': 'BUS260', 'stopType': 0}, {'name': 'Wabash Landing on State St (at Roebuck Dr): BUS644', 'stopCode': 'BUS644', 'stopType': 0}, {'name': 'CityBus Center: BUS215', 'stopCode': 'BUS215', 'stopType': 0}, {'name': 'CityBus Center: BUS215', 'stopCode': 'BUS215', 'stopType': 0}, {'name': 'Columbia St & 2nd St (NE Corner): BUS287NE', 'stopCode': 'BUS287NE', 'stopType': 0}, {'name': 'Wabash Landing on State St (at shelter): BUS156', 'stopCode': 'BUS156', 'stopType': 0}, {'name': 'Purdue Memorial Union (PMU) on MD Blvd: BUS271', 'stopCode': 'BUS271', 'stopType': 0}, {'name': 'Mitch Daniels Blv & Russell St (NE Corner): BUS547', 'stopCode': 'BUS547', 'stopType': 0}, {'name': 'First Street Towers on Mitch Daniels Blvd: BUS898', 'stopCode': 'BUS898', 'stopType': 0}, {'name': 'Purdue West on Mitch Daniels Blvd: BUS566', 'stopCode': 'BUS566', 'stopType': 0}, {'name': 'Purdue West on McCormick Rd: BUS504', 'stopCode': 'BUS504', 'stopType': 0}, {'name': 'McCormick Rd & Stadium Ave (NE Corner): BUS251E', 'stopCode': 'BUS251E', 'stopType': 0}, {'name': 'Schwartz Tennis Cntr on McCormick Rd: BUS906E', 'stopCode': 'BUS906E', 'stopType': 0}, {'name': 'SW Blackbird Farms Apt Buildings (E): BUS393', 'stopCode': 'BUS393', 'stopType': 0}, {'name': 'McCormick Rd & Lindberg Rd (SE Corner): BUS236', 'stopCode': 'BUS236', 'stopType': 0}, {'name': 'University Pl (at clubhouse): BUS551', 'stopCode': 'BUS551', 'stopType': 0}, {'name': 'Village West Apts on Lindberg (at Shelter): BUS308', 'stopCode': 'BUS308', 'stopType': 0}, {'name': 'Station 21 on Lindberg (@ Shelter): BUS300', 'stopCode': 'BUS300', 'stopType': 0}, {'name': 'Connection Point Church: BUS225', 'stopCode': 'BUS225', 'stopType': 0}, {'name': 'Lodge Apts on Cumberland Ave (@Shelter): BUS223', 'stopCode': 'BUS223', 'stopType': 0}, {'name': 'Walmart West Lafayette (at Shelter): BUS403', 'stopCode': 'BUS403', 'stopType': 0}]
target_route_directions = c.get_route_directions(target_route["key"])
# [{'direction': {'key': '191819d0-9173-4a89-855f-2e1e42decae1', 'name': 'to CityBus Center'}, 'destination': 'to Campus & CityBus Center', 'lineColor': '#007F49', 'textColor': '#FFFFFF', 'patternList': [{'key': 'cf0c64a3-7b5e-4c68-a012-2029aed9d7f8', 'isDisplay': True}], 'serviceInterruptionKeys': [3274]}, {'direction': {'key': '91801df8-8e37-44e2-8029-0662a713a619', 'name': 'to WL Walmart'}, 'destination': 'to Campus & WL Walmart', 'lineColor': '#007F49', 'textColor': '#FFFFFF', 'patternList': [{'key': 'b7e2e890-98a4-421c-8917-683467c8db03', 'isDisplay': True}], 'serviceInterruptionKeys': []}]
target_route_direction = target_route_directions[0]
# {'direction': {'key': '191819d0-9173-4a89-855f-2e1e42decae1', 'name': 'to CityBus Center'}, 'destination': 'to Campus & CityBus Center', 'lineColor': '#007F49', 'textColor': '#FFFFFF', 'patternList': [{'key': 'cf0c64a3-7b5e-4c68-a012-2029aed9d7f8', 'isDisplay': True}], 'serviceInterruptionKeys': [3274]}
next_depart_times = c.get_next_depart_times(target_route["key"], target_route_direction["direction"]["key"],
                                            target_route_stops[0]["stopCode"])
# [{'estimatedDepartTimeUtc': '2024-10-26T00:29:00Z', 'scheduledDepartTimeUtc': '2024-10-26T00:14:00Z', 'isOffRoute': False}, {'estimatedDepartTimeUtc': '2024-10-26T00:46:00Z', 'scheduledDepartTimeUtc': '2024-10-26T00:44:00Z', 'isOffRoute': False}, {'estimatedDepartTimeUtc': '2024-10-26T01:14:00Z', 'scheduledDepartTimeUtc': '2024-10-26T01:14:00Z', 'isOffRoute': False}]

import humanize
from datetime import datetime

humanize.naturaltime(datetime.fromisoformat(next_depart_times[0]["estimatedDepartTimeUtc"]))
# 14 minutes from now

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

citybussin-0.0.1a2.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

citybussin-0.0.1a2-py3-none-any.whl (3.5 kB view details)

Uploaded Python 3

File details

Details for the file citybussin-0.0.1a2.tar.gz.

File metadata

  • Download URL: citybussin-0.0.1a2.tar.gz
  • Upload date:
  • Size: 3.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.5 Windows/11

File hashes

Hashes for citybussin-0.0.1a2.tar.gz
Algorithm Hash digest
SHA256 973a6ac11da0d7ac77173f14b8c6afdf2a95234665fd7fcaf026382e1daf5a51
MD5 47fcb20def3e0dd46c9e0cde64320715
BLAKE2b-256 3dde8ea2d5f49fc09ea5b51a5d5b6252f6b390777bd538bf12ffe24e1c5bc826

See more details on using hashes here.

File details

Details for the file citybussin-0.0.1a2-py3-none-any.whl.

File metadata

  • Download URL: citybussin-0.0.1a2-py3-none-any.whl
  • Upload date:
  • Size: 3.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.5 Windows/11

File hashes

Hashes for citybussin-0.0.1a2-py3-none-any.whl
Algorithm Hash digest
SHA256 e1df6ed8807b96c37cc166b00c9cb8ad1d53fd8c67738a71ae88d72cf91f453c
MD5 e07933d0491a0fb696ccdfa6b3131534
BLAKE2b-256 3279a675346b6c0de2eee08ffe8cdb2c88d0256573c37ab3010ea70249bdb526

See more details on using hashes here.

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