<jupyter_start><jupyter_text>API Scavenger Game Challenge 1: Fork LanguagesYou will find out how many programming languages are used among all the forks created from the main lab repo of your bootcamp.<jupyter_code># import libraries here

import json
import requests
import pandas as pd

pd.set_option('display.max_columns', None)
pd.set_option('display.max_rows', None)<jupyter_output><empty_output><jupyter_text>Assuming the main lab repo is ironhack-datalabs/madrid-oct-2018, you will: 1. Obtain the full list of forks created from the main lab repo via Github API. To list forks, we can use the GET method. As explained in the GitHub API documentation, we need to make the request to: GET /repos/:owner/:repo/forks.<jupyter_code># your code here

response = requests.get('https://api.github.com/repos/ironhack-datalabs/madrid-oct-2018/forks')
results = response.json()
data = pd.DataFrame(results)
data.head(10)
data['language']
data.head(10)
data.columns
# data['git_commits_url']<jupyter_output><empty_output><jupyter_text>2. Loop the JSON response to find out the language attribute of each fork. Use an array to store the language attributes of each fork.Hint: Each language should appear only once in your array.Print the language array. It should be something like: ["Python", "Jupyter Notebook", "HTML"]<jupyter_code># your code here

data['language'].unique()<jupyter_output><empty_output><jupyter_text>Challenge 2: Count CommitsCount how many commits were made in the month of october of 2018. 1. Obtain all the commits made in October 2018 via API, which is a JSON array that contains multiple commit objects.<jupyter_code>username = 'ruesaintdenis'
token = 
gh_session = requests.Session()
gh_session.auth = (username, token)
url = 'https://api.github.com/repos/ironhack-datalabs/madrid-oct-2018/commits'
response = gh_session.get(url)
results = response.json()
data = pd.DataFrame(results)
data.head(10)

# from pandas.io.json import json_normalize
# response = requests.get('https://api.github.com/repos/ironhack-datalabs/madrid-oct-2018/commits')
# results = response.json()
# data = pd.DataFrame(results)
# data.head(10)
# from pandas.io.json import json_normalize
# response = requests.get('https://api.github.com/repos/ironhack-datalabs/madrid-oct-2018/commits')
# results = response.json()
# # data = pd.DataFrame(results)
# # data.columns
# # data['name'].value_counts()
# # data.head(10)
# flattened_data = json_normalize(results)
# flattened_data = pd.DataFrame(flattened_data)
# flattened_data.head()
# # flattened_data.columns

username = 'ruesaintdenis'
token = 
gh_session = requests.Session()
gh_session.auth = (username, token)
url = 'https://api.github.com/repos/ironhack-datalabs/madrid-oct-2018/commits'
response = gh_session.get(url)
results = response.json()
flattened_data = json_normalize(results)
flattened_data = pd.DataFrame(flattened_data)
flattened_data.head()


len(flattened_data['commit.committer.date'].value_counts())
# your code here<jupyter_output><empty_output><jupyter_text>2. Count how many commit objects are contained in the array.<jupyter_code># your code here<jupyter_output><empty_output><jupyter_text>Challenge 3: Hidden Cold JokeUsing Python, call Github API to find out the cold joke contained in the 24 secret files in the following repo:https://github.com/ironhack-datalabs/scavengerThe filenames of the secret files contain .scavengerhunt and they are scattered in different directories of this repo. The secret files are named from .0001.scavengerhunt to .0024.scavengerhunt. They are scattered randomly throughout this repo. You need to search for these files by calling the Github API, not searching the local files on your computer. 1. Find the secret files.<jupyter_code># your code here

username = 'ruesaintdenis'
token = 
gh_session = requests.Session()
gh_session.auth = (username, token)
url = 'https://api.github.com/repos/ironhack-datalabs/scavenger/git/trees/9308ccc8a4c34c5e3a991ee815222a9691c32476?recursive=1'
response = gh_session.get(url)
results = response.json()
data = pd.DataFrame(results)
data.head(10)
# /repos/:ironhack-datalabs/:scavenger/git/trees/:tree_sha?recursive=1
# /repos/:owner/:repo/git/trees/:tree_sha?recursive=1
#             ironhack-datalabs/scavenger<jupyter_output><empty_output><jupyter_text>2.  Sort the filenames ascendingly.<jupyter_code># your code here<jupyter_output><empty_output><jupyter_text>3. Read the content of each secret files into an array of strings.Since the response is encoded, you will need to send the following information in the header of your request:````pythonheaders = {'Accept': 'application/vnd.github.v3.raw'}````<jupyter_code># your code here<jupyter_output><empty_output><jupyter_text>4. Concatenate the strings in the array separating each two with a whitespace.<jupyter_code># your code here<jupyter_output><empty_output><jupyter_text>5. Print out the joke.<jupyter_code># your code here<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.10625, 'fraction_numerical': 0.01975806451612903, 'mean_word_length': 5.957924263674614, 'pattern_counts': {'":': 0, '<': 41, '<?xml version=': 0, '>': 41, 'https://': 7, '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': '10', 'dir': 'jupyter-structured-clean-dedup', 'id': '536427', 'license': 'MIT', 'n_tokens_mistral': 1699, 'n_tokens_neox': 1599, 'n_words': 443, 'path': 'module-1/API-Scavenger/your-code/main.ipynb', 'repo_name': 'ruesaintdenis/Ironhack-Labs', 'size': '4960'}