Querying a remote API from a Python script
Question: I would like to integrate the `reviews API` from Zomato in my Python script.

I know basic programming in Python, but as for API integration, I want to know

  * how to proceed with the API
  * what steps should be taken to query the API from Python
  * how to integrate the results in my script

What are the viable options?


Answer: You may get started with Python's `requests` module.

Quick example to get a list of categories:

    
    
    import requests
    
    domain = "https://developers.zomato.com/api/v2.1"
    headers = {'user-key': 'your_api_key_here'}
    
    response = requests.get("{}/categories".format(domain), headers=headers).json()
    
    for category in response["categories"]:
        print(category)
    

This will output something like:

    
    
    {"categories": {"id": 1, "name": "Delivery"}}
    {"categories": {"id": 2, "name": "Dine-out"}}
    {"categories": {"id": 3, "name": "Nightlife"}}
    {"categories": {"id": 4, "name": "Catching-up"}}
    {"categories": {"id": 5, "name": "Takeaway"}}
    # etc...
    

Documentation for `requests` [can be found here.](http://docs.python-
requests.org/en/master/)

