<jupyter_start><jupyter_text>All Available EPL Leagues<jupyter_code># Import packages
import json
import os
import pandas as pd
import pymongo
import requests
from classes.progress_bar import printProgressBar

# Get the API details from the conda environment
headers = {
    'x-rapidapi-host': os.environ.get("api_host"),
    'x-rapidapi-key': os.environ.get("api_key")
}

def api_call(url):
    '''
    Call the given url and load the resulting JSON object

    Parameters
    ----------
    url: string
        The API endpoint to call with a GET request
    '''
    response = requests.request("GET", url, headers=headers)

    try:
        response = json.loads(response.text)
    except BaseException:
        print(f"Response {response.text} isn't valid JSON format.")

    return(response)
all_leagues = api_call("https://api-football-v1.p.rapidapi.com/v2/leagues")
pl = [{'season': x['season'],
  'start': x['season_start'], 
  'end': x['season_start'], 
  'available_coverage':x['coverage']} for x in all_leagues['api']['leagues'] if x['name'] == 'Premier League' and x['country'] == 'England']
pldf = pd.DataFrame(pl)
pldf.sort_values('season', inplace=True)
fixturedf = pldf.available_coverage.apply(pd.Series).fixtures.apply(pd.Series)
fixturedf.columns = ['fixture_' + x for x in fixturedf.columns]
pd.concat([pldf.drop('available_coverage', axis = 1), 
           pldf.available_coverage.apply(pd.Series).drop('fixtures', axis = 1),
           fixturedf], axis = 1)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14512922465208747, 'fraction_numerical': 0.0033134526176275677, 'mean_word_length': 4.11864406779661, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 1, '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': '648501', 'license': 'MIT', 'n_tokens_mistral': 513, 'n_tokens_neox': 501, 'n_words': 118, 'path': 'epl_league_details.ipynb', 'repo_name': 'willcanniford/python-football-api', 'size': '1509'}