Skip to content

Latest commit

 

History

History
281 lines (176 loc) · 10.3 KB

api.md

File metadata and controls

281 lines (176 loc) · 10.3 KB

RESTless API Docs

Fetch Quotes and Authors

Fetch Quote

GET /api/fetch/quote/
Parameters

None

Responses
http code content-type response
200 application/json JSON
Example cURL
 curl "https://resttless.vercel.app/api/fetch/quote/?format=json"

Fetch Author by Name or ID

GET /api/fetch/author/{author name or id}
Parameters
name type data type description
name or id required string / int Author's name or ID
Responses
http code content-type response
200 application/json JSON
Example cURL
For name
 curl "https://resttless.vercel.app/api/fetch/author/?name=Thomas+Edison&format=json"

For ID

 curl "https://resttless.vercel.app/api/fetch/author/?id=5&format=json"

Fetch all Authors

GET /api/fetch/author
Parameters

None

Responses
http code content-type response
200 application/json JSON
Example cURL
 curl "https://resttless.vercel.app/api/fetch/author/all/?format=json"

Create Quotes and Authors

Create Author

POST /api/create/author/
Parameters

None

Headers
name type data type description
Authorization required Pass the authorization token, get it from here
Data
name type data type description
name required JSON Specify the name of the author to be created
Responses
http code content-type response
201 application/json {id: [author_id], name: [author_name]}
405 application/json {'detail': 'Method "<method_name>" not allowed.'}
Example cURL
 curl -X POST -H "Authorization: Token < your_auth_token >" -H "Content-Type: application/json" -d '{"name" : "Lucas"}' "https://resttless.vercel.app/api/create/author/"

Create Quote

POST /api/create/quote/
Parameters

None

Headers
name type data type description
Authorization required Pass the authorization token, get it from here
Data
name type data type description
name required JSON Specify the name of the author
quote required JSON Quote to post
author_id required JSON ID of author
Responses
http code content-type response
201 application/json {'quote': '<quote>', 'author_id': <author id>, 'author': {'id': <author id>, 'name': '<author name>'}}
405 application/json {'detail': 'Method "<method_name>" not allowed.'}
Example cURL
 curl -X POST -H "Authorization: Token < your_auth_token >" -H "Content-Type: application/json" -d "{'quote': 'doing from client', 'author_id': 14, 'author': {'id': 14, 'name': 'unknown'}}" "https://resttless.vercel.app/api/create/quote/"

Update Author

Update Author

PUT /api/update/author/
Parameters
name type data type description
id required int Author's ID
Headers
name type data type description
Authorization required Pass the authorization token, get it from here
Data
name type data type description
name required JSON New name of Author
Responses
http code content-type response
200 application/json {'message':'author updated'}
405 application/json {'detail': 'Method "<method_name>" not allowed.'}
Example cURL
 curl -X PUT -H "Authorization: Token < your_auth_token >" -H "Content-Type: application/json" -d '{"name" : "Lucas"}' "https://resttless.vercel.app/api/update/author/100"

Delete Quote and Author

Delete Author

DELETE /api/delete/author/
Parameters
name type data type description
id required int Author's ID
Headers
name type data type description
Authorization required Pass the authorization token, get it from here
Data

None

Responses
http code content-type response
200 application/json {'message':'author deleted'}
405 application/json {'detail': 'Method "<method_name>" not allowed.'}
Example cURL
 curl -X DELETE -H "Authorization: Token < your_auth_token >" "https://resttless.vercel.app/api/delete/author/100"

Delete Quote

DELETE /api/delete/quote/
Parameters
name type data type description
id required int Quote ID
Headers
name type data type description
Authorization required Pass the authorization token, get it from here
Data

None

Responses
http code content-type response
200 application/json {'message':'Quote Deleted'}
405 application/json {'detail': 'Method "<method_name>" not allowed.'}
Example cURL
 curl -X DELETE -H "Authorization: Token < your_auth_token >" "https://resttless.vercel.app/api/delete/quote/120"