# Server APIs for Logseq

Logseq HTTP server is running at `http://${HOST}:${PORT}`.

## Available API

> 🔐 All API requests must provide a valid token for data security purposes by providing the `Authorization` field in the header. Tokens can be configured in Logseq.

### [POST] `/api`

Invoke any APs that's provided by Logseq plugin SDK.

- #### Request Body (`Content-Type: application/json`)

  - `method` {string} [required] pattern string as `logseq.Editor.getCurrentBlock` You can find more APIs from https://plugins-doc.logseq.com
  - `args` {array} [optional] arguments list for method

- #### Examples

      ### Send POST request with json body
      POST http://127.0.0.1:12315/api
      Content-Type: application/json
      Authorization: Bearer your-valid-token-xxx

      {
        "method": "logseq.Editor.getBlock",
        "args": [
          "6395fe84-9940-41bc-9bdf-3644bde42c42"
        ]
      }

      ### show a message tip
      POST http://127.0.0.1:12315/api
      Content-Type: application/json
      Authorization: Bearer your-valid-token-xxx

      {
        "method": "logseq.UI.showMsg",
        "args": [
          "Hello Logseq :)"
        ]
      }

## Helps

- Discord community https://discord.com/invite/KpN4eHY
- Logseq forum https://discuss.logseq.com/c/questions-and-help/8
- Plugin docs https://plugins-doc.logseq.com
- Plugin SDK https://www.npmjs.com/package/@logseq/libs