-
Notifications
You must be signed in to change notification settings - Fork 0
Api Documentation
The Codezvous-App API is organized around REST. The API has predictable resource oriented URLs, accepts JSON-encoded request bodies, returns JSON-encoded responses, and uses standard HTTP response codes and verbs.
API routes are not user-facing and should only be used by developers.
Resources:
Endpoints for the Users resource:
-
Log In -
POST /api/auth/login -
Sign Up -
POST /api/auth/signup -
Log Out -
GET /api/auth/logout -
Authenticate -
GET /api/auth -
Unauthorized -
GET /api/auth/unauthorized -
Retrieve All Users -
GET /api/users -
Retrieve Single User -
GET /api/users/<int:id> -
Retrieve User Groups -
GET /api/users/<int:id/groups> -
Retrieve User Events -
GET /api/users/<int:id/events> -
Retrieve User RSVPs -
GET /api/users/<int:id/rsvps>
Logs an existing user into the application
| Parameter | Type | Description | Notes |
|---|---|---|---|
email |
string |
email of the user logging in |
required |
password |
string |
password of the user logging in |
required |
Returns a current user object if successful and sets an HTTP-only auth cookie, and returns an errors object otherwise.
Creates a new user and logs them into the application
| Parameter | Type | Description | Notes |
|---|---|---|---|
username |
string40 |
Desired username of the new user |
required, unique |
email |
string |
Desired email of the new user |
required, unique |
password |
string |
Desired password of the new user |
required |
zipcode |
string |
Desired password of the new user |
required |
inage_url |
string |
Url path to desired image of the new user | required |
Returns a current user object if successful and sets an HTTP-only auth cookie, and returns an errors object otherwise.
Logs out the current user
Returns a logged out message.
Authenticates a user
| Parameter | Type | Description | Notes |
|---|---|---|---|
id |
ID |
id of the user |
required |
Returns a current user object if successful, and returns an errors object otherwise.
Returns unauthorized JSON when flask-login authentication fails
Returns an errors object.
Returns all users stored in the database.
Returns an array of user objects.
Returns user specified by id provided in URL
| Parameter | Type | Description | Notes |
|---|---|---|---|
id |
ID |
id of the user |
required |
Returns a user object.
Returns groups specified by user id provided in URL
| Parameter | Type | Description | Notes |
|---|---|---|---|
id |
ID |
id of the user |
required |
Returns an array of group objects.
Returns events specified by user id provided in URL
| Parameter | Type | Description | Notes |
|---|---|---|---|
id |
ID |
id of the user |
required |
Returns an array of event objects.
Returns rsvps specified by user id provided in URL
| Parameter | Type | Description | Notes |
|---|---|---|---|
id |
ID |
id of the user |
required |
Returns an array of event objects.
Endpoints for the Groups resource:
-
Retrieve All Groups -
GET /api/groups -
Retrieve a Single Group -
GET /api/groups/:id -
Retrieve all events for a Single Group -
GET /api/groups/:id/events -
Retrieve the leader of a Single Group -
GET /api/groups/:id/leader -
Retrieve all members of a Single Group -
GET /api/groups/:id/members -
Create a Group -
POST /api/groups -
Edit a Group -
PUT /api/groups/:id -
Delete a Group -
DELETE /api/groups/:id -
Create a Users_Group -
POST /api/groups/new-user
Retrieves all the groups
Returns an array of group objects if successful, and returns an errors object otherwise
Retrieves a single group with the specified id
| Parameter | Type | Description | Notes |
|---|---|---|---|
id |
ID |
id of the group to retrieve |
required |
Returns a group object if successful, and returns an errors object otherwise.
Retrieves an array of all Events associated with a group with the specified id
| Parameter | Type | Description | Notes |
|---|---|---|---|
id |
ID |
id of the group to retrieve |
required |
Returns an array of event objects if successful, and returns an errors object otherwise
Retrieves a user object with the user who owns the group with the specified id
| Parameter | Type | Description | Notes |
|---|---|---|---|
id |
ID |
id of the group to retrieve |
required |
Returns a user objects if successful, and returns an errors object otherwise
Retrieves an array of all Members associated with a group with the specified id
| Parameter | Type | Description | Notes |
|---|---|---|---|
id |
ID |
id of the group to retrieve |
required |
Returns an array of user objects if successful, and returns an errors object otherwise
Creates a new group
| Parameter | Type | Description | Notes |
|---|---|---|---|
group_name |
string |
group_name of the group being created |
required |
description |
text |
description of the group being created |
required |
city |
string |
city of the group being created |
required |
state |
string |
state of the group being created |
required |
zip_code |
string |
zip_code of the group being created |
required |
is_active |
string |
is_active of the group being created |
required |
image_url |
string |
image_url of the group being created |
required |
leader_id |
integer |
leader_id of the group being created |
required |
Returns the created group object if successful, and returns an errors object otherwise.
Edits an existing group of that the current user is the leader of, **requires authentication with a cookie**
| Parameter | Type | Description | Notes |
|---|---|---|---|
id |
ID |
id of the group to edit |
required |
| Parameter | Type | Description | Notes |
|---|---|---|---|
group_name |
string |
group_name of the group being edited |
required |
description |
text |
description of the group being edited |
required |
city |
string |
city of the group being created |
required |
state |
string |
state of the group being created |
required |
zip_code |
string |
zip_code of the group being created |
required |
is_active |
string |
is_active of the group being created |
required |
image_url |
string |
image_url of the group being created |
required |
leader_id |
integer |
leader_id of the group being created |
required |
Returns the edited group object if successful, and returns an errors object otherwise.
Deletes an existing group of that the current user is the leader of, **requires authentication with a cookie**
| Parameter | Type | Description | Notes |
|---|---|---|---|
id |
ID |
id of the group to edit |
required |
Returns a success message if successful, and returns an errors object otherwise.
Endpoints for the Events resource:
-
Events-
Retrieve All Events -
GET /api/events -
Retrieve a Single Event -
GET /api/events/:id -
Create an Event -
POST /api/events -
Edit an Event -
PUT /api/events/:id -
Delete an Event -
DELETE /api/events/:id
-
Retrieve All Events -
-
Comments-
Retrieve all Comments for a Single Event -
GET /api/events/:id/comments -
Create a Comment -
POST /api/events/comments
-
Retrieve all Comments for a Single Event -
Retrieves all the events
Returns an array of event objects if successful, and returns an errors object otherwise
Retrieves a single event with the specified id
| Parameter | Type | Description | Notes |
|---|---|---|---|
id |
ID |
id of the event to retrieve |
required |
Returns an event object if successful, and returns an errors object otherwise.
Create a new event
| Parameter | Type | Description | Notes |
|---|---|---|---|
event_name |
string |
event_name of the event being created |
required |
description |
text |
description of the event being created |
required |
city |
string |
city of the event being created |
required |
state |
string |
state of the event being created |
required |
zip_code |
string |
zip_code of the event being created |
required |
virtual |
string |
virtual of the event being created |
required |
type |
string |
type of the event being created |
required |
status |
string |
status of the event being created |
required |
image_url |
string |
image_url of the event being created |
required |
group_id |
integer |
group_id of the event being created |
required |
start_time |
datetime |
start_time of the event being created |
required |
end_time |
datetime |
end_time of the event being created |
required |
Returns the created event object if successful, and returns an errors object otherwise.
Edits an existing event of that the current user is the leader of the group that is hosting the event, **requires authentication with a cookie**
| Parameter | Type | Description | Notes |
|---|---|---|---|
id |
ID |
id of the event to edit |
required |
| Parameter | Type | Description | Notes |
|---|---|---|---|
event_name |
string |
event_name of the event being created |
required |
description |
text |
description of the event being created |
required |
city |
string |
city of the event being created |
required |
state |
string |
state of the event being created |
required |
zip_code |
string |
zip_code of the event being created |
required |
virtual |
string |
virtual of the event being created |
required |
type |
string |
type of the event being created |
required |
status |
string |
status of the event being created |
required |
image_url |
string |
image_url of the event being created |
required |
group_id |
integer |
group_id of the event being created |
required |
start_time |
datetime |
start_time of the event being created |
required |
end_time |
datetime |
end_time of the event being created |
required |
Returns the edited event object if successful, and returns an errors object otherwise.
Deletes an existing event of that the current user is the leader of the group that is hosting the event, **requires authentication with a cookie**
| Parameter | Type | Description | Notes |
|---|---|---|---|
id |
ID |
id of the event to delete |
required |
Returns a success message if successful, and returns an errors object otherwise.
Endpoints for the RSVPs resource:
-
Retrieve all users attending an event -
GET /api/events/:id/attendees -
RSVP for an Event -
POST /api/events/:id/rsvps -
Remove RSVP for an Event -
DELETE /api/events/:id/rsvps
Returns rsvps for all users attending an event
Returns an array of rsvp objects if successful, and returns an errors object otherwise.
Creates an rsvp between the current user and the specified event that the user has not rsvp'd for yet
| Parameter | Type | Description | Notes |
|---|---|---|---|
id |
ID |
id of the event to rsvp for |
required |
Returns the rsvp as a rsvp object with the attending key
set to true if successful, and returns an errors object otherwise.
Deletes a RSVP between the current user and the specified event that the user has RSVP'd for previously
| Parameter | Type | Description | Notes |
|---|---|---|---|
id |
ID |
id of the event to delete rsvp |
required |
Returns the rsvp as a rsvp object with the attending
key set to false if successful, and returns an errors object otherwise.
Endpoints for the Comments resource:
-
Create a Comment for an Event -
POST /api/events/:id/comments -
Remove Comment for an Event -
DELETE /api/events/:id/comments -
Edit a Comment for an Event -
PUT /api/events/:id/comments
Creates a comment from the current user on the specified event
| Parameter | Type | Description | Notes |
|---|---|---|---|
id |
ID |
id of the event to comment on |
required |
Returns the comment as a comment object, and returns an errors object otherwise.
Deletes a Comment from the current user on the specified event
| Parameter | Type | Description | Notes |
|---|---|---|---|
id |
ID |
id of the event to delete comment from |
required |
Returns a success message.
{
"id": 1,
"username": "zagreus",
"email": "zagreus@codezvous-app.com"
}{
"id": 1,
"username": "zagreus",
"email": "zagreus@codezvous-app.com"
}{
"message": "success"
}{
"message": "User logged out"
}{
"errors": "errors message here"
}{
"id": 41,
"group_name": "Super Duper Javascript Group of Austin",
"description": "We are passionate about Javascript and coming together as a group!",
"city": "Austin",
"state": "TX",
"zip_code": 78704,
"is_active": "active",
"image_url": "https://picsum.photos/id/{img_num}/600/337",
"leader_id": 1,
"createdAt": "2020-10-18T20:26:34.256Z",
"updatedAt": "2020-10-18T20:26:34.256Z",
}{
"id": 23,
"event_name": "Showing of The Social Network",
"description": "Come join us to watch The Social Network starring Jesse Eisenberg depicting Mark Zuckerberg and the triumphs and trials of starting Facebook",
"address": "275 Easton Town Center",
"city": "Austin",
"state": "TX",
"zip_code": 78704,
"group_id": 41,
"type": "Workshop",
"start_time": "2021-04-12 12:05:00",
"end_time": "2021-04-12 14:50:00",
"createdAt": "2020-10-18T20:26:34.256Z",
"updatedAt": "2020-10-18T20:26:34.256Z",
}{
"id": 17,
"user_id": 41,
"event_id": 23,
"createdAt": "2020-10-18T20:26:34.256Z",
"updatedAt": "2020-10-18T20:26:34.256Z",
}{
"id": 87,
"user_id": 41,
"event_id": 23,
"description": "My favorite movie! Can't wait to meetup with everyone again.",
"createdAt": "2020-10-18T20:26:34.256Z",
"updatedAt": "2020-10-18T20:26:34.256Z",
}