Skip to content

PrameshKhanal/python-api-projects

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Python API Projects

Table of Contents

Introduction

🚀 API Fun Projects

Welcome to my API Fun Projects repository! Here, I create small Python projects using different public APIs.

🔍 Explore the Subfolders:

  • Each subfolder has a different project, showing how to use APIs in Python.
  • Check out the code to see how I make interesting things with data from various APIs.

🛠️ Learning and Trying Out:

  • These projects are my way of learning and trying out new things with Python and APIs.
  • See how to get, process, and show data from different APIs while improving your coding skills.

🌟 Get Involved:

  • Explore, add your own touch, or share your ideas.
  • I'd love to hear your thoughts and ideas to make these projects even better.

🚧 Still Building:

  • This repository is always changing as I add new projects. Keep an eye out for updates!

Back to Top

Modules, Libraries and Installations

The modules and libraries can be installed using the Python package installer 'pip'

Back to Top

HSL API - Stop Schedule Display

The Python program utilizes the Digitransit's Routing API to display the stop/station schedule using GraphQL query. The variable definition "stopName": "V6110" can be modified to include the desired name of the stops. To be able to access the API, user needs to register and use the API keys. In this case, the API key is accesed from environment variable using subscription_key = os.environ.get('HSL_SUBSCRIPTION_KEY'). API request was sent using urllib.request to the URL endpoint https://api.digitransit.fi/routing/v1/routers/hsl/index/graphql and the data is stored in json format in the parsed_response variable. The UNIX date and time information from the parsed_response variable are first stored in 4 different variable, converted to Helsinki timezone using the convert_date_time() function and added in the table.

Program output | VIEW FILE

  • stoptimesWithoutPatterns(numberOfDepartures: 5): 5 departures will be displayed in the output
  • Route Number: displays the bus/train/tram numbers for a stop (in this case V6110 stop; bus numbers 570 and 576)
  • Scheduled arrival: displays the secheduled arrival time
  • Real time arrival: displays the real time arrival at the stop
  • Status: displays the delay based on the Scheduled and Real time arrivals
  • Direction: displays the vehicle's head sign/route name

Stop Schedule

Back to Top