Skip to content

Commit d44256f

Browse files
committed
TOC (2)
1 parent 5772a55 commit d44256f

File tree

1 file changed

+45
-48
lines changed

1 file changed

+45
-48
lines changed

README.md

Lines changed: 45 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -7,32 +7,30 @@ A 21th century specification proposal for Rest API's
77

88
---------------
99

10-
#### This specification is intended to establish an agreement on the behavior of an API, no matters the format (json, xml, etc...).
11-
12-
13-
- 1. Design
14-
- 2. Formatting
15-
- 3. Security
16-
- 4. Verbs
17-
- Fallback header
18-
- Location header
19-
- Resource on update and create actions
20-
- 5. Status codes
21-
- 6. Errors
22-
- 7. Parameters
23-
- 8. Custom HTTP headers
24-
- 9. Versioning
25-
- 10. Pagination
26-
- 11. Filtering
27-
- 12. Sorting
28-
- 13. Searching
29-
- 14. Embedding
30-
- 15. Selecting
31-
- 16. Caching
32-
- 17. Asynchronous processing
33-
- Sources
34-
35-
### 1. Design
10+
### This specification is intended to establish an agreement on the behavior of an API, no matters the format (json, xml, etc...).
11+
12+
## Table of contents
13+
14+
1. [Design](#1-design)
15+
2. [Formatting](#2-formatting)
16+
3. [Security](#3-security)
17+
4. [Verbs](#4-verbs)
18+
5. [Status codes](#5-status-codes)
19+
6. [Errors](#6-errors)
20+
7. [Parameters](#7-parameters)
21+
8. [Custom HTTP headers](#8-custom-http-headers)
22+
9. [Versioning](#9-versioning)
23+
10. [Pagination](#10-pagination)
24+
11. [Filtering](#11-filtering)
25+
12. [Sorting](#12-sorting)
26+
13. [Searching](#13-searching)
27+
14. [Embedding](#14-embedding)
28+
15. [Selecting](#15-selecting)
29+
16. [Caching](#16-caching)
30+
17. [Asynchronous processing](#17-asynchronous-processing)
31+
[Sources](#sources)
32+
33+
## 1. Design
3634

3735
The API must embrace RESTful design principles. It must be resource-based, and each resource representation must contain enough information to modify or delete the resource on the server, provided it has permission to do so.
3836

@@ -48,20 +46,19 @@ The API must embrace RESTful design principles. It must be resource-based, and e
4846

4947
> You don't want to deal with complex pluralization (e.g., foot/feet, child/children, people/people). Keep it simple.
5048
51-
### 2. Formatting
49+
## 2. Formatting
5250

5351
- Dates must be returned in ISO 8601 format (YYYY-MM-DDTHH:MM:SSZ).
54-
- Geographic coordinates must be returned in `[-]d.d, [-]d.d` format (e.g., 12.3456, -98.7654).
5552

56-
> TODO: more ?
53+
- Geographic coordinates must be returned in `[-]d.d, [-]d.d` format (e.g., 12.3456, -98.7654).
5754

58-
### 3. Security
55+
## 3. Security
5956

6057
- The API must be served over SSL, using `https`. It must not redirect on non-SSL urls.
6158

6259
> Always using SSL guaranteed encrypted communications, and allow use of simple access tokens.
6360
64-
### 4. Verbs
61+
## 4. Verbs
6562

6663
| Verb | Description |
6764
|--------------|-------------------------------------------------------|
@@ -70,21 +67,21 @@ The API must embrace RESTful design principles. It must be resource-based, and e
7067
| PATCH / PUT | Used for updating resources. |
7168
| DELETE | Used for deleting resources. |
7269

73-
#### Fallback header
70+
### Fallback header
7471

7572
The HTTP client that doesn't support PUT, PATCH or DELETE requests must send a POST request with an `X-HTTP-Method-Override` header specifying the desired verb.
7673

7774
The server must correctly handle this header. When it is set, it take precedence over the original request method.
7875

79-
#### Location header
76+
### Location header
8077

8178
When a resource is created (with a `POST` request), the response must contain a `Location` header with the link of the new resource.
8279

83-
#### Resource on update and create actions
80+
### Resource on update and create actions
8481

8582
When a resource is created or modified (e.g., with a POST, PUT or PATCH request), the response must contain the created or updated respresentation of the resource.
8683

87-
### 5. Status codes
84+
## 5. Status codes
8885

8986
**The API must uses descriptive HTTP response codes to indicate the success or failure of request.**
9087

@@ -113,7 +110,7 @@ The server must respond with the following status codes, according to the situat
113110
| 503 Service Unavailable | The server is currently unable to handle the request. |
114111

115112

116-
### 6. Errors
113+
## 6. Errors
117114

118115
- All errors in the 4xx must return a body containing a `error` key, containing the error code.
119116

@@ -154,7 +151,7 @@ Content-Type: application/json
154151
```
155152

156153

157-
### 7. Parameters
154+
## 7. Parameters
158155

159156
Resource creation or update parameters must be wrapped in an object as the singular name of the resource.
160157

@@ -186,13 +183,13 @@ Content-Type: application/json
186183
```
187184

188185

189-
### 8. Custom HTTP headers
186+
## 8. Custom HTTP headers
190187

191188
All non-standard HTTP headers must begin by a `X-`.
192189

193190
For example, for rate limiting, the `X-Rate-Limit-Limit`, `X-Rate-Limit-Remaining` and `X-Rate-Limit-Reset` headers should be used.
194191

195-
### 9. Versioning
192+
## 9. Versioning
196193

197194
The API must be versioned, and must not have breaking changes whitout version change.
198195

@@ -221,7 +218,7 @@ X-Version: 3.1
221218
}
222219
```
223220

224-
### 10. Pagination
221+
## 10. Pagination
225222

226223
Requests for collections should be paginated, and return a limited number of results.
227224

@@ -266,7 +263,7 @@ X-Total: 4
266263
]
267264
```
268265

269-
### 11. Filtering
266+
## 11. Filtering
270267

271268
The client should be able to filter resource collections using the `filter` parameter. In this case, only the fields matching the given filter(s) will be returned.
272269

@@ -293,7 +290,7 @@ Content-Type: application/json
293290
```
294291

295292

296-
### 12. Sorting
293+
## 12. Sorting
297294

298295
The client should be able to sort resource collections according to one or more fields using the `sort` parameter. The value for `sort` must represent sort fields.
299296

@@ -339,7 +336,7 @@ Content-Type: application/json
339336

340337
If the server does not support sorting as specified in the query parameter `sort`, it must return a `400 Bad Request` status code.
341338

342-
### 13. Searching
339+
## 13. Searching
343340

344341
The client should be able to search on resource collections fields using the `search` parameter. In this case, only the fields matching the given search(s) will be returned.
345342

@@ -377,7 +374,7 @@ Content-Type: application/json
377374

378375
A global search on a resource collection should be implemented using directly a value instead of a hash for the `search` parameter.
379376

380-
### 14. Embedding
377+
## 14. Embedding
381378

382379
The client should be able to include data related to (or referenced) from the resource being requested using the `embed` parameter. The value of the `embed` parameter must be a comma separated list of fields to be embedded. Dot-notation must be used to refer to sub-fields.
383380

@@ -429,7 +426,7 @@ Content-Type: application/json
429426
]
430427
```
431428

432-
### 15. Selecting
429+
## 15. Selecting
433430

434431
The client should be able to select only specific fields in the response using the `fields` parameter. In this case, only the requested fields will be returned.
435432

@@ -466,11 +463,11 @@ Content-Type: application/json
466463
If the server does not support selection as specified in the query parameter `fields`, it must return a `400 Bad Request` status code.
467464

468465

469-
### 16. Caching
466+
## 16. Caching
470467

471468
Server should generate a [ETag header](http://en.wikipedia.org/wiki/HTTP_ETag) containing a hash or checksum of the representation. This value should change whenever the output representation changes.
472469

473-
### 17. Asynchronous processing
470+
## 17. Asynchronous processing
474471

475472
When a resource creation or update is asynchronously processed, the request should return a `202 Accepted` status code with a link in the `Content-Location` header which should redirect to the resource when the job processing is done.
476473

@@ -506,7 +503,7 @@ Content-Type: application/json
506503
Location: https://api.example.com/movies/3
507504
```
508505

509-
### Sources
506+
## Sources
510507

511508
- [Nouns are good, verbs are bad](http://apigee.com/about/blog/technology/restful-api-design-nouns-are-good-verbs-are-bad)
512509
- [Principles of good RESTful API Design](https://codeplanet.io/principles-good-restful-api-design/)

0 commit comments

Comments
 (0)