チャンク一覧を取得
ドキュメント内のチャンクのページネーションリストを返します。任意でキーワードまたはインデックスステータスでフィルタリングできます。
1 min read
get/datasets/{dataset_id}/documents/{document_id}/segments
Request example
curl --request GET \
--url https://api.dify.ai/v1/datasets/{dataset_id}/documents/{document_id}/segments \
--header 'Authorization: Bearer <token>'import requests
url = "https://api.dify.ai/v1/datasets/{dataset_id}/documents/{document_id}/segments"
headers = {
"Authorization": "Bearer <token>",
}
response = requests.request("GET", url, headers=headers)
print(response.text)const response = await fetch('https://api.dify.ai/v1/datasets/{dataset_id}/documents/{document_id}/segments', {
method: 'GET',
headers: {
'Authorization': 'Bearer <token>'
}
});
const data = await response.json();
console.log(data);<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://api.dify.ai/v1/datasets/{dataset_id}/documents/{document_id}/segments',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => [
'Authorization: Bearer <token>',
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;package main
import (
"fmt"
"io"
"net/http"
)
func main() {
url := "https://api.dify.ai/v1/datasets/{dataset_id}/documents/{document_id}/segments"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.dify.ai/v1/datasets/{dataset_id}/documents/{document_id}/segments"))
.header("Authorization", "Bearer <token>")
.method("GET", HttpRequest.BodyPublishers.noBody())
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());require 'uri'
require 'net/http'
url = URI('https://api.dify.ai/v1/datasets/{dataset_id}/documents/{document_id}/segments')
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = url.scheme == 'https'
request = Net::HTTP::Get.new(url)
request['Authorization'] = 'Bearer <token>'
response = http.request(request)
puts response.read_bodyResponse
{
"data": [
{
"answer": "",
"attachments": [],
"child_chunks": [],
"completed_at": 1741267200,
"content": "Dify is an open-source LLM app development platform.",
"created_at": 1741267200,
"created_by": "ad313dd6-ef04-4dd1-a5b0-c0f0b9e2e7e4",
"disabled_at": null,
"disabled_by": null,
"document_id": "a8e0e5b5-78c6-4130-a5ce-25feb0e0b4ac",
"enabled": true,
"error": null,
"hit_count": 0,
"id": "f3d1c7be-9f3a-40d8-8eb8-3a1ef9c3f2c1",
"index_node_hash": "abc123def456",
"index_node_id": "a1b2c3d4-e5f6-7890-abcd-000000000001",
"indexing_at": 1741267200,
"keywords": [
"dify",
"platform",
"llm"
],
"position": 1,
"sign_content": "",
"status": "completed",
"stopped_at": null,
"summary": null,
"tokens": 12,
"updated_at": 1741267200,
"updated_by": "ad313dd6-ef04-4dd1-a5b0-c0f0b9e2e7e4",
"word_count": 9
}
],
"doc_form": "text_model",
"has_more": false,
"limit": 20,
"page": 1,
"total": 1
}{
"code": "provider_not_initialize",
"message": "No Embedding Model available. Please configure a valid provider in the Settings -> Model Provider.",
"status": 400
}{
"code": "forbidden",
"message": "Dataset api access is not enabled.",
"status": 403
}{
"code": "forbidden",
"message": "The API key is not authorized to access this knowledge base.",
"status": 403
}{
"code": "not_found",
"message": "Dataset not found.",
"status": 404
}{
"code": "not_found",
"message": "Document not found.",
"status": 404
}get/datasets/{dataset_id}/documents/{document_id}/segments
Authorization
すべてのリクエストは API キーで認証します:Authorization: Bearer {API_KEY}。アプリのエンドポイントにはアプリの API キーを、ナレッジのエンドポイントにはナレッジベースの API キーを使用します(Dify API クイックスタート)。
キーはサーバーサイドで保管し、クライアントコードには決して埋め込まないでください。キーが欠落または無効なリクエストは HTTP 401(unauthorized)で失敗します。
Path parameters
ナレッジベース ID。ナレッジベースリストを取得 で取得します。スコープを限定したキーでは、Dify の URL から ID をコピー してください。
ドキュメント ID です。ナレッジベースのドキュメントリストを取得 から取得します。
Query parameters
インデックスステータスでチャンクをフィルタリングします(例:
completed、indexing、error)。検索キーワードです。
Responses
application/json
チャンクのリストです。
チャンクのリスト。
Show child attributesHide child attributes
回答コンテンツです。Q&A モードのドキュメントで使用されます。
このチャンクに添付されたファイルです。
このチャンクに属する子チャンクです。階層モードのドキュメントにのみ存在します。
Show child attributesHide child attributes
子チャンクのテキスト内容です。
作成タイムスタンプ(Unix エポック、秒単位)です。
子チャンクの一意識別子です。
親チャンク内の子チャンクの位置です。
この子チャンクが属する親チャンクの ID です。
子チャンクの作成方法です。API から作成または更新された子チャンクは常に
customized です。システム生成の子チャンクは automatic です。最終更新タイムスタンプ(Unix エポック、秒単位)です。
子チャンク内容の単語数です。
インデックス作成が完了したタイムスタンプです。まだ完了していない場合は
null です。チャンクのテキスト内容です。
作成タイムスタンプ(Unix エポック、秒単位)です。
チャンクを作成したユーザーの ID です。
チャンクが無効化されたタイムスタンプです。有効な場合は
null です。チャンクを無効化したユーザーの ID です。有効な場合は
null です。このチャンクが属するドキュメントの ID です。
このチャンクが検索に対して有効かどうかです。
インデックス作成が失敗した場合のエラーメッセージです。エラーなしの場合は
null です。このチャンクが検索クエリでマッチした回数です。
チャンクの一意識別子です。
インデックスされたコンテンツのハッシュです。変更の検出に使用されます。
ベクトルストア内のインデックスノードの ID です。
インデックス作成が開始されたタイムスタンプです。まだ開始されていない場合は
null です。キーワードベースの検索のためにこのチャンクに関連付けられたキーワードです。
ドキュメント内のチャンクの位置。
整合性検証用の署名付きコンテンツハッシュです。
チャンクの現在のインデックスステータスです(例:
completed、indexing、error)。インデックス作成が停止されたタイムスタンプです。停止されていない場合は
null です。AI が生成したチャンクコンテンツの要約です。要約インデックスが有効でない場合は
null です。チャンク内容のトークン数です。
最終更新タイムスタンプ(Unix エポック、秒単位)です。
このチャンクを最後に更新したユーザーの ID です。
チャンク内容の単語数です。
このドキュメントが使用するドキュメントチャンキングモードです。
次のページにさらに項目が存在するかどうかです。
1 ページあたりの件数です。
現在のページ番号です。
一致するチャンクの合計数です。