Skip to content

Commit baab3dc

Browse files
authored
Merge pull request #54 from fhict-skilltree/53-document-rest-api-uuid-convention
feat(53): document rest api convention to use uuid instead of ID
2 parents 2fa990c + cc9001d commit baab3dc

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

docs/technical/rest-api.md

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
layout: default
3+
title: REST API
4+
nav_order: 5
5+
parent: REST API
6+
permalink: /docs/technical/rest-api
7+
---
8+
9+
# REST API
10+
11+
## Development conventions
12+
13+
### Use UUID for resource identifiers
14+
15+
Identifiers of resources that are exposed through the REST API must be the UUID and not the internal ID (integer).
16+
17+
Example resource response:
18+
19+
```diff
20+
{
21+
- "id": 2032,
22+
+ "uuid": "9a70ad0a-7717-4750-8cb7-c95b62133382",
23+
"title": "Skilltree example"
24+
}
25+
```
26+
27+
Example API endpoint:
28+
29+
```diff
30+
- GET /users/2032/settings,
31+
+ GET /users/9a70ad0a-7717-4750-8cb7-c95b62133382/settings,
32+
```
33+
34+
Concerns regarding using the ID:
35+
* The incremental nature of IDs gives insights about the amount of resources that exists. Although this information is not confidential for the public, it's preferred to not expose undesired details.
36+
* Malicious hackers can guess the resource identifiers and therefore attempt to access resources in endpoints that are not protected well enough. UUIDs are not incremental and have a probability of 2^12 which decreases the that chance people guess a UUID.
37+
* UUIDs can be shared across environments, allowing us to create consistent database setups when testing for example.

0 commit comments

Comments
 (0)