<jupyter_start><jupyter_text>Documentation:- [Requests.py](http://docs.python-requests.org)- [json](https://docs.python.org/3/library/json.html)<jupyter_code># Example on Irail https://docs.irail.be/
# Retrieve the list of stations:
params = {'format': 'json', 'lang': 'en'}
r1 = requests.get('https://api.irail.be/stations', headers=headers, params=params)
print(r1.url, r1.status_code)
# load the json text into a Python structure:
stations = json.loads(r1.text)['station']

# For all stations, search their name and if Brussel print id:
for station in stations:
    if ('Brussels' in station['name']):
        print(station['name'], station['id'])

# Retrieve all connections from Brussels-Contral:
params = {'format': 'json', 'lang': 'en', 'id': 'BE.NMBS.008813003'}
r2 = requests.get('https://api.irail.be/liveboard', headers=headers, params=params)
print(r2.url, r2.status_code)
# load the json text into a Python structure and print trains to the airport:
departures = json.loads(r2.text)['departures']
for departure in departures['departure']:
    if ('Zaventem' in departure['station']):
        time = datetime.fromtimestamp(int(departure['time']))
        print(departure['stationinfo']['name'], departure['vehicle'], time, departure['platform'])

# Get details of one of the trains:
params = {'format': 'json', 'lang': 'en', 'id': 'BE.NMBS.IC2312'}
r3 = requests.get('https://api.irail.be/vehicle', headers=headers, params=params)
print(r3.url, r3.status_code)

# Actual position of that train:
vehinfo = json.loads(r3.text)['vehicleinfo']
print(vehinfo['locationX'], vehinfo['locationY'])

# All stops of that particular train:
stops = json.loads(r3.text)['stops']['stop']
for stop in stops:
    time = datetime.fromtimestamp(int(stop['time']))
    print(stop['station'], time.strftime("%H:%M:%S"))<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.17816404128191202, 'fraction_numerical': 0.014665942422596416, 'mean_word_length': 5.747252747252747, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 5, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '321636', 'license': 'CC-BY-4.0', 'n_tokens_mistral': 627, 'n_tokens_neox': 613, 'n_words': 147, 'path': '20220218/2_3_Course_OpenData.ipynb', 'repo_name': 'SNStatComp/CBSAcademyBD', 'size': '1841'}