- Introduction
- Base URI / Live Deployment
- Local Server Setup
- Authentication
- Endpoints
- Sample Usage
- Error Handling
- UML Class Diagram
- Limitations and Assumptions
- Authors
Welcome to the Events App documentation for Team SpitFire! This document provides detailed information on setting up the server locally, API endpoints, authentication, sample usage, error handling, and more.
The Events App is hosted for live testing at [insert_base_uri_here]. Replace
[insert_base_uri_here]
with the actual base URI where the API is deployed.
To get started with the local development environment, clone the repository:
$ git clone https://github.com/kevinkoech357/spitfire-events-backend.git
$ cd spitfire-events-backend
You can set up the environment using either venv
or pipenv
. Here are
instructions for both:
Using venv
:
# create Virtual Environment
$ python3 -m venv venv
# Activate Virtual Env
$ source venv/bin/activate
# Install Dependencies
$ pip install -r requirements.txt
Using pipenv
:
$ pip install pipenv
# create virtuel environment
$ pipenv --python 3.10
# Activate virtual env
$ pipenv shell
# install dependencies in requirements.txt or pipfile
$ pipenv install
Make sure to set the following environment variables:
SECRET_KEY: [Your Secret Key]
SQLALCHEMY_DATABASE_URI: [Your Database URI]
OAUTHLIB_INSECURE_TRANSPORT: 1
ANDROID_CLIENT_ID:
IOS_CLIENT_ID:
$ python3 run.py
Note: ensure you are connected to the internet before running tests and are
in spitfire-events
directory
# install test suite and HTTP requests library
$ pip install requests pytest
# Run the tests in test_crud.py
$ pytest test_event.py -v
The authentication mechanism used by this API is Google oAuth2 with session cookies see Authentication here
POST 'API/auth'
- Retrieves a person from the database using user id
- Request Body:
- Input: JSON with auth token.
{ "token": "google id token", }
- Returns: JSON response with a message and person object containing
id
,name
anddate created
Example Response
{
"message": "success",
"name": "user display name",
"email": "user email",
"avatar": "user image url"
}
status code: 200 see Api Documentation here
Errors are returned as JSON objects in the following format with their error code
{
"error": "error name",
"message": "error description"
}
The API will return 5 error types, with diffreent descriptions when requests fail;
- 400: Request unprocessable
- 403: Forbidden
- 404: resource not found
- 422: Bad Request
- 429: Too Many Requests(rate limiting)
- 500: Internal server error