Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Пример работы с подсказками DaData на Python. Использует пакет requests (http://docs.python-requests.org/).
# -*- coding: utf-8 -*-
import json
import requests
API_KEY = 'YOUR_API_KEY'
BASE_URL = 'https://suggestions.dadata.ru/suggestions/api/4_1/rs/suggest/%s'
def suggest(query, resource):
url = BASE_URL % resource
headers = {
'Authorization': 'Token %s' % API_KEY,
'Content-Type': 'application/json',
}
data = {
'query': query
}
r = requests.post(url, data=json.dumps(data), headers=headers)
return r.json()
print suggest(u'москва хабаровская', 'address')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment