コンテンツにスキップ

ドキュメントの内容を取得する

GET /documents/{document_id}/contents/

Retrieve contents of a document by its ID.

Returns the content of the document with the specified ID, along with the index of the latest retrieved chunk. Each call fetches up to 20 chunks. To get more, use the end_chunk value from the response as the start_chunk for the next call.

Parameter In Type Required Description
document_id path integer yes The ID of the document to retrieve contents for.
start_chunk query integer Indicate the starting chunk that you want to retrieve. If not specified, the default value is 0.
end_chunk query integer Indicate the ending chunk that you want to retrieve. If not specified, the default value is start_chunk + 20.

Responses

  • 200 — Content of the document and index of the latest retrieved chunk.
  • 404 — Document not found.
  • 500 — Internal server error.

例のリクエスト

curl -X GET   
  "https://api.rememberizer.ai/api/v1/documents/12345/contents/?start_chunk=0&end_chunk=20"   
  -H "Authorization: Bearer YOUR_JWT_TOKEN"

Info

YOUR_JWT_TOKEN を実際のJWTトークンに、12345 を実際のドキュメントIDに置き換えてください。

const getDocumentContents = async (documentId, startChunk = 0, endChunk = 20) => {
  const url = new URL(`https://api.rememberizer.ai/api/v1/documents/${documentId}/contents/`);
  url.searchParams.append('start_chunk', startChunk);
  url.searchParams.append('end_chunk', endChunk);

  const response = await fetch(url.toString(), {
    method: 'GET',
    headers: {
      'Authorization': 'Bearer YOUR_JWT_TOKEN'
    }
  });

  const data = await response.json();
  console.log(data);

  // さらにチャンクがある場合は、それを取得できます
  if (data.end_chunk < totalChunks) {
    // 次のチャンクセットを取得
    await getDocumentContents(documentId, data.end_chunk, data.end_chunk + 20);
  }
};

getDocumentContents(12345);

Info

YOUR_JWT_TOKEN を実際のJWTトークンに、12345 を実際のドキュメントIDに置き換えてください。

import requests

def get_document_contents(document_id, start_chunk=0, end_chunk=20):
    headers = {
        "Authorization": "Bearer YOUR_JWT_TOKEN"
    }

    params = {
        "start_chunk": start_chunk,
        "end_chunk": end_chunk
    }

    response = requests.get(
        f"https://api.rememberizer.ai/api/v1/documents/{document_id}/contents/",
        headers=headers,
        params=params
    )

    data = response.json()
    print(data)

    # さらにチャンクがある場合は、それを取得できます
    # これは単純な例です - 適切な再帰チェックを実装することをお勧めします
    if 'end_chunk' in data and data['end_chunk'] < total_chunks:
        get_document_contents(document_id, data['end_chunk'], data['end_chunk'] + 20)

get_document_contents(12345)

Info

YOUR_JWT_TOKEN を実際のJWTトークンに、12345 を実際のドキュメントIDに置き換えてください。

パスパラメータ

パラメータ タイプ 説明
document_id 整数 必須。 コンテンツを取得するためのドキュメントのID。

クエリパラメータ

パラメータ タイプ 説明
start_chunk 整数 開始チャンクインデックス。デフォルトは0です。
end_chunk 整数 終了チャンクインデックス。デフォルトはstart_chunk + 20です。

レスポンスフォーマット

{
  "content": "ドキュメントチャンクの完全なテキストコンテンツ...",
  "end_chunk": 20
}

エラー応答

ステータスコード 説明
404 ドキュメントが見つかりません
500 サーバー内部エラー

大きなドキュメントのページネーション

大きなドキュメントの場合、コンテンツはチャンクに分割されます。複数のリクエストを行うことで、完全なドキュメントを取得できます:

  1. start_chunk=0で初期リクエストを行います
  2. 戻されたend_chunk値を次のリクエストのstart_chunkとして使用します
  3. すべてのチャンクを取得するまで続けます

このエンドポイントはドキュメントの生のテキストコンテンツを返し、詳細な処理や分析のために完全な情報にアクセスできるようにします。