Skip to content

API endpoints for the Questioner web application

Notifications You must be signed in to change notification settings

khwilo/questioner-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QUESTIONER API

Build Status Coverage Status Maintainability

DESCRIPTION

API implementation for the Questioner application. The API documentation can be accessed from here.

Work In Progress

  • User registration
  • User log in
  • User log out
  • Admin user creating a meetup
  • Fetching all meetups
  • Fetching a specific meetup
  • Admin user deleting a meetup
  • User posting a question
  • User commenting on a question
  • User upvoting on a question
  • User downvoting on a question
  • User RSVP meetup

API ENDPOINTS

NOTE:

  • API endpoints are prefixed by /api/v2.
  • Fields for the date are specified like this month day year time. An example date format: "Jan 10 2019 12:15AM"
Method Endpoint Description
POST /auth/signup Create a user record
POST /auth/login Log in a user
POST /meetups Create a meetup record
GET /meetups/<meetup-id> Fetch a specific meetup record
GET /meetups/upcoming/ Fetch all upcoming meetup records
POST /meetups/<meetup-id>/questions Create a question for a specific meetup
POST /questions/<question_id>/comments Comment on a specific question
PATCH /questions/<question-id>/upvote Upvote (increase votes by 1) a specific question
PATCH /questions/<question-id>/downvote Downvote (decrease votes by 1) a specific question
POST /meetups/<meetup-id>/rsvps Respond to meetup RSVP with a "yes", "no" or "maybe"

Pre-requisites

Make sure you have Python version 3 and Postgres installed on your local machine.

Usage

  1. Clone the repository using the command:

    $ git clone https://github.com/khwilo/questioner-api.git
  2. Change directory to the location you cloned the repository:

    $ cd questioner-api
  3. Set environment variables for APP_SETTINGS, SECRET_KEY, JWT_SECRET_KEY, DATABASE_URL and DATABASE_TEST_URL. For more information see the config.py file from the instance directory.

  4. Create a database for the development database and test environment, example:

    $ sudo -u postgres psql
    $ CREATE DATABASE yourdbname;
    $ CREATE USER youruser WITH ENCRYPTED PASSWORD 'yourpassword';
    $ GRANT ALL PRIVILEGES ON DATABASE yourdbname TO youruser;
  5. Create a virtual environment and activate it:

    $ python3 -m venv venv
    $ source venv/bin/activate
  6. Install the required dependencies:

    $ pip install -r requirements.txt
  7. Create the tables by running this script:

    $ python3 manage.py
  8. Run the Flask application:

    $ export FLASK_APP=run.py
    $ flask run

Test the API on Postman

  • The accepted content type header is as follows:

    • key: Content-Type
    • value: application/json
  • Authorization header is as follows:

    • key: Authorization
    • value: Bearer <access-token>

The access-token is found from the response when a user logs in.

Unit testing

Running the unit test is done using the command pytest --cov=app/api or python -m unittest discover -v on your terminal.

Heroku

The API is hosted on Heroku at https://q-questioner-api.herokuapp.com/. Currently there is no default route that is configured but you can test the API endpoints by providing their paths after the host name. For example, to test user account creation use the URL https://q-questioner-api.herokuapp.com/api/v2/auth/signup.

About

API endpoints for the Questioner web application

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages