Skip to main content

Unofficial API to retrieve STCP information for public transit buses in Porto, Portugal

Project description

STCP API

Unofficial API to retrieve STCP information for public transit buses in Porto, Portugal.

Retrieves static data about lines, stops, locations, and real-time estimates of bus arrivals.

Since it's based on a non-official API, it may stop working in the future. Confirmed working as of 24 February 2024.

See the files at stcp/api.py and stcp/util.py for the complete documentation, and examples.md for usage examples.

Available operations

Function Description
get_lines gets a list of all STCP lines.
get_line_directions gets a list of directions (usually 2) of a line.
get_line_stops gets a list of all stops of a line.
get_stop_data gets information about a stop, including a list of all the lines that pass through it.
get_stop_real_times gets a real-time list of buses passing through a stop soon (up to one hour from the current time).

Utilities

Function Description
get_all_stops gets a set of all STCP stop codes across all lines.
stop_departures gets a map of upcoming departures of a stop, grouped by line.
follow_line gets the current times for a given line.

Notes

To be able to get a stop's real-time departures, a "hash" is needed, which can be obtained by scraping STCP's webpage. These hashes are stored in a local CSV cache for efficiency purposes, which is generated on the first execution. However, the cache can be disabled, and the hash request can be made on-the-fly, by passing use_hash_cache=False to the get_stop_real_times function.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

stcp_api-1.1.3-py3-none-any.whl (19.9 kB view details)

Uploaded Python 3

File details

Details for the file stcp_api-1.1.3-py3-none-any.whl.

File metadata

  • Download URL: stcp_api-1.1.3-py3-none-any.whl
  • Upload date:
  • Size: 19.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.11.10

File hashes

Hashes for stcp_api-1.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 c324d66bea10f5215f0228f724ca4c87783146edc97ccfa2c830a4a189bf2ea0
MD5 7f030c51f6083982523a22a5f6ab0786
BLAKE2b-256 973553949ec6d457a3997c10787a8e9878aba601498f13fe7b31d3e847f80a4d

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