This is an application that lets you query both Reddit and Twitter and access the results. The url for the site is https://426garbageaggregator.azurewebsites.net/.
Posts have the following properties:
attribute | type | description
-----------------------------------------------------------
sourceURL | string | The url of the post.
query | string | The search query used to find this.
text | string | The title of the post (if from Reddit) or the tweet text, if there is any.
score | int | The score of the post (reddit upvotes, likes + retweets on twitter).
date | long | The date of the post in UNIX time.
author | string | The person who posted this.
sourceSite | string | One of "reddit" or "twitter".
subreddit | string | The subreddit, if from reddit. Otherwise is an empty string.
postType | string | One of "text" or "other".
previewMediaURL | string | If media is found in the post, this is the URL of the first one found. Could be a link, or an image.
Preference objects have these properties:
attribute | type | description
-----------------------------------------------------------
id | id | The id of the associated user. This is set to (-1) unless the login endpoint is used.
sortPref | string | The sort preference of the associated user ("score" or "new").
typePref | string | The type preference of the associated user ("text","other", or "all").
sitePref | string | The site preference of the associated user ("reddit", "twitter", or "both").
reversePref | bool | The reverse preference of the associated user (true or false).
Endpoint: GET https://garbageapiprototype.azurewebsites.net/api/Posts
Parameters:
- query (string) - Optional. The keyword to search for. Defaults to "cats".
- limit (int) - Optional. The number of posts to return. Defaults to 10.
- type (string) - Optional. Must be one of "text", "other" or "all". Determines what kind of posts to return (if something contains anything other than text, it becomes "other"). Defaults to "all".
- site (string) - Optional. Must be one of "reddit", "twitter", or "both". Determines what site to get posts from. Defaults to "both".
- reverse (boolean) - Optional. Reverses the output if true. Defaults to false.
Response: Responds with an array of Post objects.
Example Axios Request:
axios.get('https://garbageapiprototype.azurewebsites.net/api/Posts?query=' + query+ "&limit=30&site=" + user.sites+ "&type=" + user.content + "&sort="+ user.sortBy + "&reverse=" + user.sort)Example Response:
[{"sourceURL":"https://reddit.com/r/aww/comments/ckbolc/this_is_tiger_he_just_turned_31_we_are_told_he_is/","query":"cats","text":"This is Tiger. He just turned 31. We are told he is the oldest cat in the state of Illinois","score":181060,"date":1564594564,"author":"Aritilli","sourceSite":"reddit","subreddit":"r/aww","postType":"other","previewMediaURL":"https://i.redd.it/sg3q5cuedod31.jpg"}, ... ]
Endpoint: GET https://garbageapiprototype.azurewebsites.net/api/ApplicationUsers/:id
Response: Responds with the preferences of the user with this id. Returns null if you are not logged in as this user.
Example Axios Request:
axios.get('https://garbageapiprototype.azurewebsites.net/api/ApplicationUsers/33')Example Response:
{
"sortPref": "new",
"typePref": "image",
"sitePref": "reddit",
"reversePref": false,
"id": -1
}
Endpoint: POST https://garbageapiprototype.azurewebsites.net/api/ApplicationUsers/login
Parameters:
- username (string) - Your username.
- password (string) - Your password.
Response: Responds with the preferences of this user, if the username and password combination is correct. Otherwise, returns null.
Example Axios Request:
axios.post("https://garbageapiprototype.azurewebsites.net/api/ApplicationUsers/login", {username: name, password: password} )Example Response:
{
"sortPref": "new",
"typePref": "image",
"sitePref": "reddit",
"reversePref": false,
"id": 33
}
Endpoint: POST https://garbageapiprototype.azurewebsites.net/api/ApplicationUsers/register
Parameters:
- username (string) - Your username.
- password (string) - Your password.
- sortPref (string) - Sorting preferences (see Preference object above).
- typePref (string) - Type preferences.
- sitePref (string) - Site preferences.
- reversePref (bool) - Reverse preference.
Response: Responds with a default Preferences object.
Example Axios Request:
axios({
method: "post",
url: "https://garbageapiprototype.azurewebsites.net/api/ApplicationUsers/register" ,
data: {
username: name,
password: pass,
sortPref: "score",
typePref: "all",
sitePref: "both",
reversePref: false
}
})Example Response:
{
"sortPref": "score",
"typePref": "all",
"sitePref": "both",
"reversePref": false,
"id": -1
}
Endpoint: PUT https://garbageapiprototype.azurewebsites.net/api/ApplicationUsers/:id
Changes the preference of this user, based on their id. Returns a bad request if you are not currently logged in with this id. Otherwise, returns null.
Parameters:
- username (string) - Your username.
- password (string) - Your password.
- sortPref (string) - Sorting preferences (see Preference object above).
- typePref (string) - Type preferences.
- sitePref (string) - Site preferences.
- reversePref (bool) - Reverse preference.
Example Axios Request:
axios({
method: "put",
url: "https://garbageapiprototype.azurewebsites.net/api/ApplicationUsers/"+user.id,
data: {
"username": user.name,
"password": user.pass,
"sortPref": sortBy,
"typePref": content,
"sitePref": sites,
"reversePref": sort
}
})Example Response: nothing
Note: This endpoint is not used in the application.
Endpoint: DELETE https://garbageapiprototype.azurewebsites.net/api/ApplicationUsers/:id
Parameters:
- username (string) - Your username.
- password (string) - Your password.
- sortPref (string) - Sorting preferences (see Preference object above).
- typePref (string) - Type preferences.
- sitePref (string) - Site preferences.
- reversePref (bool) - Reverse preference.
This fails and returns a 401 if you are not logged in as this user.
Example Axios Request:
axios({
method: "delete",
url: "https://garbageapiprototype.azurewebsites.net/api/ApplicationUsers/"+user.id,
data: {
username: name,
password: pass,
sortPref: "score",
typePref: "all",
sitePref: "both",
reversePref: false
}
})Example Response:
{
"id": 33,
"username": "poopfeast421",
"password": "$MYHASH$V1$10000$3AE6E2183iKHqpPjnGWGNpOKaSAUHCx8mItqa+2MfjfJa1hn",
"sortPref": "new",
"typePref": "image",
"sitePref": "reddit",
"reversePref": false
}