Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.

You can’t perform that action at this time.