Python using API

A small example on using an API is provided below. I have attempted to make the programme as small as possible. It shows how the response is derived. This response is then translated into a dataframe. this dataframe is then split into keys and values.

import requests
import pandas as pd
response = requests.get("http://api.open-notify.org/astros.json")
if (response.status_code == 200):
  dataframe = pd.DataFrame.from_dict(response.json(),   orient="Index")
  ff=dataframe.iloc[2]
  w = ff[0]
  for j in range(len(w)):
    for key, value in w[j].items():
    print('key ',key,' value ',value)
elif (response.status_code == 404) :
  print("Result not found!")

Door tom