Skip to content

Commit 0770f2a

Browse files
Update REST.md
1 parent 6014477 commit 0770f2a

1 file changed

Lines changed: 145 additions & 1 deletion

File tree

docs/REST.md

Lines changed: 145 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,148 @@ Pocket Database Rest API supports all the features available, from creating a da
66
https://pocketdatabase.vercel.app/v1/api/<ENDPOINT>?token=<TOKEN?>&record=<RECORD>
77
```
88

9-
##
9+
## Writing a record
10+
11+
| Method | Endpoint |
12+
|:-----:|:-----:|
13+
| `POST` | `/write` |
14+
15+
This endpoint writes a record to a new database or to an existing database. If the token is not provided, a new database will be created.
16+
17+
```http
18+
POST https://pocketdatabase.vercel.app/v1/api/write?token=<TOKEN>&record=<RECORD>
19+
```
20+
21+
<details>
22+
<summary> <kbd>:rocket:</kbd> Request Object</summary>
23+
24+
The parameter **record** is required, and the request body must be a JSON.
25+
26+
</details>
27+
28+
<details>
29+
<summary> <kbd>:comet:</kbd> Response Object</summary>
30+
31+
```javascript
32+
{
33+
"success": Boolean,
34+
"result": {
35+
// List of records
36+
"list": Array<String>,
37+
"token": String
38+
}
39+
}
40+
```
41+
42+
</details>
43+
44+
## Reading a record
45+
46+
| Method | Endpoint |
47+
|:-----:|:-----:|
48+
| `GET` | `/read` |
49+
50+
This endpoint reads a record from an existing database.
51+
52+
```http
53+
GET https://pocketdatabase.vercel.app/v1/api/read?token=<TOKEN>&record=<RECORD>
54+
```
55+
56+
<details>
57+
<summary> <kbd>:rocket:</kbd> Request Object</summary>
58+
59+
The parameter **record** and **token** are required.
60+
61+
</details>
62+
63+
<details>
64+
<summary> <kbd>:comet:</kbd> Response Object</summary>
65+
66+
```javascript
67+
{
68+
"success": Boolean,
69+
"result": {
70+
// List of records
71+
"list": Array<String>,
72+
"token": String,
73+
// Data of the record
74+
"data": Any
75+
}
76+
}
77+
```
78+
79+
</details>
80+
81+
## Checking if a record exists
82+
83+
| Method | Endpoint |
84+
|:-----:|:-----:|
85+
| `POST` | `/write` |
86+
87+
This endpoint checks if a record exists from an existing database.
88+
89+
I suggest you to check on the `list` instead for optimization and less performance cost.
90+
91+
```http
92+
GET https://pocketdatabase.vercel.app/v1/api/has?token=<TOKEN>&record=<RECORD>
93+
```
94+
95+
<details>
96+
<summary> <kbd>:rocket:</kbd> Request Object</summary>
97+
98+
The parameter **record** and **token** are required.
99+
100+
</details>
101+
102+
<details>
103+
<summary> <kbd>:comet:</kbd> Response Object</summary>
104+
105+
```javascript
106+
{
107+
"success": Boolean,
108+
"result": {
109+
// List of records
110+
"list": Array<String>,
111+
"token": String,
112+
// Result of the checking
113+
"exists": Boolean
114+
}
115+
}
116+
```
117+
118+
</details>
119+
120+
## Deleting a record
121+
122+
| Method | Endpoint |
123+
|:-----:|:-----:|
124+
| `GET` | `/delete` |
125+
126+
This endpoint deletes a record from an existing database. Please take note that this will only override the data into a nil. Thus, the record will still exist but its data aren't.
127+
128+
```http
129+
GET https://pocketdatabase.vercel.app/v1/api/delete?token=<TOKEN>&record=<RECORD>
130+
```
131+
132+
<details>
133+
<summary> <kbd>:rocket:</kbd> Request Object</summary>
134+
135+
The parameter **record** and **token** are required.
136+
137+
</details>
138+
139+
<details>
140+
<summary> <kbd>:comet:</kbd> Response Object</summary>
141+
142+
```javascript
143+
{
144+
"success": Boolean,
145+
"result": {
146+
// List of records
147+
"list": Array<String>,
148+
"token": String
149+
}
150+
}
151+
```
152+
153+
</details>

0 commit comments

Comments
 (0)