API Doc - HindsightTwentyTwenty/backend GitHub Wiki

Create Account

When creating a new account, make a post request to '/users/' with the following JSON:

{"email": "[email protected]","password": "hindsite","first_name": "Zach","last_name": "Tannenbaum","confirm_password": "hindsite"}

The response if successful will be a 200 with the following JSON:

{"token": "55537b678958d82cb20c451d39cb31bc599495f5"}

Change password

To change password, make a post request to '/change/' with the following JSON:

{"email": "[email protected]","current_pw": "hindsite", "new_pw": "twentytwenty"}

Forgot Password

When you want to send to the forgot password endpoint, make a post request to '/forgot/' with the following JSON:

{"email":"[email protected]"}

Get User Info

When you want to get user info, make a get request to '/userinfo/'.

Tracking On/Off

When you want to turn tracking on or off, make a post request to '/tracking/' with the following JSON (true=on/false=off):

{"tracking":[true/false]}

Search

When doing a basic search, make a post request to '/search/' with the following JSON:

{"query":[string of search terms], "start_time":[see note below on times], "end_time":[see note below on times], "category": [category title], "order":[choices are "relevance" or "date" currently]}

For the times, if "Anytime" is selected send start_time as "now-24M" and end_time as "now"; if "past hour" send "now-1h" and "now"; if "past 24hours" send "now-24h" and "now"; if "past week" send "now-7d" and "now"; if "past month" send "now-1M" and "now"; if "past year" send "now-12M" and "now"; if "custom range" send "2017-01-30T04:30:00" and "2017-01-30T04:45:00"

Add Page

When a page changes or a new tab is created make a post request to '/newpage/' with the following JSON:

{"tab":[integer tab id], "title":"[page title]", "domain":"[domain title]", "url":"[full url]", "favIconUrl": [favicon url], "previousTabId": [integer tab id], "active": [true/false]}

Close Tab

When a tab is closed, make a post request to '/closetab/' with the following JSON:

{"tab":[integer tab id]}

Active Changed

When active tab changes, make a post request to '/active/' with the following JSON:

{"tab":[integer tab id], "closed": [true/false]}

Get Info for Popup

When you want the popup info, make a post request to '/popupinfo/' with the following JSON:

{"url": [full url]}

Get Tabs by Time Range

When you want to get all tabs/domains for a given time range, make a post request to '/tabinfo/' with the following JSON:

{"start": "2016-11-5T12:50:40.466Z", "end": "2016-11-5T16:50:40.466Z"}

Get Domain Info

When you want to get a specific domain's information (ie when clicking on a domain in lookback view), make a post request to '/domaininfo/' with the following JSON:

{"pk": [domain's primary key, under 'pk']}

Get all Categories and their Pages

When you want to get all categories and pages, make a GET request to '/getcategories/'

Add Category To Page

When you want to add a category to a page make a post request to '/addcategorypage/' with the following JSON:

{"url":"[full url]", "title": "[if from popup, always send page title too]", "category":"[category title]", "color": [optional, should be of format "#01AB55"]}

Delete Category From Page

When you want to delete a category from a page, make a post request to '/deletecategorypage/' with the following JSON:

{"url":"[full url]", "pk":[pk]}

Change Star/Unstar

When you want to update the star attribute on a page, make a post request to '/updatestar/' with the following JSON:

{"url":"[full url]", "title": "[if on popup always send the title too]", "star":[true/false]}

Add Category

When you want to add a category, make a post request to '/addcategory/' with the following JSON:

{"category":"[category title]", "color": [optional, should be of format "#01AB55"]}

Delete Category

When you want to delete a category, make a post request to '/deletecategory/' with the following JSON:

{"pk": [pk]}

Edit Category

When you want to edit a category, make a post request to '/editcategory/' with the following JSON:

{"pk": [pk], "updated": "[new category title]", "color": [optional, should be of format "#01AB55"]}

Add Blacklist

When you want to add a blacklist, make a post request to '/addblacklist/' with the following JSON:

{"blacklist":"[domain, must start 'http://' or 'https://']"}

Delete Blacklist

When you want to delete a blacklist, make a post request to '/deleteblacklist/' with the following JSON:

{"pk": [blacklist pk]}

Edit blacklist

When you want to edit a blacklist, make a post request to '/editblacklist/' with the following JSON:

{"pk":[blacklist pk], "blacklist": "[updated domain, must start 'http://' or 'https://']"}

Get all blacklists

When you want to get all of the blacklisted pages, make a get request to '/blacklists/'

Add Session

When you want to add a Session, make a post request to '/addsession/' with the following JSON:

{"title":"[name of session]", "start": "2017-02-06T00:35:11.576325Z", "end": [optional, same format as start]}

Delete Session

When you want to delete a Session, make a post request to '/deletesession/' with the following JSON:

{"pk": [session pk]}

Edit Session

When you want to edit a session, make a post request to '/editsession/' with the following JSON:

{"pk":[session pk], "title": "[updated title]"}

Get all sessions

When you want to get all of the sessions, make a get request to '/sessions/'

End Current Session

If you want to end the current session, make a get request to '/endsession/'