Skip to content

Instantly share code, notes, and snippets.

@horken7
Created October 12, 2017 06:54
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save horken7/f7f3ad1caa2f71e84bb64e01ca5fa7cd to your computer and use it in GitHub Desktop.
Save horken7/f7f3ad1caa2f71e84bb64e01ca5fa7cd to your computer and use it in GitHub Desktop.
Booli API Python3.6
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