在流量服務API中執行清單(GET)請求時,您可以使用查詢參數來排序和篩選回應。 本指南提供如何針對不同使用案例使用這些參數的參考資料。
您可以使用orderby
查詢參數來排序回應。 可在API中排序下列資源:
若要使用參數,必須將其值設定為您要排序的特定屬性(例如?orderby=name
)。 您可以在值的開頭加上升順序的加號(+
),或以下降順序的加號(-
)。 如果未提供排序前置詞,則清單預設會以升序排序。
GET /flows?orderby=name
GET /flows?orderby=-name
您也可以使用"and"符號(&
),將排序參數與篩選參數結合。
GET /flows?property=state==enabled&orderby=createdAt
您可以使用property
參數搭配機碼值運算式來篩選回應。 例如, ?property=id==12345
僅傳回其id
屬性恰好等於12345
的資源。
只要已知該屬性的有效路徑,則可通常對實體中的任何屬性套用篩選。
如果屬性嵌套在陣列項中,則必須將方括弧([]
)附加到路徑中的陣列。 如需範例,請參閱篩選陣列屬性的相關章節。
返回源表名為的所有源連 lead
接:
GET /sourceConnections?property=params.tableName==lead
傳回特定區段ID的所有流量:
GET /flows?property=transformations[].params.segmentSelectors.selectors[].value.id==5722a16f-5e1f-4732-91b6-3b03943f759a
若多個property
篩選器以"and"字元(&
)分隔,則可納入查詢中。 合併篩選器時會假設為AND關係,這表示實體必須滿足所有篩選器,才能將其納入回應中。
傳回區段ID的所有已啟用流程:
GET /flows?property=transformations[].params.segmentSelectors.selectors[].value.id==5722a16f-5e1f-4732-91b6-3b03943f759a&property=state==enabled
您可以將[]
附加至陣列屬性的名稱,以根據陣列內項目的屬性進行篩選。
與特定源連接關聯的返回流:
GET /flows?property=sourceConnectionIds[]==9874984,6980696
具有包含特定選擇器值ID之轉換的傳回流:
GET /flows?property=transformations[].params.segmentSelectors.selectors[].value.id==5722a16f-5e1f-4732-91b6-3b03943f759a
返回具有特定值的列的源 name
連接:
GET /sourceConnections?property=params.columns[].name==firstName
依區段ID篩選,以查找目的地的流程執行ID:
GET /runs?property=metrics.recordSummary.targetSummaries[].entitySummaries[].id==segment:068d6e2c-b546-4c73-bfb7-9a9d33375659
count
任何篩選查詢都可附加count
查詢參數,其值為true
,以傳回結果計數。 API回應包含count
屬性,其值代表篩選項目總數的計數。 此呼叫不會傳回實際篩選的項目。
返回系統中已啟用流的計數:
GET /flows?property=state==enabled&count=true
對上述查詢的回應如下所示:
{
"count": 95
}
根據要檢索的流服務實體,可以使用不同的屬性進行篩選。 下表劃分了篩選使用案例中常用的每個資源的根級別欄位。
connectionSpec
屬性 | 範例 |
---|---|
id |
/connectionSpecs?property=id==736873,9485095 |
name |
/connectionSpecs?property=name==TestConn |
providerId |
/connectionSpecs?property=providerId==3897933 |
attributes.{ATTRIBUTE_NAME} |
/connectionSpecs?property=attributes.sampleAttribute="abc" |
flowSpec
屬性 | 範例 |
---|---|
id |
/flowSpecs?property=id==736873,9485095 |
name |
/flowSpecs?property=name==TestConn |
providerId |
/flowSpecs?property=providerId==3897933 |
connection
屬性 | 範例 |
---|---|
id |
/connections?property=id==736873,9485095 |
name |
/connections?property=name==TestConn |
description |
/connections?property=description==Test%20description |
connectionSpec.id |
/connections?property=connectionSpec.id==938903,849048 |
state |
/connections?property=state==enabled |
sourceConnection
屬性 | 範例 |
---|---|
id |
/sourceConnections?property=id==736873,9485095 |
connectionSpec.id |
/sourceConnections?property=connectionSpec.id==938903,849048 |
baseConnectionId |
/sourceConnections?property=baseConnectionId==983908,4908095 |
targetConnection
屬性 | 範例 |
---|---|
id |
/targetConnections?property=id==736873,9485095 |
connectionSpec.id |
/targetConnections?property=connectionSpec.id==938903,849048 |
baseConnectionId |
/targetConnections?property=baseConnectionId==983908,4908095 |
flow
屬性 | 範例 |
---|---|
id |
/flows?property=id==736873,9485095 |
name |
/flows?property=name==TestFlow |
description |
/flows?property=description==Test%20description |
flowSpec.id |
/flows?property=flowSpec.id==938903,849048 |
state |
/flows?property=state==enabled |
sourceConnectionIds |
/flows?property=sourceConnectionIds[]==9874984,6980696 |
targetConnectionIds |
/flows?property=targetConnectionIds[]==598590,690666 |
run
屬性 | 範例 |
---|---|
id |
/runs?property=id==736873,9485095 |
flowId |
/runs?property=flowId==8749844 |
state |
/runs?property=state==inProgress |
本指南說明如何使用orderby
和property
查詢參數來排序和篩選流量服務API中的回應。 如需如何在Platform中使用API進行常見工作流程的逐步指南,請參閱sources和destinations檔案中的API教學課程。