import json import requests # tutorial source: https://www.digitalocean.com/community/tutorials/how-to-use-web-apis-in-python-3 api_key = 'your_api_key_here' deals_api_url = 'https://api.aqarsas.sa/deals/' stats_api_url = 'https://api.aqarsas.sa/stats/' top_deals_api = 'https://api.aqarsas.sa/papi_topdeals/' land_details_api = 'https://api.aqarsas.sa/papi_landdetails/' headers = {'Content-Type': 'application/json'} stats_json_req = { "key": api_key, 'stat_type': "number_of_deals", "calendar": "gregorian", "start_date": "2016-01-01", "end_date": "2016-01-31", "state": 0, "city": "الرياض" } print("Printing response for a sample call to /stats/ : ") response = requests.post(stats_api_url, headers=headers, json=stats_json_req) result = json.loads(response.content) for key, value in result.items(): print (key, value) deals_json_req = { 'key': api_key, 'calendar': "hijri", 'start_date': "1439-05-01", 'end_date': "1439-05-30", 'category': "سكني", 'dtype': "قطعة أرض", 'state': 0, 'city': "الرياض", 'min_meter_price': 1000, 'max_meter_price': 1200, 'min_area': 100, 'max_area': 5000, 'hai': "القادسيه", 'hai_exact_match': 0, } print("Printing response for a sample call to /deals/ :") response = requests.post(deals_api_url, headers=headers, json=deals_json_req) result = json.loads(response.content) for key, value in result.items(): print (key, value) top_deals_json_req = { "key": api_key, "calendar": "gregorian", "start_date": "2008-12-29","end_date": "2010-12-29", "state": 0,"city": "الرياض", "hai": "القادسيه","hai_exact_match": 0, "sort_by_ascending":0, "sort_by":"area" , "results_n":10 } print("Printing response for a sample call to /top_deals/ :") response = requests.post(top_deals_api, headers=headers, json=top_deals_json_req) result = json.loads(response.content) for key, value in result.items(): print (key, value) land_details_json_req = { "key": api_key, "state": 0,"city": "الرياض", "m566":"3114","unit":"784" } print("Printing response for a sample call to /land_details/ :") response = requests.post(land_details_api, headers=headers, json=land_details_json_req) result = json.loads(response.content) for key, value in result.items(): print (key, value)