KosmoKrator

social

Mastodon Lua API for KosmoKrator Agents

Agent-facing Lua documentation and function reference for the Mastodon KosmoKrator integration.

6 functions 5 read 1 write Bearer token auth

Lua Namespace

Agents call this integration through app.integrations.mastodon.*. Use lua_read_doc("integrations.mastodon") inside KosmoKrator to discover the same reference at runtime.

Agent-Facing Lua Docs

This is the rendered version of the full Lua documentation exposed to agents when they inspect the integration namespace.

Mastodon β€” Lua API Reference

list_statuses

Browse statuses (toots) from a Mastodon timeline.

Parameters

NameTypeRequiredDescription
timelinestringnoTimeline to retrieve: "home" (default), "local", or "public"
limitintegernoMax statuses to return (1–40, default: 20)
max_idstringnoReturn results older than this status ID (pagination)
since_idstringnoReturn results newer than this status ID (pagination)

Examples

Home timeline

local result = app.integrations.mastodon.list_statuses({
  timeline = "home",
  limit = 10
})

for _, status in ipairs(result.statuses) do
  print(status.account.display_name .. ": " .. status.content)
end

Public timeline with pagination

local result = app.integrations.mastodon.list_statuses({
  timeline = "public",
  limit = 40,
  max_id = last_seen_id
})

get_status

Retrieve a single status (toot) by its ID.

Parameters

NameTypeRequiredDescription
idstringyesThe ID of the status to retrieve

Example

local status = app.integrations.mastodon.get_status({ id = "1234567890" })
print(status.account.username .. " posted: " .. status.content)
print("Boosts: " .. status.reblogs_count .. ", Favs: " .. status.favourites_count)

create_status

Publish a new status (toot) on Mastodon.

Parameters

NameTypeRequiredDescription
statusstringyesThe text content of the status
visibilitystringno"public" (default), "unlisted", "private", or "direct"
in_reply_to_idstringnoID of the status to reply to
spoiler_textstringnoContent warning text
sensitivebooleannoWhether the status contains sensitive media
languagestringnoISO 639-1 language code (e.g., "en", "nl")

Examples

Simple post

local result = app.integrations.mastodon.create_status({
  status = "Hello from the API! 🐘"
})
print("Posted: " .. result.url)

Post with content warning

local result = app.integrations.mastodon.create_status({
  status = "Spoilers for the latest episode...",
  spoiler_text = "TV Show Spoilers",
  visibility = "unlisted"
})

Reply to a status

local result = app.integrations.mastodon.create_status({
  status = "Great point! I agree.",
  in_reply_to_id = "1234567890"
})

list_accounts

List followers of a Mastodon account.

Parameters

NameTypeRequiredDescription
idstringyesThe account ID whose followers to list
limitintegernoMax accounts to return (1–80, default: 40)
max_idstringnoReturn results older than this account ID (pagination)

Example

local result = app.integrations.mastodon.list_accounts({
  id = "123456",
  limit = 20
})

for _, follower in ipairs(result.followers) do
  print(follower.display_name .. " (@" .. follower.acct .. ")")
  print("  Followers: " .. follower.followers_count)
end

get_account

Retrieve a Mastodon account profile by ID.

Parameters

NameTypeRequiredDescription
idstringyesThe account ID to retrieve

Example

local account = app.integrations.mastodon.get_account({ id = "123456" })
print(account.display_name .. " (@" .. account.username .. ")")
print("Bio: " .. account.note)
print("Followers: " .. account.followers_count)
print("Following: " .. account.following_count)
print("Statuses: " .. account.statuses_count)

get_current_user

Get the authenticated user’s Mastodon profile.

Parameters

None.

Example

local me = app.integrations.mastodon.get_current_user({})
print("Logged in as @" .. me.username)
print("Display name: " .. me.display_name)
print("Default visibility: " .. (me.source.privacy or "public"))

Multi-Account Usage

If you have multiple Mastodon accounts configured, use account-specific namespaces:

-- Default account (always works)
app.integrations.mastodon.function_name({...})

-- Explicit default (portable across setups)
app.integrations.mastodon.default.function_name({...})

-- Named accounts
app.integrations.mastodon.work.function_name({...})
app.integrations.mastodon.personal.function_name({...})

All functions are identical across accounts β€” only the credentials differ.

Raw agent markdown
# Mastodon β€” Lua API Reference

## list_statuses

Browse statuses (toots) from a Mastodon timeline.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `timeline` | string | no | Timeline to retrieve: `"home"` (default), `"local"`, or `"public"` |
| `limit` | integer | no | Max statuses to return (1–40, default: 20) |
| `max_id` | string | no | Return results older than this status ID (pagination) |
| `since_id` | string | no | Return results newer than this status ID (pagination) |

### Examples

#### Home timeline

```lua
local result = app.integrations.mastodon.list_statuses({
  timeline = "home",
  limit = 10
})

for _, status in ipairs(result.statuses) do
  print(status.account.display_name .. ": " .. status.content)
end
```

#### Public timeline with pagination

```lua
local result = app.integrations.mastodon.list_statuses({
  timeline = "public",
  limit = 40,
  max_id = last_seen_id
})
```

---

## get_status

Retrieve a single status (toot) by its ID.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The ID of the status to retrieve |

### Example

```lua
local status = app.integrations.mastodon.get_status({ id = "1234567890" })
print(status.account.username .. " posted: " .. status.content)
print("Boosts: " .. status.reblogs_count .. ", Favs: " .. status.favourites_count)
```

---

## create_status

Publish a new status (toot) on Mastodon.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `status` | string | yes | The text content of the status |
| `visibility` | string | no | `"public"` (default), `"unlisted"`, `"private"`, or `"direct"` |
| `in_reply_to_id` | string | no | ID of the status to reply to |
| `spoiler_text` | string | no | Content warning text |
| `sensitive` | boolean | no | Whether the status contains sensitive media |
| `language` | string | no | ISO 639-1 language code (e.g., `"en"`, `"nl"`) |

### Examples

#### Simple post

```lua
local result = app.integrations.mastodon.create_status({
  status = "Hello from the API! 🐘"
})
print("Posted: " .. result.url)
```

#### Post with content warning

```lua
local result = app.integrations.mastodon.create_status({
  status = "Spoilers for the latest episode...",
  spoiler_text = "TV Show Spoilers",
  visibility = "unlisted"
})
```

#### Reply to a status

```lua
local result = app.integrations.mastodon.create_status({
  status = "Great point! I agree.",
  in_reply_to_id = "1234567890"
})
```

---

## list_accounts

List followers of a Mastodon account.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The account ID whose followers to list |
| `limit` | integer | no | Max accounts to return (1–80, default: 40) |
| `max_id` | string | no | Return results older than this account ID (pagination) |

### Example

```lua
local result = app.integrations.mastodon.list_accounts({
  id = "123456",
  limit = 20
})

for _, follower in ipairs(result.followers) do
  print(follower.display_name .. " (@" .. follower.acct .. ")")
  print("  Followers: " .. follower.followers_count)
end
```

---

## get_account

Retrieve a Mastodon account profile by ID.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `id` | string | yes | The account ID to retrieve |

### Example

```lua
local account = app.integrations.mastodon.get_account({ id = "123456" })
print(account.display_name .. " (@" .. account.username .. ")")
print("Bio: " .. account.note)
print("Followers: " .. account.followers_count)
print("Following: " .. account.following_count)
print("Statuses: " .. account.statuses_count)
```

---

## get_current_user

Get the authenticated user's Mastodon profile.

### Parameters

None.

### Example

```lua
local me = app.integrations.mastodon.get_current_user({})
print("Logged in as @" .. me.username)
print("Display name: " .. me.display_name)
print("Default visibility: " .. (me.source.privacy or "public"))
```

---

## Multi-Account Usage

If you have multiple Mastodon accounts configured, use account-specific namespaces:

```lua
-- Default account (always works)
app.integrations.mastodon.function_name({...})

-- Explicit default (portable across setups)
app.integrations.mastodon.default.function_name({...})

-- Named accounts
app.integrations.mastodon.work.function_name({...})
app.integrations.mastodon.personal.function_name({...})
```

All functions are identical across accounts β€” only the credentials differ.

Metadata-Derived Lua Example

local result = app.integrations.mastodon.mastodon_list_statuses({
  timeline = "example_timeline",
  limit = 1,
  max_id = "example_max_id",
  since_id = "example_since_id"
})
print(result)

Functions

mastodon_list_statuses

Browse statuses (toots) from a Mastodon timeline. Use "home" for your home feed, "public" for the federated timeline, or "local" for the local instance timeline. Supports pagination.

Operation
Read read
Full name
mastodon.mastodon_list_statuses
ParameterTypeRequiredDescription
timeline string no Timeline to retrieve: "home" (default), "local", or "public".
limit integer no Maximum number of statuses to return (1–40, default: 20).
max_id string no Return results older than this status ID (for pagination).
since_id string no Return results newer than this status ID (for pagination).

mastodon_get_status

Retrieve a single Mastodon status (toot) by its ID. Returns the full post content, author details, and engagement metrics.

Operation
Read read
Full name
mastodon.mastodon_get_status
ParameterTypeRequiredDescription
id string yes The ID of the status to retrieve.

mastodon_create_status

Publish a new status (toot) on Mastodon. Supports content warnings, visibility controls (public, unlisted, private, direct), replies, and language settings.

Operation
Write write
Full name
mastodon.mastodon_create_status
ParameterTypeRequiredDescription
status string yes The text content of the status.
visibility string no Visibility: "public" (default), "unlisted", "private", or "direct".
in_reply_to_id string no ID of the status to reply to.
spoiler_text string no Content warning text (marks the status as sensitive).
sensitive boolean no Whether the status contains sensitive media.
language string no ISO 639-1 language code (e.g., "en", "nl", "fr").

mastodon_list_accounts

List followers of a Mastodon account. Returns account profiles with display names, bios, and follower counts. Supports pagination.

Operation
Read read
Full name
mastodon.mastodon_list_accounts
ParameterTypeRequiredDescription
id string yes The account ID whose followers to list.
limit integer no Maximum number of accounts to return (1–80, default: 40).
max_id string no Return results older than this account ID (for pagination).

mastodon_get_account

Retrieve a Mastodon account profile by ID. Returns display name, bio, follower counts, and other profile details.

Operation
Read read
Full name
mastodon.mastodon_get_account
ParameterTypeRequiredDescription
id string yes The account ID to retrieve.

mastodon_get_current_user

Get the authenticated user's Mastodon profile. Returns display name, bio, follower/following counts, and other account details.

Operation
Read read
Full name
mastodon.mastodon_get_current_user
ParameterTypeRequiredDescription
No parameters.