mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-12-23 03:11:32 +00:00
Adding TOC to api.md
This commit is contained in:
parent
08b6660ae6
commit
3fb328ec1c
1 changed files with 131 additions and 2 deletions
133
docs/api.md
vendored
133
docs/api.md
vendored
|
@ -1,6 +1,130 @@
|
||||||
# Lemmy WebSocket API
|
# Lemmy WebSocket API
|
||||||
*Note: this may lag behind the actual API endpoints [here](../server/src/api).*
|
*Note: this may lag behind the actual API endpoints [here](../server/src/api).*
|
||||||
|
|
||||||
|
<!-- toc -->
|
||||||
|
|
||||||
|
- [Data types](#data-types)
|
||||||
|
- [Basic usage](#basic-usage)
|
||||||
|
* [Endpoint](#endpoint)
|
||||||
|
* [Testing with Websocat](#testing-with-websocat)
|
||||||
|
* [Testing with the WebSocket JavaScript API](#testing-with-the-websocket-javascript-api)
|
||||||
|
- [Rate limits](#rate-limits)
|
||||||
|
- [Errors](#errors)
|
||||||
|
- [API documentation](#api-documentation)
|
||||||
|
* [Sort Types](#sort-types)
|
||||||
|
* [User / Authentication / Admin actions](#user--authentication--admin-actions)
|
||||||
|
+ [Login](#login)
|
||||||
|
- [Request](#request)
|
||||||
|
- [Response](#response)
|
||||||
|
+ [Register](#register)
|
||||||
|
- [Request](#request-1)
|
||||||
|
- [Response](#response-1)
|
||||||
|
+ [Get User Details](#get-user-details)
|
||||||
|
- [Request](#request-2)
|
||||||
|
- [Response](#response-2)
|
||||||
|
+ [Save User Settings](#save-user-settings)
|
||||||
|
- [Request](#request-3)
|
||||||
|
- [Response](#response-3)
|
||||||
|
+ [Get Replies / Inbox](#get-replies--inbox)
|
||||||
|
- [Request](#request-4)
|
||||||
|
- [Response](#response-4)
|
||||||
|
+ [Mark all replies as read](#mark-all-replies-as-read)
|
||||||
|
- [Request](#request-5)
|
||||||
|
- [Response](#response-5)
|
||||||
|
+ [Delete Account](#delete-account)
|
||||||
|
- [Request](#request-6)
|
||||||
|
- [Response](#response-6)
|
||||||
|
+ [Add admin](#add-admin)
|
||||||
|
- [Request](#request-7)
|
||||||
|
- [Response](#response-7)
|
||||||
|
+ [Ban user](#ban-user)
|
||||||
|
- [Request](#request-8)
|
||||||
|
- [Response](#response-8)
|
||||||
|
* [Site](#site)
|
||||||
|
+ [List Categories](#list-categories)
|
||||||
|
- [Request](#request-9)
|
||||||
|
- [Response](#response-9)
|
||||||
|
+ [Search](#search)
|
||||||
|
- [Request](#request-10)
|
||||||
|
- [Response](#response-10)
|
||||||
|
+ [Get Modlog](#get-modlog)
|
||||||
|
- [Request](#request-11)
|
||||||
|
- [Response](#response-11)
|
||||||
|
+ [Create Site](#create-site)
|
||||||
|
- [Request](#request-12)
|
||||||
|
- [Response](#response-12)
|
||||||
|
+ [Edit Site](#edit-site)
|
||||||
|
- [Request](#request-13)
|
||||||
|
- [Response](#response-13)
|
||||||
|
+ [Get Site](#get-site)
|
||||||
|
- [Request](#request-14)
|
||||||
|
- [Response](#response-14)
|
||||||
|
+ [Transfer Site](#transfer-site)
|
||||||
|
- [Request](#request-15)
|
||||||
|
- [Response](#response-15)
|
||||||
|
* [Community](#community)
|
||||||
|
+ [Get Community](#get-community)
|
||||||
|
- [Request](#request-16)
|
||||||
|
- [Response](#response-16)
|
||||||
|
+ [Create Community](#create-community)
|
||||||
|
- [Request](#request-17)
|
||||||
|
- [Response](#response-17)
|
||||||
|
+ [List Communities](#list-communities)
|
||||||
|
- [Request](#request-18)
|
||||||
|
- [Response](#response-18)
|
||||||
|
+ [Ban from Community](#ban-from-community)
|
||||||
|
- [Request](#request-19)
|
||||||
|
- [Response](#response-19)
|
||||||
|
+ [Add Mod to Community](#add-mod-to-community)
|
||||||
|
- [Request](#request-20)
|
||||||
|
- [Response](#response-20)
|
||||||
|
+ [Edit Community](#edit-community)
|
||||||
|
- [Request](#request-21)
|
||||||
|
- [Response](#response-21)
|
||||||
|
+ [Follow Community](#follow-community)
|
||||||
|
- [Request](#request-22)
|
||||||
|
- [Response](#response-22)
|
||||||
|
+ [Get Followed Communities](#get-followed-communities)
|
||||||
|
- [Request](#request-23)
|
||||||
|
- [Response](#response-23)
|
||||||
|
+ [Transfer Community](#transfer-community)
|
||||||
|
- [Request](#request-24)
|
||||||
|
- [Response](#response-24)
|
||||||
|
* [Post](#post)
|
||||||
|
+ [Create Post](#create-post)
|
||||||
|
- [Request](#request-25)
|
||||||
|
- [Response](#response-25)
|
||||||
|
+ [Get Post](#get-post)
|
||||||
|
- [Request](#request-26)
|
||||||
|
- [Response](#response-26)
|
||||||
|
+ [Get Posts](#get-posts)
|
||||||
|
- [Request](#request-27)
|
||||||
|
- [Response](#response-27)
|
||||||
|
+ [Create Post Like](#create-post-like)
|
||||||
|
- [Request](#request-28)
|
||||||
|
- [Response](#response-28)
|
||||||
|
+ [Edit Post](#edit-post)
|
||||||
|
- [Request](#request-29)
|
||||||
|
- [Response](#response-29)
|
||||||
|
+ [Save Post](#save-post)
|
||||||
|
- [Request](#request-30)
|
||||||
|
- [Response](#response-30)
|
||||||
|
* [Comment](#comment)
|
||||||
|
+ [Create Comment](#create-comment)
|
||||||
|
- [Request](#request-31)
|
||||||
|
- [Response](#response-31)
|
||||||
|
+ [Edit Comment](#edit-comment)
|
||||||
|
- [Request](#request-32)
|
||||||
|
- [Response](#response-32)
|
||||||
|
+ [Save Comment](#save-comment)
|
||||||
|
- [Request](#request-33)
|
||||||
|
- [Response](#response-33)
|
||||||
|
+ [Create Comment Like](#create-comment-like)
|
||||||
|
- [Request](#request-34)
|
||||||
|
- [Response](#response-34)
|
||||||
|
|
||||||
|
<!-- tocstop -->
|
||||||
|
|
||||||
## Data types
|
## Data types
|
||||||
|
|
||||||
- `i16`, `i32` and `i64` are respectively [16-bit](https://en.wikipedia.org/wiki/16-bit), [32-bit](https://en.wikipedia.org/wiki/32-bit) and [64-bit](https://en.wikipedia.org/wiki/64-bit_computing) integers.
|
- `i16`, `i32` and `i64` are respectively [16-bit](https://en.wikipedia.org/wiki/16-bit), [32-bit](https://en.wikipedia.org/wiki/32-bit) and [64-bit](https://en.wikipedia.org/wiki/64-bit_computing) integers.
|
||||||
|
@ -19,13 +143,18 @@ Connect to <code>ws://***host***/api/v1/ws</code> to get started.
|
||||||
|
|
||||||
If the ***`host`*** supports secure connections, you can use <code>wss://***host***/api/v1/ws</code>.
|
If the ***`host`*** supports secure connections, you can use <code>wss://***host***/api/v1/ws</code>.
|
||||||
|
|
||||||
### Testing with [Websocat](https://github.com/vi/websocat)
|
### Testing with Websocat
|
||||||
|
|
||||||
|
[Websocat link](https://github.com/vi/websocat)
|
||||||
|
|
||||||
`websocat ws://127.0.0.1:8536/api/v1/ws -nt`
|
`websocat ws://127.0.0.1:8536/api/v1/ws -nt`
|
||||||
|
|
||||||
A simple test command:
|
A simple test command:
|
||||||
`{"op": "ListCategories"}`
|
`{"op": "ListCategories"}`
|
||||||
|
|
||||||
### Testing with the [WebSocket JavaScript API](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API)
|
### Testing with the WebSocket JavaScript API
|
||||||
|
|
||||||
|
[WebSocket JavaScript API](https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API)
|
||||||
```javascript
|
```javascript
|
||||||
var ws = new WebSocket("ws://" + host + "/api/v1/ws");
|
var ws = new WebSocket("ws://" + host + "/api/v1/ws");
|
||||||
ws.onopen = function () {
|
ws.onopen = function () {
|
||||||
|
|
Loading…
Reference in a new issue