ウェブサイトのクロールをプレビュー
ウェブサイトソースをクロールし、見つかったページを選択できるように一時保存します。インポートは行わず、実行を返します。state が preview_ready、zero_results、failed、canceled のいずれかになるまで、その id で ソースの実行を取得 をポーリングしてください。
その後、クロールプレビューのページ一覧を取得 でページを一覧表示し、必要なページを 選択したページをインポート でインポートします。
ソースは web ソースである必要があります。クロールされるページ数は、ソースのクロール設定に従います。クロール結果が 1,000 ページを超えると失敗するため、先にクロール設定で範囲を絞り込んでください。
プレビューは、インポートするか ソースの実行をキャンセル でキャンセルするまで、ソースのアクティブな実行として扱われます。インポートしないプレビューはキャンセルしてください。プレビューを開始する前に、ソースのほかの実行が終わるのを待ってください。
プレビューとインポートの流れについては、ウェブサイトのページのインポート を参照してください。
curl --request POST \
--url https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}/crawl-preview \
--header 'Authorization: Bearer <token>' \
--header 'Idempotency-Key: <idempotency-key>'import requests
url = "https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}/crawl-preview"
headers = {
"Idempotency-Key": "<idempotency-key>",
"Authorization": "Bearer <token>"
}
response = requests.post(url, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Idempotency-Key': '<idempotency-key>', Authorization: 'Bearer <token>'}
};
fetch('https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}/crawl-preview', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}/crawl-preview",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Idempotency-Key: <idempotency-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}/crawl-preview"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}/crawl-preview")
.header("Idempotency-Key", "<idempotency-key>")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}/crawl-preview")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"canceled_at": null,
"checkpoint": "queued",
"completed_at": null,
"created_at": "2026-10-20T10:00:00Z",
"cursor": null,
"execution_attempts": 0,
"failure": null,
"id": "e1f2a3b4-c5d6-4e7f-8a9b-0c1d2e3f4a5b",
"kind": "crawl-preview",
"knowledge_space_id": "0a9d3c2e-5b6f-4e1a-8c7d-2f3e4a5b6c7d",
"last_error_code": null,
"max_execution_attempts": 5,
"progress_completed": 0,
"progress_failed": 0,
"progress_skipped": 0,
"progress_total": null,
"source_id": "6f1c2b0e-3d0b-4a5e-9f4c-1c0e6a7b8d90",
"state": "queued",
"updated_at": "2026-10-20T10:00:00Z"
}Authorizations
すべてのリクエストは、Authorization: Bearer {API_KEY} ヘッダーに指定した API キーで認証します。アプリのエンドポイントにはアプリの API キーを、ナレッジのエンドポイントにはナレッジベースの API キーを使用します(Dify API クイックスタート)。
キーはサーバーサイドで保管し、クライアントコードには決して埋め込まないでください。キーがない、または無効な場合は HTTP 401(unauthorized)が返ります。
Headers
Response
kind: crawl-preview、state: queued の実行です。
実行が到達した最後のステップで、queued、provider-read、preview-staged、selection-frozen、materialized、cleanup-staging、source-committed のいずれかです。ソースの実行を再試行 は、チェックポイントにかかわらず実行を最初からやり直します。
ワーカーが実行を取得した回数です。ソースの実行を再試行 の後の取得も含み、再試行してもリセットされません。
実行 ID です。ソースの実行を取得、ソースの実行をキャンセル、ソースの実行を再試行 に渡します。
実行の処理内容です:
sync:ソースを同期、ソースを更新、スケジュール、または Dify によって開始されます。crawl-preview:ウェブサイトのクロールをプレビュー によって開始されます。選択したページをインポート がこの実行からインポートしている間も、種類は変わりません。crawl-import:ウェブサイトのページをインポート によって開始されます。online-document-import、online-drive-import:ソースのアイテムをインポート によって開始されます。
Dify でソースを追加または編集した場合も、Dify がプレビューとインポートを開始します。
execution_attempts の上限です。上限に達すると、ソースの実行を再試行 は 409 を返します。
実行が処理する予定のアイテム数です。インポートではリクエストされたページまたはアイテム、クロールプレビューではこれまでに一時保存されたページ、同期では一覧の取得後のソースのアイテムを数えます。判明するまでは null です。
ウェブサイトのページをインポート の実行が URL をクロールしている間は、progress_completed と progress_total のどちらも、それまでにクロールしたページ数を数えます。すべての URL のクロールが終わると、URL の数を総数として 0 から数え直します。
実行の進行状況です。
進行中の状態:
queued:ワーカー待ちcrawling:クロールプレビューによるページの取得中preview_ready:クロールプレビューが 選択したページをインポート または ソースの実行をキャンセル を待機中importing:アイテムのインポートとインデックス処理中syncing:ソースのドキュメントを更新中
最終状態:
completed:すべてのアイテムのインポートまたは更新、インデックス処理、アクティブ化が完了zero_results:クロールプレビューで見つかったページが 0 件failed:failureを参照canceled
failed または canceled の後は、ソースの実行を再試行 で再実行でき、ソースを同期 で新しい同期を開始できます。
Was this page helpful?
curl --request POST \
--url https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}/crawl-preview \
--header 'Authorization: Bearer <token>' \
--header 'Idempotency-Key: <idempotency-key>'import requests
url = "https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}/crawl-preview"
headers = {
"Idempotency-Key": "<idempotency-key>",
"Authorization": "Bearer <token>"
}
response = requests.post(url, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Idempotency-Key': '<idempotency-key>', Authorization: 'Bearer <token>'}
};
fetch('https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}/crawl-preview', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}/crawl-preview",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Idempotency-Key: <idempotency-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}/crawl-preview"
req, _ := http.NewRequest("POST", url, nil)
req.Header.Add("Idempotency-Key", "<idempotency-key>")
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}/crawl-preview")
.header("Idempotency-Key", "<idempotency-key>")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://{api_base_url}/knowledge-fs/spaces/{knowledge_base_id}/sources/{source_id}/crawl-preview")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Idempotency-Key"] = '<idempotency-key>'
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"canceled_at": null,
"checkpoint": "queued",
"completed_at": null,
"created_at": "2026-10-20T10:00:00Z",
"cursor": null,
"execution_attempts": 0,
"failure": null,
"id": "e1f2a3b4-c5d6-4e7f-8a9b-0c1d2e3f4a5b",
"kind": "crawl-preview",
"knowledge_space_id": "0a9d3c2e-5b6f-4e1a-8c7d-2f3e4a5b6c7d",
"last_error_code": null,
"max_execution_attempts": 5,
"progress_completed": 0,
"progress_failed": 0,
"progress_skipped": 0,
"progress_total": null,
"source_id": "6f1c2b0e-3d0b-4a5e-9f4c-1c0e6a7b8d90",
"state": "queued",
"updated_at": "2026-10-20T10:00:00Z"
}