A Python package for the Constructor.io API. Constructor.io provides a lightning-fast, typo-tolerant autocomplete service that ranks your users' queries by popularity to let them find what they're looking for as quickly as possible.
pip install constructor-io
Here is a simple example how autocomplete works:
from constructor_io import ConstructorIO # Listed token and key will work for a small demo :) API_TOKEN = None KEY = "P03bVBcmyYjSG1ZQyD4V" constructor_instance = ConstructorIO(API_TOKEN, KEY) if __name__ == "__main__": while True: misspelled = raw_input("Type mispelled things and press enter! > ") query = constructor_instance.query(misspelled) suggestions = query["suggestions"] suggested_queries = [suggestion["value"] for suggestion in suggestions] print("Suggested queries: " + " | ".join(suggested_queries))
# If you didn't install constructor-io with pip, uncomment next line: # export PYTHONPATH=$PYTHONPATH:$(pwd) python examples/autocomplete.py