Skip to content

lpmi-13/micromaterials-api

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

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

Micromaterials API

Note: this is no longer in production, and exists only as a module for providing an endpoint for micromaterials to consume

Such Totes!

A REST-ful API For Words & Stuff

Read Adam's blog post here.

Setup

$ virtualenv .venv
$ source .venv/bin/activate
$ pip install -r requirements.txt

Running The Application

$ python wsgi.py

Running The Tests

Unit Tests

$ nosetests

Functional Tests

Note: these tests require a running MongoDB instance.

$ behave

The MongoDB instance defaults one running on localhost but you can change this in the settings.yml file.

$ MONGO_URL: '<insert the URL of your MongoDB instance here>'

Layout

  • krump :: the application source code.
  • test :: unit tests for the above source code.
  • cukes :: BDD tests for the application using Behave.

Serving Sentences

This next bit assumes that the DB is populated and the application is running.

To get sentences with a specific feature:

http://<SERVER_IP_ADDRESS:PORT>/api/sentence/<FEATURE>

Currently only JSON responses are supported: clients must supply an ACCEPT header value of application/json.

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.

  • simple_past
  • non_third_person_singular_simple_present
  • third_person_singular_simple_present
  • present_participle
  • past_participle
  • article
  • singular_noun
  • plural_noun
  • wh_determiner
  • comparative_adjective
  • superlative_adjective
curl -XGET -H 'Accept: application/json' http://localhost:9000/api/sentence/apostrophe

To get sentences with a specific word (if present in the database):

http://<SERVER_IP_ADDRESS:PORT>/api/sentence/word/<WORD>

The API also supports three query parameters:

  • count : the number of sentences to be returned. (Default 10.)

  • max-words : the maximum number of words in sentences returned. (Default 100.)

  • skip : allows paging and returns the next (skip * count) sentences in the response.

About

a simple API to send back sentences with metadata about the words in them. Consumes the /r/writingprompts subreddit

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published