Owncast Plugin APIs
Owncast プラグインランタイムは、プラグインが呼び出すことができるホスト関数を持つ単一のグローバル owncast を公開します。 Most methods require the matching permission in your manifest. A call without it never reaches Owncast: the host logs the denial and the call does nothing. What your plugin sees depends on the method. Mutating calls that report an outcome raise an error (moderation, users.register, auth.grantSession, kv.set, videoConfig.write, actions.add, actions.clear, and every sql method), readers return an empty or zero value, and calls that return nothing become silent no-ops. fs.write, fs.delete, and storage.upload are the exceptions: they report failure in their return value rather than raising. A few methods are ambient and need no permission: logging, timers, reading bundled assets, and owncast.config.get.
Plugins require Owncast 0.3.0 or later.
呼び出しは両方の SDK 用に表示され、タブで言語を選択します。 JavaScript または Python のセットアップを参照してください。 (JavaScript のメソッド名は camelCase で、Python は snake_case を使用します。つまり、sendAction は send_action となります。)
Logging
owncast.log.info(message), .warning(message), and .error(message)
Write an operator-visible entry to Owncast's server log. Owncast records the calling plugin's slug and the matching info, warning, or error severity. It replaces control characters with spaces so each entry stays on one line, then truncates messages longer than 4 KiB.
- JavaScript
- Python
owncast.log.info('sync started');
owncast.log.warning('provider response is incomplete');
owncast.log.error('sync failed');
owncast.log.info("sync started")
owncast.log.warning("provider response is incomplete")
owncast.log.error("sync failed")
環境: 権限は必要ありません。 See the paired chat-logger examples for JavaScript and Python.
チャット
チャットボット、モデレーションツール、またはフィルターを作成していますか? チャットプラグイン から始めてください。
owncast.chat.send(text)
チャットメッセージを投稿します。 プラグインのボットアイデンティティとして送信されます(マニフェストの bot.displayName または name からの表示名)。
- JavaScript
- Python
owncast.chat.send('hello chat');
owncast.chat.send("hello chat")
chat.send が必要です。
owncast.chat.sendAction(text)
アクションスタイル("/me")メッセージを投稿します。
- JavaScript
- Python
owncast.chat.sendAction('is now live');
owncast.chat.send_action("is now live")
chat.send が必要です。
owncast.chat.system(body)
サーバーアナウンスメッセージを投稿します。 ボットアイデンティティは添付されていません。 本文は HTML としてインライン表示されますので、「ストリームは5分後に開始します」といった短いサーバー属性の通知に使用してください。 本文は信頼されていない HTML 出力として扱います: それにユーザー入力を埋め込む際はエスケープを行わないでください。
Requires chat.send.
owncast.chat.sendTo(clientId, text)
接続されているクライアントにプライベートメッセージを送信します。
Requires chat.send.
owncast.chat.replyTo(msg, text)
チャットメッセージを送信した相手に返信します。 onChatMessage/filterChatMessage からチャットメッセージを渡します(あるいは裸のクライアント ID を使用します)。 送信者の接続が不明な場合(クライアント ID がない)、false を返しますので、パブリックな send にフォールバックできます。 sendTo(clientId, text) を使いやすくしたものです。
- JavaScript
- Python
onChatMessage(msg) {
if (!owncast.chat.replyTo(msg, "got it")) {
owncast.chat.send("got it");
}
}
@plugin.on_chat_message
def handle(msg):
if not owncast.chat.reply_to(msg, "got it"):
owncast.chat.send("got it")
chat.send が必要です。
owncast.chat.history(limit?)
最新のチャットメッセージを返します。各メッセージには id、user、body、timestamp が含まれます。 limit のデフォルトは 50 です。
chat.history が必要です。
owncast.chat.clients()
Return the list of currently-connected chat clients, each with id, userId?, displayName?, connectedAt?, userAgent?, ipAddress?, and messageCount. id は chat.kick に使用される接続ごとのクライアント ID です。
chat.history が必要です。
owncast.chat.deleteMessage(messageId)
視聴者からチャットメッセージを隠します。
Requires chat.moderate.
owncast.chat.kick(clientId)
チャットクライアントの接続を切ります。
Requires chat.moderate.
チャットアイデンティティ
すべてのプラグインには、プラグインがインストールされるときに Owncast が提供するチャットアイデンティティが正確に 1 つあります。 表示名は、設定されている場合はマニフェストの bot.displayName で、そうでない場合は name で、IsBot: true になります。 send と sendAction の両方がこのアイデンティティとして投稿され、Owncast の通常のチャットパイプライン(フィルター、レート制限、モデレーション)を通ります。 プラグインは任意の名前で投稿したり、実際のユーザーを偽装したりすることはできません。
ボットユーザーはプラグインの slug に基づいているので、アイデンティティは name または bot.displayName のマニフェストの編集を生き抜きます。 複数のチャットペルソナが必要な場合は、複数のプラグインを提供してください。
ユーザー
owncast.users.list() と owncast.users.get(id)
チャットユーザーリストまたは単一のユーザーレコードを読み取ります。
- JavaScript
- Python
const users = owncast.users.list();
const alice = owncast.users.get('u-alice');
users = owncast.users.list()
alice = owncast.users.get("u-alice")
users.read が必要です。
owncast.users.setEnabled(id, enabled, reason?)
チャットユーザーを有効または無効にします。
- JavaScript
- Python
owncast.users.setEnabled('u-spammer', false, 'spam');
owncast.users.set_enabled("u-spammer", False, "spam")
users.moderate が必要です。
owncast.users.banIP(ip)
チャットに参加するための IP を禁止します。
- JavaScript
- Python
owncast.users.banIP('203.0.113.42');
owncast.users.ban_ip("203.0.113.42")
users.moderate が必要です。
owncast.users.register({ authId, displayName?, scopes?, profileUrl?, handle?, public? })
Find or create an authenticated Owncast user for an external identity and return { userId }. Pass the provider's stable authId without adding your plugin slug. The host stores the slug separately as the identity provider, so plugins cannot collide with or spoof each other's users. displayName seeds a new user's name and is optional: omit it, or pass null, and Owncast generates a display name the same way it does for anonymous viewers. Non-empty scopes such as ["MODERATOR"] are applied on each call.
The optional profileUrl, handle, and public fields describe a verified external identity. profileUrl must be empty or an absolute HTTP(S) URL. handle is the provider's verified label, such as a GitHub login or fediverse handle. Set public to true only after the viewer opts into public display. It defaults to false. These profile fields are captured when the identity is first registered. Later calls with the same authId return the existing user but do not change the stored profile fields.
- JavaScript
- Python
const { userId } = owncast.users.register({
authId: 'github:583231',
displayName: 'octocat',
profileUrl: 'https://github.com/octocat',
handle: 'octocat',
public: false, // Set true only after the viewer opts in.
});
result = owncast.users.register(
"github:583231",
display_name="octocat",
profile_url="https://github.com/octocat",
handle="octocat",
public=False, # Set true only after the viewer opts in.
)
user_id = result.user_id
users.register が必要です。
認証
これが ビュアー認証ゲート の駆動源です。 grantSession と endSession は、ホストがセッションクッキーをインフライトHTTP応答に添付するため、onHttpRequest ハンドラ内でのみ機能します。
owncast.auth.grantSession({ userId, ttl? })
すでに登録されたユーザーについての署名されたセッションを発行します(owncast.users.register からの userId)。 ホストはセッションクッキーを現在の応答に付与、署名し、付加します。プラグインはトークンを決して見ず、偽造または漏えいすることはできません。 ttl はオプションのライフタイム(秒単位)です(0/省略された場合はホストのデフォルトの 24 時間を使用します)。
- JavaScript
- Python
const { userId } = owncast.users.register({ authId: 'shared', displayName: 'Guest' });
owncast.auth.grantSession({ userId });
return { status: 302, headers: { Location: returnTo } };
result = owncast.users.register("shared", display_name="Guest")
owncast.auth.grant_session(result.user_id)
return {"status": 302, "headers": {"Location": return_to}}
auth.gate が必要です。
owncast.auth.endSession()
現在のビューアのセッションクッキーをこの応答でクリアしてサインアウトさせます。 プラグインはリダイレクトを引き続き制御し(プロバイダーのログアウトにも転送する可能性があります)、
- JavaScript
- Python
owncast.auth.endSession();
return { status: 302, headers: { Location: '/' } };
owncast.auth.end_session()
return {"status": 302, "headers": {"Location": "/"}}
auth.gate が必要です。
ストレージ
owncast.kv.get(key) および owncast.kv.set(key, value)
プラグインごとのキー/バリュー ストア。プラグインの slug で名前空間化されます。 値は文字列です。
リッチタイプが必要な場合は、JSON ヘルパー(getJSON / setJSON、Python では get_json / set_json)を使用してください。自分で解析およびシリアル化するのではなく。 JSON ゲッターは、キーが設定されていないか無効な JSON を保持しているときにフォールバックを返します。 プラグインは互いのキーを読み取ることはできません。
- JavaScript
- Python
owncast.kv.set('count', '1');
const n = Number(owncast.kv.get('count') ?? '0');
owncast.kv.setJSON('prefs', { theme: 'dark' });
const prefs = owncast.kv.getJSON('prefs', {});
owncast.kv.set("count", "1")
n = int(owncast.kv.get("count") or "0")
owncast.kv.set_json("prefs", {"theme": "dark"})
prefs = owncast.kv.get_json("prefs", {})
storage.kv が必要です。
owncast.storage.upload(name, data)
Owncast の公開ファイルエリアにファイルをアップロードします。 JavaScript accepts a Uint8Array or string. Python accepts bytes or str. Raw bytes are preserved, while strings are encoded as UTF-8. JavaScript returns { url } or null. Python returns a dict accessed as result["url"], or None.
storage.upload が必要です。
owncast.fs.*
A private, sandboxed filesystem at data/plugin-storage/\<your-slug>/files/. owncast.storage.upload とは異なり、これらのファイルはサーバー側に残ります: HTTP 経由で提供されることはありません。 パスはサンドボックスのルートに対して相対的です。 ホストは各パスを独自のディレクトリに制限します(プラグインは他のプラグインのファイルを読み取ることができず、../ または絶対パスはサンドボックス内に戻ります)。 親ディレクトリは、書き込みが必要な場合に作成されます。
| JavaScript | Python | 返す |
|---|---|---|
fs.read(path) | fs.read(path) | Uint8Array / bytes, or null / None if missing |
fs.readText(path) | fs.read_text(path) | UTF-8 string / str, or null / None if missing |
fs.write(path, data) | fs.write(path, data) | { error? } |
fs.list(dir) | fs.list(dir) | エントリ名 (存在しないディレクトリは空) |
fs.delete(path) | fs.delete(path) | { error? } for a file or empty directory |
fs.exists(path) | fs.exists(path) | ブール値 |
fs.read preserves the original bytes. fs.readText and fs.read_text decode UTF-8. Python replaces malformed byte sequences when decoding. fs.write preserves a JavaScript Uint8Array or Python bytes, and UTF-8 encodes strings. fs.write and fs.delete return {} on success. If the host rejects the operation, they return { error } with the reason.
- JavaScript
- Python
owncast.fs.write('notes/log.txt', 'hello');
const text = owncast.fs.readText('notes/log.txt');
const data = new Uint8Array([0xff, 0x00, 0x80]);
owncast.fs.write('cache/data.bin', data);
const stored = owncast.fs.read('cache/data.bin');
if (stored) owncast.storage.upload('data.bin', stored);
owncast.fs.write("notes/log.txt", "hello")
text = owncast.fs.read_text("notes/log.txt")
data = bytes((0xFF, 0x00, 0x80))
owncast.fs.write("cache/data.bin", data)
stored = owncast.fs.read("cache/data.bin")
if stored is not None:
owncast.storage.upload("data.bin", stored)
storage.fs が必要です。
owncast.sql.*
One private SQLite database per plugin, at data/plugin-storage/\<your-slug>/db/plugin.db, separate from Owncast's own database and from the storage.fs sandbox. The sandbox is rooted at files/, so db/ is not a path owncast.fs.* refuses but one it cannot express, and the filesystem quota walk covers files/ only, so the two quotas stay independent. Reach for this over storage.kv when you need to sort, filter, or aggregate rather than just remember a value.
| Method | Returns |
|---|---|
sql.exec(sql, params?) | { rowsAffected, lastInsertId } |
sql.query(sql, params?) | rows as objects keyed by column name |
sql.queryRow(sql, params?) | the first row object, or null when nothing matched |
In Python queryRow is query_row, rows come back as dicts, and query_row returns None when nothing matched. An error throws in JavaScript and raises RuntimeError in Python. Parameters are null/None, booleans, numbers, or strings. Anything else is refused.
- JavaScript
- Python
owncast.sql.exec(`CREATE TABLE IF NOT EXISTS chatters (
user_id TEXT PRIMARY KEY,
messages INTEGER NOT NULL DEFAULT 0
)`);
owncast.sql.exec(
`INSERT INTO chatters (user_id, messages) VALUES (?, 1)
ON CONFLICT (user_id) DO UPDATE SET messages = messages + 1`,
[msg.user.id],
);
const top = owncast.sql.query(
'SELECT user_id, messages FROM chatters ORDER BY messages DESC LIMIT ?',
[5],
);
const mine = owncast.sql.queryRow('SELECT messages FROM chatters WHERE user_id = ?', [msg.user.id]);
owncast.sql.exec("""
CREATE TABLE IF NOT EXISTS chatters (
user_id TEXT PRIMARY KEY,
messages INTEGER NOT NULL DEFAULT 0
)
""")
owncast.sql.exec(
"""
INSERT INTO chatters (user_id, messages) VALUES (?, 1)
ON CONFLICT (user_id) DO UPDATE SET messages = messages + 1
""",
[msg.user.id],
)
top = owncast.sql.query(
"SELECT user_id, messages FROM chatters ORDER BY messages DESC LIMIT ?",
[5],
)
mine = owncast.sql.query_row("SELECT messages FROM chatters WHERE user_id = ?", [msg.user.id])
Each exec call runs as one host-owned transaction. A multi-statement batch commits whole or leaves the database untouched, so a schema migration can't half-apply. A plugin cannot leave a transaction open across calls, so there's nothing to clean up either.
query never hands back a silently short result. A query that overruns the row cap or the result budget is an error telling you to add a LIMIT, so write the bound you actually want when a table grows with your audience. queryRow reads a single row, which keeps it cheap on a table query is too big for.
| Limit | Value |
|---|---|
| Encoded request | 64 KiB total JSON |
| Bound parameters | 64 per call |
| Returned column value | 1 MiB |
| Encoded query result | 1 MiB |
| Rows returned | 10000 |
| Call duration | 2 seconds |
| Database size | 128 MiB |
Ordinary SQL is unaffected: DDL, DML, indexes, views, triggers, ORDER BY, recursive CTEs, subqueries, UNION, and the json1 functions all work. Refused in every host: ATTACH, DETACH, every PRAGMA (reads included), temporary-schema DDL both as keywords (CREATE TEMP TABLE / INDEX / TRIGGER / VIEW) and schema-qualified (CREATE TABLE temp.x), load_extension(), VACUUM and VACUUM INTO, and transaction controls (BEGIN, COMMIT, END, ROLLBACK, SAVEPOINT, and RELEASE). exec already owns the transaction around the whole batch.
Parameters and results cross the host boundary as JSON. Python can bind and read exact 64-bit SQLite integers. JavaScript loses unsafe integers before JSON.stringify on writes and during JSON.parse on reads. Store values above Number.MAX_SAFE_INTEGER (2^53 - 1) as TEXT when a JavaScript plugin needs them to remain exact.
Requires storage.sql. For a worked example, the chat-leaderboard plugin covers schema creation in one atomic exec, an ON CONFLICT upsert, a bounded ranked query, and a single-row read, in both JavaScript and Python. It contrasts with message-counter, which keeps the same counts in storage.kv and cannot rank.
設定
owncast.config.get(key, fallback?)
プラグインの一つの manifest-declared config 設定を読み取ります。 存在する場合は管理者が設定した値を返し、そうでなければ宣言されたデフォルト値を返します。すでに宣言された型にパース済みです。 不明なキー(または値のないキー)では fallback を返します。
- JavaScript
- Python
const cooldownMs = owncast.config.get('cooldownMs', 2000);
cooldown_ms = owncast.config.get("cooldownMs", 2000)
Ambient: no permission required. 単純なノブのために、独自の設定ページやキー/値の配管を構築することよりもこれを優先してください。 (設定キーはマニフェストで名前を付けたもので、言語ごとに翻訳されることはありません。)
ネットワーク
owncast.http.fetch(url, opts?)
同期的な外向きHTTPリクエスト。 opts は method、headers、および body を持ちます。 結果は { status, headers, body } です。 マニフェストの network.allowedHosts にリストされたホストだけが接続可能です。 その他はエラーを返します。
- JavaScript
- Python
const res = owncast.http.fetch('https://api.example.com/status');
if (res.status === 200) {
const data = JSON.parse(res.body);
}
import json
res = owncast.http.fetch("https://api.example.com/status")
if res.status == 200:
data = json.loads(res.body)
network.fetch と network.allowedHosts の一致するエントリが必要です。 あなたの言語自体のHTTPクライアントではなく、これを外向きHTTPに使用してください(Pythonでは requests を使用しないでください: プラグインにコンパイルされません)。
許可リストの構文については マニフェストリファレンス: ネットワーク を参照してください。
プラグイン間イベント
owncast.events.emit(eventType, payload)
Emit to a custom hook owned by another plugin. eventType is the fully
qualified \<recipient-slug>.\<hook> target. The host dispatches that exact name
and does not add the emitter's slug. The receiving plugin declares only its
local hook name. See the
handlers reference.
- JavaScript
- Python
owncast.events.emit('announcer.announcement.broadcast', { text: 'We are live' });
owncast.events.emit("announcer.announcement.broadcast", {"text": "We are live"})
events.emit が必要です。
ストリームおよびサーバーの状態
owncast.stream.current()
The current live stream state: { online, title?, summary?, viewers, startedAt?, latencyLevel? }.
Requires server.read.
owncast.stream.broadcaster()
Inbound encode telemetry for the current connection: { remoteAddr?, codecs?, resolution?, framerate?, bitrates? }. 読み取り専用で、放送が接続されていない場合はゼロ値です。 ビデオ出力を変更するには、以下のビデオ設定グループを参照してください。
server.read が必要です。
owncast.server.info()
Static server info: { name?, url?, summary?, welcomeMessage?, version? }.
- JavaScript
- Python
const name = owncast.server.info().name;
name = owncast.server.info().name
server.read が必要です。
owncast.server.socials()
The streamer's configured social links, each { platform, url, icon? }.
Requires server.read.
owncast.server.emotes()
サーバーのカスタムチャット絵文字: 公共の /api/emoji エンドポイントが提供する同じセットで、各 { name, url }。 :code: 絵文字をサーバーサイドでレンダリングまたはフィルタリングするのに便利です。
server.read が必要です。
owncast.server.federation()
Whether fediverse federation is enabled and under what handle: { enabled, username?, isPrivate? }. username is omitted when unset, and isPrivate is present only when true.
server.read が必要です。
owncast.server.tags()
ストリーマーの設定されたタグ、文字列のリストとして。
server.read が必要です。
ビデオおよびトランスコード設定
owncast.videoConfig.read()
Returns the current VideoConfig.
| Field | Type | Values |
|---|---|---|
latencyLevel | number | 0 through 4 |
codec | string | Configured ffmpeg encoder name |
autoplay | string | off, always, or sound-only |
variants | StreamVariant[] | Configured output renditions |
codec reads can report a legacy value or an encoder added by a newer host. Writes accept libx264, h264_omx, h264_vaapi, h264_qsv, h264_nvenc, h264_v4l2m2m, or h264_videotoolbox. Hardware codecs require the matching encoder in the host's ffmpeg build.
Autoplay off requires the viewer to press play. always starts automatically and may fall back to muted playback. sound-only starts automatically only when the browser allows sound.
Each StreamVariant has these fields:
| Field | Type | Description |
|---|---|---|
width | number | Scaled output width |
height | number | Scaled output height |
framerate | number | Output frames per second |
videoBitrate | number | Video bitrate in kbps |
cpuUsageLevel | number | Processing usage from 0 (lowest) through 4 (highest) |
isPassthrough | boolean | Pass video through without transcoding |
Audio settings are not exposed to plugins. Owncast preserves the existing audio configuration for each variant a plugin updates.
- JavaScript
- Python
const cfg = owncast.videoConfig.read();
cfg = owncast.video_config.read()
videoconfig.read が必要です。
owncast.videoConfig.write(partial)
Update any of the VideoConfig fields above. 部分的なオブジェクトを渡します。 含めたフィールドのみが変更されます。 変更は次のストリーム開始時に適用されます: ホストはアクティブな放送を再起動しません。
- JavaScript
- Python
owncast.videoConfig.write({ latencyLevel: 2, autoplay: "sound-only" });
owncast.video_config.write({"latencyLevel": 2, "autoplay": "sound-only"})
videoconfig.write が必要です。 これは高信頼性です。 管理者は慎重に権限を付与するべきです。
通知
owncast.notifications.discord(text)
ストリーマーの設定されたWebhookを通じてDiscord通知を送信します。
notifications.send が必要です。
owncast.notifications.browserPush({ title, body, url? })
購読されたブラウザにプッシュします。
- JavaScript
- Python
owncast.notifications.browserPush({ title: 'Live now', body: 'Come say hi', url: '/' });
owncast.notifications.browser_push({"title": "Live now", "body": "Come say hi", "url": "/"})
notifications.send が必要です。
owncast.notifications.fediverse({ type, body, image?, link? })
fediverse形式の通知を送信します(フォロワーへの投稿としてレンダリングされます)。
notifications.send が必要です。
fediverse
owncast.fediverse.post(text)
Owncastアカウントからfediverseに公開投稿を作成します。
Returns { url } on success (currently with an empty url: Owncast publishes the note but does not yet return its URL), or null when the host rejects the call.
fediverse.post が必要です。 高信頼性: fediverse投稿はストリーマーの自身のハンドルの下で行われ、静かに取り消すことはできません。 管理者は慎重に権限を付与するべきです。
アクションボタン(ランタイム)
owncast.actions.add(button | buttons[])
リロードせずに、プラグインのマニフェストセットに1つまたは複数のアクションボタンを追加します。 各ボタンは manifest.actions エントリと同じフィールド(title、および url / openExternally またはインライン html)を取ります。 ホストは manifest.actions と同じルールで各エントリを検証し、リロード後も追加が維持されます。 A rejected entry throws an error naming the entry and the rule it broke, and the whole batch is rejected, so nothing is added when any entry is invalid.
- JavaScript
- Python
owncast.actions.add({ title: 'Donate', url: '/plugins/my-plugin/donate', openExternally: true });
owncast.actions.add({"title": "Donate", "url": "/plugins/my-plugin/donate", "openExternally": True})
ui.modify が必要です。
owncast.actions.clear()
すべてのランタイムで追加されたアクションボタンを削除します。 マニフェストで宣言されたアクションは残ります。
ui.modify が必要です。
UI: アクションボタンでの完全なカバレッジ。
リアルタイムプッシュ(サーバー送信イベント)
owncast.sse.send(channel, event, data)
プラグインの /_sse/\<channel> エンドポイントに接続されているすべてのブラウザにサーバー送信イベントをプッシュします。
channel: どのストリームにプッシュするか。 デフォルトチャネルには""を使用します。event: ブラウザがリスンするイベント名。 デフォルトのmessageイベントには""を使用します。data: ペイロード。 文字列はそのまま送信されます。 それ以外のものはあなたのためにJSONエンコードされます。
- JavaScript
- Python
owncast.sse.send('alerts', 'donation', { from: 'alice', amount: 5 });
owncast.sse.send("alerts", "donation", {"from": "alice", "amount": 5})
ファイアアンドフォゲット。 呼び出しは直ちに返され、ブロックしません。 遅いクライアントはプラグインを停止するのではなく、フレームをドロップします。
http.sseが必要です。
HTTPを提供する: リアルタイム更新で完全なカバレッジ。
タイマー
遅延および繰り返し作業をスケジュールします。 タイマーはアンビエントで、権限は必要なく、プラグインが無効にされると自動的にクリアされます。 (Python: set_timeout, set_interval, clear。)
owncast.timer.setTimeout(fn, ms)
msミリ秒後にfnを一度実行します。 IDを返します。
owncast.timer.setInterval(fn, ms)
msミリ秒ごとにfnを繰り返し実行します。 IDを返します。
owncast.timer.clear(id)
返されたIDによって保留中のタイムアウトまたはインターバルをキャンセルします。
バンドルされたアセット
プラグインのassets/ディレクトリに配布したファイルを読み取ります。 アンビエント: 権限は必要ありません。 (Python: read, read_text。)
owncast.assets.read(path) and owncast.assets.readText(path)
Read a file bundled under assets/, relative to that directory. read returns the original bytes as a JavaScript Uint8Array or Python bytes. readText and Python's read_text decode the bytes as UTF-8. Python replaces malformed byte sequences when decoding. Missing files return null in JavaScript or None in Python.
- JavaScript
- Python
const image = owncast.assets.read('badge.png');
const template = owncast.assets.readText('template.html');
image = owncast.assets.read("badge.png")
template = owncast.assets.read_text("template.html")
完全なAPIリファレンス
以下のメソッド名はJavaScript(キャメルケース)形式です。 Pythonの対応するものはsnake_caseです(sendAction → send_action, banIP → ban_ip, videoConfig → video_config, など)。
| API | 権限 |
|---|---|
owncast.log.info / .warning / .error | なし(アンビエント) |
owncast.chat.send | chat.send |
owncast.chat.sendAction | chat.send |
owncast.chat.sendTo | chat.send |
owncast.chat.system | chat.send |
owncast.chat.replyTo | chat.send |
owncast.chat.history | chat.history |
owncast.chat.clients | chat.history |
owncast.chat.deleteMessage | chat.moderate |
owncast.chat.kick | chat.moderate |
owncast.users.list / .get | users.read |
owncast.users.setEnabled / .banIP | users.moderate |
owncast.users.register | users.register |
owncast.auth.grantSession / .endSession | auth.gate |
owncast.kv.get / .set / .getJSON / .setJSON | storage.kv |
owncast.storage.upload | storage.upload |
owncast.fs.read / .readText / .write / .list / .delete / .exists | storage.fs |
owncast.sql.exec / .query / .queryRow | storage.sql |
owncast.http.fetch | network.fetch |
owncast.events.emit | events.emit |
owncast.stream.current | server.read |
owncast.stream.broadcaster | server.read |
owncast.server.info / .socials / .emotes / .federation / .tags | server.read |
owncast.videoConfig.read | videoconfig.read |
owncast.videoConfig.write | videoconfig.write |
owncast.notifications.discord / .browserPush / .fediverse | notifications.send |
owncast.fediverse.post | fediverse.post |
owncast.actions.add / .clear | ui.modify |
owncast.timer.setTimeout / .setInterval / .clear | なし(アンビエント) |
owncast.assets.read / .readText | なし(アンビエント) |
owncast.config.get | none (ambient) |
owncast.sse.send | http.sse |
Improve this page
See something missing or incorrect? Edit this page and improve the documentation for everyone.
Gabe Kangas