API リファレンス
CrowOn の外から、アカウントなしで呼べるアドレスの一覧です。どれも読み取りだけで、投稿や変更はできません。
アプリが使っている /api/… は、ログインが必要な内部用のもので、ここには載せていません。投稿やログイン連携などの公開 API は準備中です。
例のレスポンスは、テスト用のアカウントで実際に呼んだものです。
https://crowon.appGET /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 "https://crowon.app/oembed?url=https://crowon.app/s/p/p-8f3a21c7d09e"エラー
/oembed は、エラーのとき JSON で error を返します。
コード
404not_found- 投稿がない、埋め込めない(全員に公開でない、埋め込みがオフ、削除・非表示)、または CrowOn 以外のアドレス
501json_onlyformatにjson以外を指定した
{"error":"not_found"}{"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
formatstringjsonだけ
返すもの
埋め込みのコード(html)、投稿した人、サムネイル(写真か動画があるとき)。1時間キャッシュされます。
curl "https://crowon.app/oembed?url=https://crowon.app/s/p/p-8f3a21c7d09e&maxwidth=540"{ "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(パスの中)
themestringlightかdark。ないときは見る人の端末に合わせます
返すもの
カードの HTML。表示できない投稿は 404 で「この投稿は表示できません」のカード。1分間キャッシュされます。
curl -i https://crowon.app/embed/p-8f3a21c7d09eHTTP/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-themeattributelightかdark
<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>HTTP/1.1 200 OKContent-Type: text/javascript; charset=utf-8Cache-Control: public, max-age=86400Access-Control-Allow-Origin: *リンクページ
GET /@{handle}
その人が載せたリンクの一覧を、アカウントのない人にも見せるページです。リンクはタップの回数を数えるため /l/… を通ります。
パラメーター
handlestring必須- ユーザーネーム(パスの中)
返すもの
リンクページの HTML(og:type は profile)。
curl https://crowon.app/@mika.sato<meta property="og:site_name" content="CrowOn"><meta property="og:type" content="profile"><meta property="og:title" content="Mika Sato(@mika.sato)"><meta property="og:description" content="Photos from walks around the city."><meta property="og:url" content="https://crowon.app/@mika.sato"><meta name="twitter:card" content="summary">