Sunday, May 15, 2016

Accessing the API using api_key through python and retrieving the data

 

Following python script connects to public api using the api_key and we can retrieve the data from it. In order to get authenticated and read data we need to get the api_key.

# The python script is to test  connection to public api using the api_key and load the data based on the selection of object attributes

image 
Once we execute the script, sample output is as below.

C:\u01\Python-2711\python.exe C:/Users/xxxxxx/PycharmProjects/Learning/APIConnect.py
Please enter the city where you like to search : Nashua
Planet Fitness (603) 816-3555 03063
Cravings (603) 882-6626 03060
Thousand Crane II (603) 579-0888 03060
Preciou's Hair Salon (603) 882-0443 03060
Supercuts (603) 594-8545 03060
Tom's Barber Shop (603) 889-0223 03060
xxxxxxx