jfluhmann / autocompleter-api

A simple autocomplete suggestion api service

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Autocompleter API

This is a simple autocomplete API that, when given a partial word, returns a list of autocomplete suggestions.

Overview

The Autocompleter API has two routes:

  • / - returns a simple JSON {"ping": "pong"} response
  • /words/{word} - returns a JSON response list of suggested autocompletes, based on {word}
    {"words":["word0","word1"]}

Running the API

The API can be run in several ways:

  • Docker

    docker build -t autocompleter-api:0.1.2 .
    docker run -dp 8000:80 autocompleter-api:0.1.2
  • Docker compose

    docker-compose up -d
  • Helm Chart

    If using minikube, run the following prior to running helm install:

    docker build -t autocompleter-api:0.1.2 .
    minikube cache add autocompleter-api:0.1.2

    To install the helm chart and deploy autocompleter-api

    helm install autocompleter-api charts/autocompleter-api

Using the API

The API path for retrieving autocomplete suggestions is /words/{word} where {word} can be a partial (or whole) word, such as scho or school.

Two easy ways of testing responses with the API are using curl or using the interactive API documentation (provided by Swagger UI) in the browser.

Using curl

If using docker or docker-compose

$ curl http://localhost:8000/words/school

If using Helm Chart (minikube/kubernetes)

$ curl http://<endpoint>/words/school

Results

{"words":["schoolmate","schoolboy","schoolgirlish","schoolhouse","schoolyard","schoolmaster","schoolbook","school","schoolroom","schoolwork","schoolmarm","schoolgirl","schoolteacher"]}

Using Swagger UI

Autocompleter API uses FastAPI, which includes interactive API documentation (provided by Swagger UI). Open in the browser by visiting http://localhost:8000/docs (or http://<endpoint>/docs)

Alternatively

You could also visit http://localhost:8000/words/school (or http://<endpoint>/words/school) in your browser.

About

A simple autocomplete suggestion api service


Languages

Language:Python 48.3%Language:Smarty 46.2%Language:Dockerfile 5.6%