Skip to content

API Design

Justin Wilcox edited this page Apr 20, 2022 · 2 revisions

Register (POST)

API call: POST http://texttrader.com/api/register

Parameters: none

Examples of API calls: texttrader.com/api/register

Request body: {"username": “Juice”, "password":"178HiHouman!!!", "email":"justin.example@email.com"}

API respond: { “success”:true “msg”: “account created” }

LOGIN (POST)

API call: POST http://texttrader.com/api/login

Parameters: username – user’s username password – user’s password

Examples of API calls: texttrader.com/api/login

Request body: {"username": “Juice”, "password":"Password11!!”}

API respond: { “success”:true, “payload”: { "userid": 1, "username": “Juice”, "password": JSON Web Token here} }

POSTBOOK (POST)

API call: POST http://texttrader.com/api/post-book

Parameters: none

Examples of API calls: texttrader.com/api/post-book

Request body: {"title":value, "author":value, "ISBN":"value"}

API respond: { “success”: true, “payload”: { "book_id":17, "Title": “Coding for Dummies”, "Author": “Billy Smith”, "ISBN": “978190”, "owner_id": 3} }

DELETEBOOK (DELETE)

API call: DELETE http://texttrader.com/books/bookid?id={value}

Parameters: Bookid – the ID of the book

Examples of API calls: texttrader.com/books/bookid?id=1

API respond: {“success”: true}

GETALLBOOKS (GET)

API call: GET http://texttrader.com/api/books

Parameters: none

Examples of API calls: texttrader.com/api/books

API respond: [ {"book_id":17, "Title": “Coding for Dummies”, "Author": “Billy Smith”, "ISBN": “978190”, "owner_id": 3}, {"book_id":17, "Title": “Anthropology”, "Author": “Anne Davis”, "ISBN": “117357”, "owner_id": 1} ]

GETBOOK (GET)

API call: GET http://texttrader.com/api/books/title?title={value}

Parameters: title - the title of the book

Examples of API calls: texttrader.com/api/books/title?title=“anthropology”

Request body: {"title": “Anthropology”}

API respond: {"title": “Anthropology”, "author": “Anne Davis”, "ISBN": “117357”}

Clone this wiki locally