- 開発者ホーム
- エディターの埋め込み
- 文書の比較
文書の比較
文書の比較
POST /api/v1/embed/compare は Word の「校閲 > 比較 > 文書の比較」と同じように 2 つの .docx 版を比較し、すべての差分を変更履歴(挿入と削除、作成者は options.author)として記録した変更後の文書と JSON の概要を返します。Word や埋め込みエディターで開けば変更ごとに承諾・拒否できます。output_format "json" なら概要だけを返します。
curl https://mroffice.ai/api/v1/embed/compare \
-H "Authorization: Bearer $MROFFICE_SECRET_KEY" \
-H "Content-Type: application/json" \
-d '{
"original": { "url": "https://files.example.com/signed/msa-v1.docx" },
"revised": { "url": "https://files.example.com/signed/msa-v2.docx" },
"options": { "author": "Legal review" }
}'- 両方の文書の既存の変更履歴はまず承諾済みとして扱います(Word も同じ確認をします)。
- 段落と表はテキストで対応付けます。元の文書にしかない段落は削除、変更後にしかない段落は挿入、その場で変わった段落は単語ごとに比較します(options.granularity "character" なら文字ごと)。
- 変わらない語と挿入された語は変更後の書式、削除された語は元の書式を保ちます。削除された画像は画像ごと引き継がれます。
- 表は行ごと・セルごとに比較し、片方にしかない行は挿入または削除された行です。
- 比較しないもの:書式だけの変更、移動(削除と挿入で表示)、ヘッダー、フッター、脚注、コメント。
| オプション | 意味 |
|---|---|
original, revised | { url | upload_id | data_base64, name? }、どちらも .docx。 |
options.author | 変更の作成者(既定 MR Office)。 |
options.date | 日付、ISO 8601(既定は現在)。 |
options.granularity | word(既定、Word と同じ)または character。 |
output_format | docx(既定)または json。 |
result.comparison は挿入と削除の数(と語数)を数え、各変更を位置付きで列挙します。ジョブには最初の 200 件、json 出力にはすべて(最大 1,000 件)が入ります。
"result": {
"filename": "msa-v2-comparison.docx",
"comparison": {
"identical": false,
"insertions": 4, "deletions": 3, "words_inserted": 11, "words_deleted": 7,
"author": "Legal review", "date": "2026-11-21T09:00:00Z", "granularity": "word",
"changes": [
{ "type": "replace", "location": "paragraph 3", "original_text": "30 days", "text": "45 days" },
{ "type": "delete", "location": "paragraph 9", "original_text": "This clause survives termination." },
{ "type": "insert", "location": "paragraph 12 (table row)", "text": "Support\tIncluded" }
],
"changes_truncated": false
}
}