forked from leomoon-studios/wiki-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrest-api-examples.http
More file actions
215 lines (168 loc) · 4.81 KB
/
rest-api-examples.http
File metadata and controls
215 lines (168 loc) · 4.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# REST Client VSCode Extension compatible (humao.rest-client)
### Variables
@base_url = http://127.0.0.1:8080
@username = admin
@password = test
@doc_name = API Test Document
@doc_path = api-testing/api-test-document
@doc_body = # API Test Document\n\nChanged content...
@test_upload = example.txt
@newuser_username = newuser
@newuser_password = test
@newuser_role = viewer
### Authentication
#### Login
POST {{ base_url }}/api/login
Content-Type: application/json
{
"username": "{{ username }}",
"password": "{{ password }}"
}
### Store the login session
@session = {{$login.response.headers['set-cookie']?.match(/session_token=([^;]+)/)[1]}}
#### Check auth status
GET {{ base_url }}/api/check-auth
Cookie: session={{ session }}
Accept: application/json
#### Logout
POST {{ base_url }}/api/logout
Cookie: session={{ session }}
Content-Type: application/json
### Documents
#### Create document
POST {{ base_url }}/api/document/create
Cookie: session={{ session }}
Content-Type: application/json
{
"title": "{{ doc_name }}",
"path": "{{ doc_path }}"
}
#### Get document HTML
GET {{ base_url }}/api/document/{{ doc_path }}
Accept: text/html
#### Get document source (Markdown)
GET {{ base_url }}/api/source/{{ doc_path }}
Cookie: session={{ session }}
Accept: text/markdown
#### Save document
POST {{ base_url }}/api/save/{{ doc_path }}
Cookie: session={{ session }}
Content-Type: text/markdown
{{ doc_body }}
#### Rename document
POST {{ base_url }}/api/document/move
Cookie: session={{ session }}
Content-Type: application/json
{
"sourcePath": "test-doc",
"targetPath": "",
"newSlug": "test-doc2"
}
#### Move document
POST {{ base_url }}/api/document/move
Cookie: session={{ session }}
Content-Type: application/json
{
"sourcePath": "test-doc2",
"targetPath": "cat/sub",
"newSlug": "test-doc2"
}
#### Delete document
DELETE {{ base_url }}/api/document/{{ doc_path }}
Cookie: session={{ session }}
### Files
#### Upload file (text example)
POST {{ base_url }}/api/files/upload
Cookie: session={{ session }}
Content-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="docPath"
{{ doc_path }}
------WebKitFormBoundary7MA4YWxkTrZu0gW
Content-Disposition: form-data; name="file"; filename="example.txt"
Content-Type: text/plain
This is the content of the text file being uploaded.
------WebKitFormBoundary7MA4YWxkTrZu0gW--
#### List files
GET {{ base_url }}/api/files/list/{{ doc_path }}
Accept: application/json
#### Serve file
GET {{ base_url }}/api/files/{{ doc_path }}/{{ test_upload }}
Cookie: session={{ session }}
#### Delete file
DELETE {{ base_url }}/api/files/delete/{{ doc_path }}/{{ test_upload }}
Cookie: session={{ session }}
### Comments
#### Add comment
POST {{ base_url }}/api/comments/add/{{ doc_path }}
Cookie: session={{ session }}
Content-Type: application/json
{
"content": "This is a comment"
}
#### Get comments
# @name list_comments
GET {{ base_url }}/api/comments/{{ doc_path }}
Accept: application/json
### Store the first comment id
@comment_id = {{list_comments.response.body.$.comments[0].ID}}
#### Delete comment
DELETE {{ base_url }}/api/comments/delete/{{ doc_path }}/{{ comment_id }}
Cookie: session={{ session }}
### Versions
#### Get version history
# @name get_version_history
GET {{ base_url }}/api/versions/{{ doc_path }}
Accept: application/json
### Store the first version’s timestamp
@version_ts = {{get_version_history.response.body.$.versions[0].timestamp}}
#### Restore version
POST {{ base_url }}/api/versions/{{ doc_path }}/{{ version_ts }}/restore
Cookie: session={{ session }}
### Admin
#### Get wiki settings
GET {{ base_url }}/api/settings/wiki
Cookie: session={{ session }}
Accept: application/json
#### Update wiki settings
POST {{ base_url }}/api/settings/wiki
Cookie: session={{ session }}
Content-Type: application/json
{
"title": "📚 Wiki-Go",
"owner": "wikigo.leomoon.com",
"notice": "Copyright 2025 © All rights reserved.",
"timezone": "America/Vancouver",
"private": false,
"disable_comments": false,
"disable_file_upload_checking": false,
"max_versions": 10,
"max_upload_size": 1,
"language": "en"
}
#### List users
GET {{ base_url }}/api/users
Cookie: session={{ session }}
Accept: application/json
#### Create user
POST {{ base_url }}/api/users
Cookie: session={{ session }}
Content-Type: application/json
{
"username": "{{ newuser_username }}",
"password": "{{ newuser_password }}",
"role": "{{ newuser_role }}"
}
#### Update user
PUT {{ base_url }}/api/users
Cookie: session={{ session }}
Content-Type: application/json
{
"username": "{{ newuser_username }}",
"new_password": "{{ newuser_password }}",
"role": "{{ newuser_role }}"
}
#### Delete user
DELETE {{ base_url }}/api/users?username=newuser
Cookie: session={{ session }}
Content-Type: application/json