Skip to content

Api Documentation

Demeatrice J. Sherrod edited this page Sep 14, 2023 · 2 revisions

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:


Users

Endpoints for the Users resource:


Log In

Logs an existing user into the application

POST /api/auth/login

Body Parameters

Parameter Type Description Notes
email string email of the user logging in required
password string password of the user logging in required

Returns

Returns a current user object if successful and sets an HTTP-only auth cookie, and returns an errors object otherwise.


Sign Up

Creates a new user and logs them into the application

POST /api/auth/signup

Body Parameters

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

Returns a current user object if successful and sets an HTTP-only auth cookie, and returns an errors object otherwise.


Log Out

Logs out the current user

GET /api/auth/logout

Returns

Returns a logged out message.


Authenticate

Authenticates a user

GET /api/auth/

Path Parameters

Parameter Type Description Notes
id ID id of the user required

Returns

Returns a current user object if successful, and returns an errors object otherwise.


Unauthorized

Returns unauthorized JSON when flask-login authentication fails

GET /api/auth/unauthorized

Returns

Returns an errors object.


Retrieve All Users

Returns all users stored in the database.

GET /api/users

Returns

Returns an array of user objects.


Retrieve Single User

Returns user specified by id provided in URL

GET /api/users/:id

Path Parameters

Parameter Type Description Notes
id ID id of the user required

Returns

Returns a user object.


Retrieve User Groups

Returns groups specified by user id provided in URL

GET /api/users/:id/groups

Path Parameters

Parameter Type Description Notes
id ID id of the user required

Returns

Returns an array of group objects.


Retrieve User Events

Returns events specified by user id provided in URL

GET /api/users/:id/events

Path Parameters

Parameter Type Description Notes
id ID id of the user required

Returns

Returns an array of event objects.


Retrieve User RSVPs

Returns rsvps specified by user id provided in URL

GET /api/users/:id/rsvps

Path Parameters

Parameter Type Description Notes
id ID id of the user required

Returns

Returns an array of event objects.


Groups

Endpoints for the Groups resource:


Retrieve All Groups

Retrieves all the groups

GET /api/groups

Returns

Returns an array of group objects if successful, and returns an errors object otherwise


Retrieve a Single Group

Retrieves a single group with the specified id

GET /api/groups/:id

Path Parameters

Parameter Type Description Notes
id ID id of the group to retrieve required

Returns

Returns a group object if successful, and returns an errors object otherwise.


Retrieve all Events for a Single Group

Retrieves an array of all Events associated with a group with the specified id

GET /api/groups/:id/events

Path Parameters

Parameter Type Description Notes
id ID id of the group to retrieve required

Returns

Returns an array of event objects if successful, and returns an errors object otherwise


Retrieve the leader for a Single Group

Retrieves a user object with the user who owns the group with the specified id

GET /api/groups/:id/leader

Path Parameters

Parameter Type Description Notes
id ID id of the group to retrieve required

Returns

Returns a user objects if successful, and returns an errors object otherwise


Retrieve all Members for a Single Group

Retrieves an array of all Members associated with a group with the specified id

GET /api/groups/:id/members

Path Parameters

Parameter Type Description Notes
id ID id of the group to retrieve required

Returns

Returns an array of user objects if successful, and returns an errors object otherwise


Create a Group

Creates a new group

POST /api/groups

Body Parameters

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

Returns the created group object if successful, and returns an errors object otherwise.


Edit a Group

Edits an existing group of that the current user is the leader of, **requires authentication with a cookie**

PUT /api/groups/:id

Path Parameters

Parameter Type Description Notes
id ID id of the group to edit required

Body Parameters

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

Returns the edited group object if successful, and returns an errors object otherwise.


Delete a Group

Deletes an existing group of that the current user is the leader of, **requires authentication with a cookie**

DELETE /api/groups/:id

Path Parameters

Parameter Type Description Notes
id ID id of the group to edit required

Returns

Returns a success message if successful, and returns an errors object otherwise.


Events

Endpoints for the Events resource:


Retrieve All Events

Retrieves all the events

GET /api/events

Returns

Returns an array of event objects if successful, and returns an errors object otherwise


Retrieve a Single Event

Retrieves a single event with the specified id

GET /api/events/:id

Path Parameters

Parameter Type Description Notes
id ID id of the event to retrieve required

Returns

Returns an event object if successful, and returns an errors object otherwise.


Create an Event

Create a new event

POST /api/events

Body Parameters

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

Returns the created event object if successful, and returns an errors object otherwise.


Edit an Event

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**

PUT /api/events/:id

Path Parameters

Parameter Type Description Notes
id ID id of the event to edit required

Body Parameters

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

Returns the edited event object if successful, and returns an errors object otherwise.


Delete an Event

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**

DELETE /api/events/:id

Path Parameters

Parameter Type Description Notes
id ID id of the event to delete required

Returns

Returns a success message if successful, and returns an errors object otherwise.


RSVPs

Endpoints for the RSVPs resource:


Retrieve all users attending an event

Returns rsvps for all users attending an event

GET /api/events/:id/attendees

Returns

Returns an array of rsvp objects if successful, and returns an errors object otherwise.


RSVP for an Event

Creates an rsvp between the current user and the specified event that the user has not rsvp'd for yet

POST /api/events/:id/rsvps

Path Parameters

Parameter Type Description Notes
id ID id of the event to rsvp for required

Returns

Returns the rsvp as a rsvp object with the attending key set to true if successful, and returns an errors object otherwise.


Remove RSVP from an Event

Deletes a RSVP between the current user and the specified event that the user has RSVP'd for previously

DELETE /api/events/:id/rsvps

Path Parameters

Parameter Type Description Notes
id ID id of the event to delete rsvp required

Returns

Returns the rsvp as a rsvp object with the attending key set to false if successful, and returns an errors object otherwise.


Comments

Endpoints for the Comments resource:


Comment on an Event

Creates a comment from the current user on the specified event

POST /api/events/:id/comments

Path Parameters

Parameter Type Description Notes
id ID id of the event to comment on required

Returns

Returns the comment as a comment object, and returns an errors object otherwise.


Remove Comment from an Event

Deletes a Comment from the current user on the specified event

DELETE /api/events/:id/comments

Path Parameters

Parameter Type Description Notes
id ID id of the event to delete comment from required

Returns

Returns a success message.


Objects

Current User Object

{
  "id": 1,
  "username": "zagreus",
  "email": "zagreus@codezvous-app.com"
}

User Object

{
  "id": 1,
  "username": "zagreus",
  "email": "zagreus@codezvous-app.com"
}

Success Message

{
  "message": "success"
}

Logged Out Message

{
  "message": "User logged out"
}

Errors Object

{
  "errors": "errors message here"
}

Group Object

{
  "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",
}

Event Object

{
  "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",
}

RSVP Object

{
  "id": 17,
  "user_id": 41,
  "event_id": 23,
  "createdAt": "2020-10-18T20:26:34.256Z",
  "updatedAt": "2020-10-18T20:26:34.256Z",
}

Comment Object

{
  "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",
}

Clone this wiki locally