ComputerScienceHouse / QuotefaultAPI

A RESTful API for interacting with CSH Quotefault, no webgui required!

Home Page:https://quotefault-api.csh.rit.edu/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Quotefault API

Python 3.6 Travis

A RESTful API for interacting with CSH Quotefault, no webgui required!

Format

{
    "id": "533",
    "quote": "I can't wait to get to New York and kill everyone",
    "submitter": "matted",
    "speaker": "Tanat",
    "quoteTime": "Fri, 27 Oct 2017 22:14:31 GMT"
}

All date parameters should use the format yyyymmdd. The format mm-dd-yyyy is deprecated.

If no quotes are found, all routes return 'none'.

/<api_key>/all : GET

Allowed Parameters: date, submitter, speaker

Example Request: ``

/<api_key>/random : GET

Allowed Parameters: date, submitter, speaker

Example Request: /random?submitter=dante

/<api_key>/newest : GET

Allowed Parameters: date, submitter, speaker

Example Request: /<api_key>/newest?submitter=matted

Output:

Returns the newest result from the submitter = matted

{
    "id": "533",
    "quote": "I can't wait to get to New York and kill everyone",
    "submitter": "matted",
    "speaker": "Tanat",
    "quoteTime": "Fri, 27 Oct 2017 22:14:31 GMT"
}

/<api_key>/between/<start>/<limit> : GET

Allowed Parameters: submitter, speaker Required Parameters: start, limit

Route produces a list of quotes between the two dates.

/<api_key>/<qid> : GET

Returns the specified quote. Ignores query parameters.

/<api_key>/create : PUT

Required Parameters: JSON Object

{
    "quote": "This is an example Quote",
    "submitter": "matted",
    "speaker": "Example Speaker"
}

/<api_key>/markov : GET

Optionally takes speaker and or submitter query string parameters.

Generates a quote using a Markov chain based on all quotes, optionally filted by speaker or submitter.

/<api_key>/markov/<count> : GET

Optionally takes speaker and or submitter query string parameters.

Generates a list of quotes (length = count) using a Markov chain based on all quotes, optionally filted by speaker or submitter.

/generatekey/<reason> : GET

Requires a reason as to the use of the API key. A key has a unique owner/reason pair.

Output:

91651at924r55egdfac5

Dev Setup

This project is built in Python 3, and all of its dependencies are accesible via pip.

Installing Python

This guide should cover installing python then you need to make sure you have pip installed.

Recommended setup

From inside your repository directory run

python3 -m virtualenv venv # Sets up virtualenve in the venv directory in your working directory
source venv/bin/activate # Activates the virtual environment
pip install -r requirements.txt # Installs all of the dependencies listed in the requirements to the virtualenv

At this point all the dependencies are installed, so copy config.env.py to config.py and fill in fields. You probably need to set SERVER_NAME = 127.0.0.1:5000, which is where flask will put local applications.

All that's left is running it with flask run. Flask should automatically find app.py, though you may want to set debug mode with export FLASK_ENV=development before you run it.

About

A RESTful API for interacting with CSH Quotefault, no webgui required!

https://quotefault-api.csh.rit.edu/

License:GNU General Public License v3.0


Languages

Language:Python 100.0%