API implementation for the Questioner application. The API documentation can be accessed from here.
- 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
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" |
Make sure you have Python version 3 and Postgres installed on your local machine.
-
Clone the repository using the command:
$ git clone https://github.com/khwilo/questioner-api.git
-
Change directory to the location you cloned the repository:
$ cd questioner-api
-
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. -
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;
-
Create a virtual environment and activate it:
$ python3 -m venv venv $ source venv/bin/activate
-
Install the required dependencies:
$ pip install -r requirements.txt
-
Create the tables by running this script:
$ python3 manage.py
-
Run the Flask application:
$ export FLASK_APP=run.py $ flask run
-
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.
Running the unit test is done using the command pytest --cov=app/api
or python -m unittest discover -v
on your terminal.
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
.