Python Shell
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
constructor_io
examples
fixtures/ac.cnstrc.com
tests
.gitignore
.travis.yml
LICENSE
README.md
requirements-py2.txt
requirements.txt
run_example.gif
setup.py

README.md

Constructor-IO Python Client Build Version License: MIT

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.

Installation

pip install constructor-io

Usage

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))

Try it:

# If you didn't install constructor-io with pip, uncomment next line:
# export PYTHONPATH=$PYTHONPATH:$(pwd)

python examples/autocomplete.py

Run example

Check examples folder. You can read more in our most up-to-date API documentation.