搜尋會話
curl --request POST \
--url https://api.pathors.com/project/{projectId}/session/search \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"search_string": "<string>",
"limit": 123,
"offset": 123
}
'import requests
url = "https://api.pathors.com/project/{projectId}/session/search"
payload = {
"search_string": "<string>",
"limit": 123,
"offset": 123
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({search_string: '<string>', limit: 123, offset: 123})
};
fetch('https://api.pathors.com/project/{projectId}/session/search', 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.pathors.com/project/{projectId}/session/search",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'search_string' => '<string>',
'limit' => 123,
'offset' => 123
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.pathors.com/project/{projectId}/session/search"
payload := strings.NewReader("{\n \"search_string\": \"<string>\",\n \"limit\": 123,\n \"offset\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
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.pathors.com/project/{projectId}/session/search")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"search_string\": \"<string>\",\n \"limit\": 123,\n \"offset\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pathors.com/project/{projectId}/session/search")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"search_string\": \"<string>\",\n \"limit\": 123,\n \"offset\": 123\n}"
response = http.request(request)
puts response.read_body{
"results": [
{
"sessionId": "<string>",
"data": {},
"createdAt": "<string>",
"updatedAt": "<string>"
}
],
"pagination": {
"limit": 123,
"offset": 123,
"total": 123
}
}已棄用 API
搜尋會話
透過會話資料中的內容匹配來搜尋會話,包括變數和訊息。
POST
/
project
/
{projectId}
/
session
/
search
搜尋會話
curl --request POST \
--url https://api.pathors.com/project/{projectId}/session/search \
--header 'Authorization: <authorization>' \
--header 'Content-Type: application/json' \
--data '
{
"search_string": "<string>",
"limit": 123,
"offset": 123
}
'import requests
url = "https://api.pathors.com/project/{projectId}/session/search"
payload = {
"search_string": "<string>",
"limit": 123,
"offset": 123
}
headers = {
"Authorization": "<authorization>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: '<authorization>', 'Content-Type': 'application/json'},
body: JSON.stringify({search_string: '<string>', limit: 123, offset: 123})
};
fetch('https://api.pathors.com/project/{projectId}/session/search', 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.pathors.com/project/{projectId}/session/search",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'search_string' => '<string>',
'limit' => 123,
'offset' => 123
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.pathors.com/project/{projectId}/session/search"
payload := strings.NewReader("{\n \"search_string\": \"<string>\",\n \"limit\": 123,\n \"offset\": 123\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "<authorization>")
req.Header.Add("Content-Type", "application/json")
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.pathors.com/project/{projectId}/session/search")
.header("Authorization", "<authorization>")
.header("Content-Type", "application/json")
.body("{\n \"search_string\": \"<string>\",\n \"limit\": 123,\n \"offset\": 123\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.pathors.com/project/{projectId}/session/search")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = '<authorization>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"search_string\": \"<string>\",\n \"limit\": 123,\n \"offset\": 123\n}"
response = http.request(request)
puts response.read_body{
"results": [
{
"sessionId": "<string>",
"data": {},
"createdAt": "<string>",
"updatedAt": "<string>"
}
],
"pagination": {
"limit": 123,
"offset": 123,
"total": 123
}
}已棄用。 此端點已棄用,將於 2026-07-11 下架。在此之前仍可使用。請改用 V1 路徑—完整的新舊路徑對照見遷移指南。
基礎 URL
https://api.pathors.com
搜尋會話
POST /project/{projectId}/session/search
路徑參數
您的專案 ID
請求標頭
使用您的 Project API Key(以
sk_ 開頭)進行 Bearer 令牌認證。格式:Bearer {your-api-key}請求主體
要在會話資料中搜尋的字串。這將匹配所有會話內容,包括變數、訊息和其他儲存的資訊。
要返回的最大結果數。預設值:50
分頁時要跳過的結果數。預設值:0
回應
範例
請求
curl -X POST https://api.pathors.com/project/{projectId}/session/search \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"search_string": "王小明",
"limit": 10,
"offset": 0
}'
回應
{
"results": [
{
"sessionId": "user-123-session-456",
"data": {
"variables": {
"userName": "王小明",
"userRole": "admin"
},
"messages": [
{
"role": "user",
"content": "你好"
},
{
"role": "assistant",
"content": "您好,王小明!有什麼可以幫助您的嗎?"
}
]
},
"createdAt": "2024-01-15T10:30:00.000Z",
"updatedAt": "2024-01-15T10:35:00.000Z"
},
{
"sessionId": "user-456-session-789",
"data": {
"variables": {
"userName": "王小明",
"userRole": "user"
},
"messages": []
},
"createdAt": "2024-01-14T15:20:00.000Z",
"updatedAt": "2024-01-14T15:25:00.000Z"
}
],
"pagination": {
"limit": 10,
"offset": 0,
"total": 2
}
}
使用說明
- 搜尋字串: 搜尋區分大小寫,並匹配會話資料的整個 JSON 內容
- 排序: 結果按
updatedAt降冪排序(最新的在前) - 分頁: 使用
limit和offset來分頁瀏覽大量結果集 - 效能: 對於大型資料集,建議使用更具體的搜尋字串以提高查詢效能
錯誤回應
| 狀態碼 | 描述 |
|---|---|
| 400 | 缺少或無效的 search_string |
| 401 | 無效的認證 |
| 500 | 內部伺服器錯誤 |
{
"error": "search_string is required"
}
{
"error": {
"message": "Invalid authentication"
}
}
相關 API
⌘I
