Note: this is no longer in production, and exists only as a module for providing an endpoint for micromaterials to consume
A REST-ful API For Words & Stuff
Read Adam's blog post here.
$ virtualenv .venv $ source .venv/bin/activate $ pip install -r requirements.txt
Running The Application
$ python wsgi.py
Running The Tests
Note: these tests require a running MongoDB instance.
The MongoDB instance defaults one running on
localhostbut you can change this in the
$ MONGO_URL: '<insert the URL of your MongoDB instance here>'
krump:: the application source code.
test:: unit tests for the above source code.
cukes:: BDD tests for the application using Behave.
This next bit assumes that the DB is populated and the application is running.
To get sentences with a specific feature:
Currently only JSON responses are supported: clients must supply an
ACCEPTheader value of
If there are no sentences with the desired feature in the underlying DB, then a
204 NO CONTENT response will be returned.
FEATURE might be
apostrophe -- to get sentences with apostrophes -- or one
of the features listed below.
curl -XGET -H 'Accept: application/json' http://localhost:9000/api/sentence/apostrophe
To get sentences with a specific word (if present in the database):
The API also supports three query parameters:
count: the number of sentences to be returned. (Default
max-words: the maximum number of words in sentences returned. (Default
skip: allows paging and returns the next (skip * count) sentences in the response.