Created
October 12, 2017 06:54
-
-
Save horken7/f7f3ad1caa2f71e84bb64e01ca5fa7cd to your computer and use it in GitHub Desktop.
Booli API Python3.6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import requests | |
from hashlib import sha1 | |
import random | |
import string | |
import json | |
""" | |
Make a sample call to the Booli API asking for all listings in 'Nacka' in JSON format, | |
using 'YOUR_CALLER_ID' and 'YOUR_PRIVATE_KEY' for authentication | |
""" | |
callerId = "YOUR_CALLER_ID" | |
timestamp = str(int(time.time())) | |
unique = ''.join(random.choice(string.ascii_uppercase + string.digits) for x in range(16)) | |
hashstr = sha1((callerId + timestamp + "YOUR_PRIVATE_KEY" + unique).encode('utf-8')).hexdigest() | |
headers = {'Accept': 'application/vnd.booli-v2+json'} | |
url = "http://api.booli.se/listings?q=nacka&callerId=" + callerId + "&time=" + timestamp + "&unique=" + unique + "&hash=" + hashstr | |
response = requests.get(url, headers=headers) | |
if(response.status_code != 200): | |
print("fail") | |
result = json.loads(response.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment