https://github.com/code4mk/rest-api-tips
rest api tips and guideline
https://github.com/code4mk/rest-api-tips
rest rest-api
Last synced: 3 months ago
JSON representation
rest api tips and guideline
- Host: GitHub
- URL: https://github.com/code4mk/rest-api-tips
- Owner: code4mk
- License: mit
- Created: 2021-03-10T10:11:46.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-04-14T08:57:15.000Z (over 4 years ago)
- Last Synced: 2025-03-02T07:18:06.828Z (10 months ago)
- Topics: rest, rest-api
- Size: 4.88 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# REST
REST means representational state transfer.
~ Separation of Client and Server.
`Statelessness:` Systems that follow the REST paradigm are stateless, meaning that the server does not need to know anything about what state the client is in and vice versa.
# API
Applaciation Programming Interface. API allows two systems to communicate with one another.
# key points
* resource
* collections
* endpoint
* response
* http status
# HTTP methods
* get - (retrieve data)
* post - (submit post)
* put - (replace all data)
* patch - (partially update data)
* delete - (delete data)
~ resource
* https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods
# Endpoint
endpoint will be noun and plural form . endpoint will not verb.
segment will be dash as /holiday-schedules
`{baseUrl}/v1/employees/holiday-schedules`
# Header
HTTP headers let the client and the server pass additional information with an HTTP request or response.
```js
Authorization: 'Bearer Token'
Content-Type: 'application/json'
Public-Key: ''
Secret-Key: ''
```
~ resources
* https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers
# Status code
## Success
* 200 (ok) - retrieve data
* 201 (created) - insert data
* 204 (no content) - delete data
## Cilent error
* 400 (bad request)
* 401 (unauthorize)
* 403 (forbidden)
* 404 (not found)
* 405 (method not found)
* 408 (request time out)
* 414 (request get uri so long)
* 429 (so many request)
## server error
* 500 (internal server error)
* 503 (service not available)
* https://httpstatuses.com/
# summarize
* endpoint (naming system,segment)
* http methods
* http status code
~ feature
* versioning
* filtering,pagination,sorting