<jupyter_start><jupyter_text>Example: Data aggregationCurrently, resources that can be downloaded from [UMWaw API](https://api.um.warszawa.pl/) include:1. information about currently active buses,1. information about currently active buses downloaded over a period of time,1. all bus stop ids based on bus stop name,1. all lines using bus stop based on its id and number,1. line timetable on a bus stop based on its id and number,1. bus stops coordinates.Before downloading data, set up an account on [UMWaw API](https://api.um.warszawa.pl/) to generate your API key. In the beginning, you can use API key generated just for the purpose of testing of this particular library.<jupyter_code>API_KEY = '5fbe79ed-1f5b-4019-ab03-641443842d8b'
from bwaw.api.requests import *
from bwaw.io.save import save_response_to_csv, save_response_to_pickle<jupyter_output><empty_output><jupyter_text>Online bus activity<jupyter_code>get_active_buses(api_key=API_KEY)[:2]<jupyter_output><empty_output><jupyter_text>Each request is formatted into a list of either values or dictionaries. Buses active at the moment of requesting resources provide information on line number, geographical coordinates (lon and lat), brigade and vehicle number as well as time of information update.This resource can be downloaded also over a period of specified time. If a connection fails, it attempts to download it again starting from the failing resource and can also save partial results if a user has to stop downloading the resources (partial results are deleted if the whole process is successful). All partial results are then merged into one list.<jupyter_code>get_active_buses_over_time(api_key=API_KEY, 
                           no_of_requests=2, 
                           interval_btwn_requests=1, 
                           keep_partial_if_fail=True)[:2]<jupyter_output>INFO:Attempt 1/3.
INFO:Initialising new download session.
100%|██████████| 2/2 [01:01<00:00, 35.91s/it]INFO:Data collected in 1/3 attempts.<jupyter_text>Static resourcesWhen downloading resources, remember to follow typing guideliness. If you pass wrong types, validation metrics will block you request attempt and inform you about the problem.<jupyter_code>get_bus_stops_ids_by_name(api_key=API_KEY, name='Rondo ONZ')
get_all_lines_on_bus_stop(api_key=API_KEY, bus_stop_id='7088', bus_stop_nr='01')[:5]
get_timetable_for_line_on_bus_stop(api_key=API_KEY, bus_stop_id='7088', bus_stop_nr='01', line='109')[:10]
get_bus_stops_coordinates(api_key=API_KEY)[:5]<jupyter_output><empty_output><jupyter_text>All responses are stored in a list that is convertable to DataFrame, to avoid confusion.  Saving to a fileCurrently saving and loading using two formats is provided: `.csv` and `.pkl`.<jupyter_code>response = get_active_buses(api_key=API_KEY)[:2]
save_response_to_csv(data=response, path='data.csv')
response = get_bus_stops_ids_by_name(api_key=API_KEY, name='<NAME>')
save_response_to_pickle(data=response, path='data.pkl')<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.08178191489361702, 'fraction_numerical': 0.023936170212765957, 'mean_word_length': 5.917241379310345, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 21, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '127619', 'license': 'MIT', 'n_tokens_mistral': 973, 'n_tokens_neox': 914, 'n_words': 296, 'path': 'examples/notebooks/downloading_data.ipynb', 'repo_name': 'zkwiatkowska/buses-warsaw', 'size': '3011'}