本文へ
API リファレンス

API リファレンス

CrowOn の外から、アカウントなしで呼べるアドレスの一覧です。どれも読み取りだけで、投稿や変更はできません。

アプリが使っている /api/… は、ログインが必要な内部用のもので、ここには載せていません。投稿やログイン連携などの公開 API は準備中です。

例のレスポンスは、テスト用のアカウントで実際に呼んだものです。

BASE URL
https://crowon.app
ENDPOINTS
GET  /oembedGET  /embed/{id}GET  /embed.jsGET  /s/p/{id}GET  /s/v/{id}GET  /s/u/{handle}GET  /@{handle}

認証

キーもトークンもいりません。どのサイトからでも呼べます(/oembed と /embed.js は Access-Control-Allow-Origin: *)。

表示されるのは、全員に公開されていて、投稿した人が埋め込みを許可している投稿だけです。

curl
curl "https://crowon.app/oembed?url=https://crowon.app/s/p/p-8f3a21c7d09e"

エラー

/oembed は、エラーのとき JSON で error を返します。

コード

404not_found
投稿がない、埋め込めない(全員に公開でない、埋め込みがオフ、削除・非表示)、または CrowOn 以外のアドレス
501json_only
format に json 以外を指定した
404
{"error":"not_found"}
501
{"error":"json_only"}

oEmbed

GET /oembed

投稿か動画のリンクから、埋め込みのコードを返します(oEmbed 1.0、rich)。共有リンクのページにある <link rel="alternate" type="application/json+oembed"> から自動で見つけられます。

パラメーター

urlstring必須
/s/p/…、/s/v/…、/embed/…、またはアプリのアドレス /#/p/…
maxwidthinteger
240〜540。ないときは 540
formatstring
json だけ

返すもの

埋め込みのコード(html)、投稿した人、サムネイル(写真か動画があるとき)。1時間キャッシュされます。

curl
curl "https://crowon.app/oembed?url=https://crowon.app/s/p/p-8f3a21c7d09e&maxwidth=540"
RESPONSE
{  "version": "1.0",  "type": "rich",  "provider_name": "CrowOn",  "provider_url": "https://crowon.app",  "title": "Morning light at the station.",  "author_name": "Mika Sato",  "author_url": "https://crowon.app/@mika.sato",  "html": "<blockquote class=\"crowon-embed\" data-post=\"p-8f3a21c7d09e\" style=\"max-width:540px;margin:0 auto\"><a href=\"https://crowon.app/s/p/p-8f3a21c7d09e\">View this post on CrowOn</a></blockquote><script async src=\"https://crowon.app/embed.js\"></script><noscript><iframe src=\"https://crowon.app/embed/p-8f3a21c7d09e\" width=\"540\" height=\"640\" style=\"border:0;max-width:100%\" loading=\"lazy\" title=\"CrowOn\"></iframe></noscript>",  "width": 540,  "height": 220,  "cache_age": 3600}

埋め込みカード

GET /embed/{id}

投稿を1枚のカードにした HTML です。ほかのサイトの iframe に入れられるのは、CrowOn ではこのアドレスだけです。

パラメーター

idstring必須
投稿か動画の ID(パスの中)
themestring
light か dark。ないときは見る人の端末に合わせます

返すもの

カードの HTML。表示できない投稿は 404 で「この投稿は表示できません」のカード。1分間キャッシュされます。

curl
curl -i https://crowon.app/embed/p-8f3a21c7d09e
RESPONSE
HTTP/1.1 200 OKContent-Type: text/html; charset=utf-8Cache-Control: public, max-age=60Content-Security-Policy: default-src 'none'; … frame-ancestors * <!doctype html><html lang="en"><head>…<title>CrowOn</title>…

埋め込みスクリプト

GET /embed.js

ページの blockquote.crowon-embed を /embed/{id} の iframe に置きかえ、カードの高さに合わせ続けます。1ページに何枚あっても、読み込むのは1回で足ります。

パラメーター

data-postattribute必須
投稿の ID
data-themeattribute
light か dark
HTML
<blockquote class="crowon-embed" data-post="p-8f3a21c7d09e" data-theme="dark">  <a href="https://crowon.app/s/p/p-8f3a21c7d09e">View this post on CrowOn</a></blockquote><script async src="https://crowon.app/embed.js"></script>
RESPONSE
HTTP/1.1 200 OKContent-Type: text/javascript; charset=utf-8Cache-Control: public, max-age=86400Access-Control-Allow-Origin: *

共有リンク

GET /s/p/{id}GET /s/v/{id}GET /s/u/{handle}

アプリの「リンクをコピー」で作られるアドレスです。リンクのプレビュー用のタグを返し、人が開いたときは crowon.app の画面に移ります。

写真のある投稿では og:image と summary_large_image、動画では og:type が video.other になり og:video がつきます。プレビューの言葉は、ブラウザが日本語なら日本語、それ以外は英語です。

パラメーター

/s/p/{id}投稿
全員に公開か、リンクを知っている人に公開の投稿
/s/v/{id}動画
Shorts の動画
/s/u/{handle}プロフィール
名前、自己紹介、アイコン

返すもの

Open Graph と X のカードのタグがある HTML。5分間キャッシュされます。表示できないものは「表示できません」のプレビューになります。

curl
curl https://crowon.app/s/p/p-8f3a21c7d09e
RESPONSE
<meta property="og:site_name" content="CrowOn"><meta property="og:title" content="Post by Mika Sato"><meta property="og:description" content="Morning light at the station."><meta property="og:type" content="article"><meta property="og:url" content="https://crowon.app/s/p/p-8f3a21c7d09e"><meta name="twitter:card" content="summary"><meta name="twitter:title" content="Post by Mika Sato"><meta name="twitter:description" content="Morning light at the station."><link rel="alternate" type="application/json+oembed" href="https://crowon.app/oembed?url=…"><meta http-equiv="refresh" content="0;url=/#/p/p-8f3a21c7d09e">