-
Notifications
You must be signed in to change notification settings - Fork 0
API Documentation
The DejaView 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 Dreams -
GET /api/users/<int:id>/dreams -
Retrieve User Fragments -
GET /api/users/<int:id>/fragments
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 |
|---|---|---|---|
name |
string |
Desired name of the new user |
required |
email |
string |
Desired email of the new user |
required, unique |
password |
string |
Desired password 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 dreams specified by user id provided in URL
| Parameter | Type | Description | Notes |
|---|---|---|---|
id |
ID |
id of the user |
required |
Returns an array of dream objects.
Returns fragments specified by user id provided in URL
| Parameter | Type | Description | Notes |
|---|---|---|---|
id |
ID |
id of the user |
required |
Returns an array of fragment objects.
Endpoints for the Dreams resource:
-
Retrieve All Dreams -
GET /api/dreams -
Retrieve a Single Dream -
GET /api/dreams/:id -
Retrieve all fragments for a Single Dream -
GET /api/dreams/:id/fragments -
Retrieve the dreamer of a Single Dream -
GET /api/dreams/:id/dreamer -
Create a Dream -
POST /api/dreams -
Edit a Dream -
PUT /api/dreams/:id -
Delete a Dream -
DELETE /api/dreams/:id
Retrieves all the dreams
Returns an array of dream objects if successful, and returns an errors object otherwise
Retrieves a single dream with the specified id
| Parameter | Type | Description | Notes |
|---|---|---|---|
id |
ID |
id of the dream to retrieve |
required |
Returns a dream object if successful, and returns an errors object otherwise.
Retrieves all fragment objects within a dream with the specified id
| Parameter | Type | Description | Notes |
|---|---|---|---|
id |
ID |
id of the dream whose fragments are to be retrieved |
required |
Returns a fragment objects if successful, and returns an errors object otherwise
Creates a new dream
| Parameter | Type | Description | Notes |
|---|---|---|---|
title |
string |
title of the dream being created |
required |
keywords |
string |
keywords of the dream being created |
required |
notes |
text |
notes of the dream being created |
required |
created_at |
datetime |
date & time of the dream being created |
required |
updated_at |
datetime |
date & time of the dream being created |
required |
Returns the created dream object if successful, and returns an errors object otherwise.
Edits an existing dream that the current user is the dreamer of, **requires authentication with a cookie**
| Parameter | Type | Description | Notes |
|---|---|---|---|
id |
ID |
id of the dream to edit |
required |
| Parameter | Type | Description | Notes |
|---|---|---|---|
title |
string |
title of the dream being edited |
required |
keywords |
string |
keywords of the dream being created |
required |
notes |
text |
notes of the dream being edited |
required |
Returns the edited dream object if successful, and returns an errors object otherwise.
Deletes an existing dream the current user is the dreamer of, **requires authentication with a cookie**
| Parameter | Type | Description | Notes |
|---|---|---|---|
id |
ID |
id of the dream to edit |
required |
Returns a success message if successful, and returns an errors object otherwise.
Endpoints for the Fragments resource:
-
Fragments-
Retrieve All Fragments -
GET /api/fragments -
Retrieve a Single Fragment -
GET /api/fragments/:id -
Create a Fragment -
POST /api/fragments -
Edit a Fragment -
PUT /api/fragments/:id -
Delete a Fragment -
DELETE /api/fragments/:id
-
Retrieve All Fragments -
Retrieves all the fragments
Returns an array of fragment objects if successful, and returns an errors object otherwise
Retrieves a single fragment with the specified id
| Parameter | Type | Description | Notes |
|---|---|---|---|
id |
ID |
id of the fragment to retrieve |
required |
Returns an fragment object if successful, and returns an errors object otherwise.
Create a new event
| Parameter | Type | Description | Notes |
|---|---|---|---|
title |
string |
title of the fragment being created |
required |
emotions |
string |
emotions of the fragment being created |
required |
setting |
string |
setting of the fragment being created |
required |
description |
text |
description of the fragment being created |
required |
Returns the created fragment object if successful, and returns an errors object otherwise.
Edits an existing fragment that the current user is the user of, **requires authentication with a cookie**
| Parameter | Type | Description | Notes |
|---|---|---|---|
id |
ID |
id of the fragment to edit |
required |
| Parameter | Type | Description | Notes |
|---|---|---|---|
title |
string |
title of the fragment being created |
required |
emotions |
string |
emotions of the fragment being created |
required |
setting |
string |
setting of the fragment being created |
required |
description |
text |
description of the fragment being created |
required |
Returns the edited fragment object if successful, and returns an errors object otherwise.
Deletes an existing fragment of that the current user is the leader of the dream that is hosting the fragment, **requires authentication with a cookie**
| Parameter | Type | Description | Notes |
|---|---|---|---|
id |
ID |
id of the fragment to delete |
required |
Returns a success message if successful, and returns an errors object otherwise.
{
"id": 1,
"username": "Jimmy",
"email": "jimmy@dejaview.com"
}{
"id": 2,
"username": "Walker",
"email": "walker@dejaview.com"
}{
"message": "success"
}{
"message": "User logged out"
}{
"errors": "errors message here"
}{
"id": 41,
"title": "Jan30 Dream",
"keywords": "wonder",
"notes": "car, friend, convenience store, motorcycle, parking lot",
"user_id": 4,
"createdAt": "2020-10-18T20:26:34.256Z",
"updatedAt": "2020-10-18T20:26:34.256Z",
}{
"id": 23,
"title": "parking lot",
"emotions": "carefree",
"setting": "nighttime parking lot",
"description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras sed libero quam. In in porta sem, nec bibendum neque. Quisque nec turpis et libero condimentum tincidunt id eget risus. Aenean lacinia ex quis suscipit maximus. In consequat, arcu a mollis commodo, metus tellus dapibus felis, eu mattis ipsum elit a risus. Mauris tempor tincidunt ex et ullamcorper. Cras faucibus mauris vel dolor volutpat fringilla.",
"user_id": 1,
"createdAt": "2020-10-18T20:26:34.256Z",
"updatedAt": "2020-10-18T20:26:34.256Z",
}