HTTP Verb | Endpoint | Description |
---|---|---|
GET | /questions | Get all questions |
POST | /questions/ | Create a new question |
GET | /questions/:id | Get a single question |
PATCH | /questions/:id/ | Modify a question |
DELETE | /questions/:id/ | Delete a question |
GET | /search/questions | Find questions with keyword or phrase in title |
GET | /filter/questions | Filter questions by tag name |
Return a list of all questions from newest to oldest
/questions
GET https://developer-mental-health-org.herokuapp.com/api/v1/questions
STATUS: 200 OK
[
{
"id": 2,
"title": "Need Help",
"body": "Questions about anxiety",
"user": null,
"response_count": 3,
"tagging": [],
"upvotes": 1,
"downvotes": 0,
"created_at": "2021-10-21T21:20:57.757299Z",
"updated_at": "2021-10-21T21:20:57.757318Z"
},
{
"id": 3,
"title": "Some sort of title",
"body": "Some body of information",
"user": {
"username": "antonio",
"title": null
},
"response_count": 0,
"tagging": [
"First Tag",
"Second Tag"
],
"upvotes": 1,
"downvotes": 0,
"created_at": "2021-10-22T00:24:35.360530Z",
"updated_at": "2021-10-22T00:24:35.360572Z"
},
...
]
Add a new question to the list
/questions/
Parameter | Data Type | Required (Y/N) | Default | Notes |
---|---|---|---|---|
title | String | Yes | ||
tags | String | Yes | [ ] | value can be blank |
body | String | No | Empty string | |
upvotes | Integer | No | 0 | |
downvotes | Integer | No | 0 | |
user | String/Integer | No | Null | specify user id |
POST https://developer-mental-health-org.herokuapp.com/api/v1/questions/
STATUS: 201 Created
Return a single question and its attributes
/questions/:id
GET https://developer-mental-health-org.herokuapp.com/api/v1/questions/3
STATUS: 200 OK
{
"id": 3,
"title": "Some sort of title",
"body": "Some body of information",
"user": {
"username": "antonio",
"title": null
},
"tagging": [
"First Tag",
"Second Tag"
],
"responses": [
{
"body": "Sample comment.",
"user": {
"username": "antonio",
"title": null
},
"upvote": 0,
"downvote": 1,
"created_at": "2021-10-23T16:11:05.096515Z"
},
{
"body": "sdfadsgsdfghsdfg",
"user": null,
"upvote": 0,
"downvote": 1,
"created_at": "2021-10-24T20:09:10.397386Z"
}
],
"upvotes": 1,
"downvotes": 0,
"created_at": "2021-10-22T00:24:35.360530Z",
"updated_at": "2021-10-22T00:24:35.360572Z"
}
Modify an existing question
/questions/:id/
Parameter | Data Type | Notes |
---|---|---|
title | String | |
body | String |
PATCH https://developer-mental-health-org.herokuapp.com/api/v1/questions/3/
STATUS: 200 OK
Delete an existing question
/questions/:id/
DELETE https://developer-mental-health-org.herokuapp.com/api/v1/questions/3/
STATUS: 204 No Content
Returns a list of questions with titles that contain the specified keyword or phrase
/search/questions
Parameter | Value | Notes |
---|---|---|
search | keyword or phrase | case insensitive |
GET https://developer-mental-health-org.herokuapp.com/api/v1/search/questions?search=need
STATUS: 200 OK
[
{
"id": 2,
"title": "Need Help",
"body": "Questions about anxiety",
"user": null,
"response_count": 3,
"tagging": [],
"upvotes": 1,
"downvotes": 0,
"created_at": "2021-10-21T21:20:57.757299Z",
"updated_at": "2021-10-21T21:20:57.757318Z"
}
]
Returns a list of questions associated with the specified tag
/filter/questions
Parameter | Value | Notes |
---|---|---|
tags | Exact | case sensitive |
GET https://developer-mental-health-org.herokuapp.com/api/v1/search/questions?search=First_Tag
STATUS: 200 OK
[
{
"id": 3,
"title": "Some sort of title",
"body": "Some body of information",
"user": {
"username": "antonio",
"title": null
},
"response_count": 0,
"tagging": [
"First Tag",
"Second Tag"
],
"upvotes": 1,
"downvotes": 0,
"created_at": "2021-10-22T00:24:35.360530Z",
"updated_at": "2021-10-22T00:24:35.360572Z"
}
]