Ctrl K
ComunidadGuías…

rest-api-examples.http

Rama master · réplica de lectura del repositorio original.

Archivo original ↗Preguntar a KiBot
# 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
@renamed_upload = renamed-example.txt
@newuser_username = newuser
@newuser_password = test
@newuser_role = viewer

### Authentication

#### Login
# @name login
POST {{ base_url }}/api/login
Content-Type: application/json

{
  "username": "{{ username }}",
  "password": "{{ password }}",
  "keepLoggedIn": false
}

#### Check auth status
GET {{ base_url }}/api/check-auth
Accept: application/json

### Profile

#### Change password (wrong current password — expect 401)
POST {{ base_url }}/api/password
Content-Type: application/json

{
  "current_password": "wrongpass",
  "new_password": "newpass123"
}

#### Change password via GET (expect 405)
GET {{ base_url }}/api/password

### Documents

#### Create document
POST {{ base_url }}/api/document/create
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 }}
Accept: text/markdown

#### Save document
POST {{ base_url }}/api/save/{{ doc_path }}
Content-Type: text/markdown

{{ doc_body }}

#### Rename document
POST {{ base_url }}/api/document/move
Content-Type: application/json

{
  "sourcePath": "test-doc",
  "targetPath": "",
  "newSlug": "test-doc2"
}

#### Move document
POST {{ base_url }}/api/document/move
Content-Type: application/json

{
  "sourcePath": "test-doc2",
  "targetPath": "cat/sub",
  "newSlug": "test-doc2"
}

#### Delete document
DELETE {{ base_url }}/api/document/{{ doc_path }}

### Files

#### Upload file (text example)
POST {{ base_url }}/api/files/upload
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 }}

#### Rename file
POST {{ base_url }}/api/files/rename
Content-Type: application/json

{
  "currentPath": "{{ doc_path }}/{{ test_upload }}",
  "newName": "{{ renamed_upload }}"
}

#### Delete renamed file
DELETE {{ base_url }}/api/files/delete/{{ doc_path }}/{{ renamed_upload }}

### Comments

#### Add comment
POST {{ base_url }}/api/comments/add/{{ doc_path }}
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 }}

### 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

### Admin

#### Get wiki settings
GET {{ base_url }}/api/settings/wiki
Accept: application/json

#### Update wiki settings
POST {{ base_url }}/api/settings/wiki
Content-Type: application/json

{
  "title": "📚 Wiki-Go",
  "owner": "wikigo.leomoon.com",
  "notice": "Copyright :::year::: © 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"
}

#### Update security settings
POST {{ base_url }}/api/settings/security
Content-Type: application/json

{
  "login_ban": {
    "enabled": true,
    "max_failures": 5,
    "window_seconds": 180,
    "initial_ban_seconds": 60,
    "max_ban_seconds": 86400
  }
}

#### List users
GET {{ base_url }}/api/users
Accept: application/json

#### Create user
POST {{ base_url }}/api/users
Content-Type: application/json

{
  "username": "{{ newuser_username }}",
  "password": "{{ newuser_password }}",
  "role": "{{ newuser_role }}"
}

#### Update user
PUT {{ base_url }}/api/users
Content-Type: application/json

{
  "username": "{{ newuser_username }}",
  "new_password": "{{ newuser_password }}",
  "role": "{{ newuser_role }}"
}

#### Delete user
DELETE {{ base_url }}/api/users?username=newuser
Content-Type: application/json

### Backup

#### Start backup
# @name start_backup
POST {{ base_url }}/api/backup/start

### Store the backup job ID
@backup_job_id = {{start_backup.response.body.$.jobId}}

#### Check backup status
GET {{ base_url }}/api/backup/status/{{ backup_job_id }}
Accept: application/json

#### List backups
# @name list_backups
GET {{ base_url }}/api/backup/list
Accept: application/json

### Store the first backup filename
@backup_filename = {{list_backups.response.body.$.backups[0].name}}

#### Download backup
GET {{ base_url }}/api/backup/download/{{ backup_filename }}

#### Delete backup
DELETE {{ base_url }}/api/backup/delete/{{ backup_filename }}

### Links API

#### Add a new link to links document
POST {{ base_url }}/api/links/add/links
Content-Type: application/json

{
  "url": "https://stackoverflow.com",
  "title": "Stack Overflow",
  "description": "Programming Q&A community",
  "category": "Learning Resources",
  "date": "2025-09-03"
}

#### Edit an existing link (update GitHub link)
PUT {{ base_url }}/api/links/edit/links
Content-Type: application/json

{
  "oldUrl": "https://github.com",
  "newLink": {
    "url": "https://github.com",
    "title": "GitHub - Updated",
    "description": "World's leading development platform - Updated!",
    "category": "Work Tools",
    "date": "2025-09-03"
  }
}

#### Delete a link (remove Figma)
DELETE {{ base_url }}/api/links/delete/links
Content-Type: application/json

{
  "url": "https://figma.com"
}

#### Fetch metadata
POST {{ base_url }}/api/links/fetch-metadata
Content-Type: application/json

{
  "url": "https://www.kingorama.com/rostam-pop-up-book"
}

### Password-change and authentication cleanup

#### Change password (correct — expect 200 and session revocation)
POST {{ base_url }}/api/password
Content-Type: application/json

{
  "current_password": "{{ password }}",
  "new_password": "{{ password }}"
}

#### Check auth after password change (expect 401)
GET {{ base_url }}/api/check-auth
Accept: application/json

#### Log in again after password change
POST {{ base_url }}/api/login
Content-Type: application/json

{
  "username": "{{ username }}",
  "password": "{{ password }}",
  "keepLoggedIn": false
}

#### Logout after re-authentication
POST {{ base_url }}/api/logout
Content-Type: application/json