Skip to main content

Wrapper for MARTA realtime rail/bus APIs

Project description

MARTApy

Python wrapper for MARTA realtime rail and bus APIs: http://www.itsmarta.com/app-developer-resources.aspx

Installation

To install via pip, just:

$ pip install martapy

Or, locally from the same directory as setup.py:

$ python setup.py install

Rail

To get a list of train arrivals:

from martapy import RailClient

rail_client = RailClient(api_key="your_api_key")
arrivals = rail_client.arrivals()

This returns an instance of martapy.rail.Arrivals(list) which has a few handy methods to filter results further.

For example, to print the destination and waiting time for upcoming arrivals at Peachtree Center Station:

from martapy import RailClient

rail_client = RailClient(api_key="your_api_key")
peachtree_station = rail_client.arrivals().by_station('peachtree')

for arrival in peachtree_station:
    print("To: {}, When: {}".format(arrival.destination, arrival.waiting_time))
With output that would look something like::

To: Airport, When: Arriving To: Lindbergh, When: 16 min To: Doraville, When: 19 min

Filters

To narrow results, martapy.rail.Arrivals(list) has a number of properties/methods:

  • Arrivals by line: red_line blue_line green_line gold_line

  • Arrivals by direction: northbound eastbound westbound southbound

  • Arrivals by waiting time: boarding arriving arrived

  • Arrivals grouped by station name: Arrivals.stations

  • Arrivals grouped by train ID: Arrivals.trains

  • Arrivals associated with a specific station: Arrivals.by_station('station name')

These can be chained as well for more specific results. For example, to get all arrivals for the red line which are heading southbound:

from martapy.rail import RailClient

rail_client = RailClient(api_key="your_api_key")
arrivals = rail_client.arrivals().red_line.southbound

Other properties

Each Arrivals instance returned is just a list of martapy.rail.Arrival objects, with properties similar to the filters above (station, direction, event_time, line…). To get the original JSON string back, use Arrival.json.

Bus

To get a list of active buses:

from martapy import BusClient

bus_client = BusClient()
buses = bus_client.buses()

To get active buses for a particular route number, use BusClient.buses(route=111) (or any other route number)

To filter this list down further, use filter() on the returned Buses list. For example, to return only Westbound buses:

from martapy import BusClient

bus_client = BusClient()
buses = bus_client.buses().filter(direction='Westbound')

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

martapy-1.1.tar.gz (7.4 kB view details)

Uploaded Source

Built Distribution

martapy-1.1-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file martapy-1.1.tar.gz.

File metadata

  • Download URL: martapy-1.1.tar.gz
  • Upload date:
  • Size: 7.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for martapy-1.1.tar.gz
Algorithm Hash digest
SHA256 496fc4370e63a201f7052aa8c258d5a83ac883b5f11c45c37245fe1d7491c389
MD5 da241091e03b7973e874c5da71e89421
BLAKE2b-256 d75125519b42766556bee53ad110dbf9e22bfde15c5e3875487ab54eac18db0d

See more details on using hashes here.

File details

Details for the file martapy-1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for martapy-1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 49dbcedc1d3048f4f75171095bee254d86e43382c3c33e0e1d00325e0ceaaade
MD5 dd6cdc0cf91d920670936f1c3ef29521
BLAKE2b-256 cf5a93571a8ce20679234f76f7a44dd74801f4642b75015cc0b194418c7dcb42

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