为以下对象创建源连接和数据流 Mixpanel 使用 Flow Service API
以下教程将指导您完成创建源连接和要引入的数据流的步骤 Mixpanel 使用将数据发送到Adobe Experience Platform 流服务API.
快速入门
本指南要求您对 Experience Platform 的以下组件有一定了解:
以下部分提供成功连接时需要了解的其他信息 Mixpanel 使用 Flow Service API。
收集所需的凭据
为了连接 Mixpanel 到Platform时,必须提供以下连接属性的值:
password
dLlidiKHpCZtJhQDyN2RECKudMeTItX1
有关验证您的身份的详细信息 Mixpanel 源,请参见 Mixpanel 源概述.
创建基本连接 base-connection
基本连接会保留您的源和平台之间的信息,包括源的身份验证凭据、连接的当前状态以及唯一的基本连接ID。 基本连接ID允许您浏览和浏览源中的文件,并标识要摄取的特定项目,包括有关其数据类型和格式的信息。
POST要创建基本连接ID,请向 /connections
端点,同时提供 Mixpanel 作为请求正文一部分的身份验证凭据。
API格式
POST /connections
请求
以下请求为创建基本连接 Mixpanel:
curl -X POST \
'https://platform.adobe.io/data/foundation/flowservice/connections' \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H 'x-sandbox-name: {SANDBOX_NAME}' \
-H 'Content-Type: application/json' \
-d '{
"name": "Mixpanel base connection",
"description": "Mixpanel base connection to authenticate to Platform",
"connectionSpec": {
"id": "fd2c8ff3-1de0-4f6b-8fa8-4264784870eb",
"version": "1.0"
},
"auth": {
"specName": "Basic Authentication",
"params": {
"username": "{USERNAME}",
"password": "{PASSWORD}"
}
}
}'
name
description
connectionSpec.id
auth.specName
auth.params.
auth.params.username
auth.params.password
响应
成功的响应会返回新创建的基本连接,包括其唯一连接标识符(id
)。 在下一步中浏览源的文件结构和内容时,需要此ID。
{
"id": "70383d02-2777-4be7-a309-9dd6eea1b46d",
"etag": "\"d64c8298-add4-4667-9a49-28195b2e2a84\""
}
浏览您的源 explore
使用在上一步中生成的基本连接ID,可以通过执行GET请求来浏览文件和目录。
使用以下调用查找要引入Experience Platform的文件的路径:
API格式
GET /connections/{BASE_CONNECTION_ID}/explore?objectType=rest&object={OBJECT}&fileType={FILE_TYPE}&preview={PREVIEW}&sourceParams={SOURCE_PARAMS}
执行GET请求以浏览源的文件结构和内容时,必须包括下表列出的查询参数:
{BASE_CONNECTION_ID}
objectType=rest
rest
.{OBJECT}
json
.fileType=json
json
是唯一支持的文件类型。{PREVIEW}
{SOURCE_PARAMS}
{SOURCE_PARAMS}
,则必须对整个 {"projectId":"2671127","timezone":"Pacific Standard Time"}
base64中的字符串。 注意:在以下示例中, "{"projectId":"2671127","timezone":"Pacific Standard Time"}"
以base64编码等于 eyJwcm9qZWN0SWQiOiIyNjcxMTI3IiwidGltZXpvbmUiOiJQYWNpZmljIFN0YW5kYXJkIFRpbWUifQ==
.请求
curl -X GET \
'https://platform.adobe.io/data/foundation/flowservice/connections/70383d02-2777-4be7-a309-9dd6eea1b46d/explore?objectType=rest&object=json&fileType=json&preview=true&sourceParams=eyJsaXN0SWQiOiIxMGMwOTdjYTcxIn0=' \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H 'x-sandbox-name: {SANDBOX_NAME}'
响应
成功的响应将返回查询文件的结构。
{
"format": "hierarchical",
"schema": {
"type": "object",
"properties": {
"event": {
"type": "string"
},
"properties": {
"type": "object",
"properties": {
"$mp_api_endpoint": {
"type": "string"
},
"$insert_id": {
"type": "string"
},
"item_id": {
"type": "string"
},
"distinct_id": {
"type": "string"
},
"$mp_api_timestamp_ms": {
"type": "integer",
"minimum": -9007199254740992,
"maximum": 9007199254740991
},
"item_price": {
"type": "string"
},
"$import": {
"type": "boolean"
},
"item_name": {
"type": "string"
},
"time": {
"type": "integer",
"minimum": -9007199254740992,
"maximum": 9007199254740991
},
"mp_processing_time_ms": {
"type": "integer",
"minimum": -9007199254740992,
"maximum": 9007199254740991
}
}
}
}
},
"data": [
{
"event": "Items purchased",
"properties": {
"time": 1652825148,
"distinct_id": "test@test.com",
"$insert_id": "935d87b1-00cd-41b7-be34-b9d98dd08b70",
"$mp_api_endpoint": "api.mixpanel.com",
"$mp_api_timestamp_ms": 1652850348643,
"item_id": "29066",
"item_name": "charger",
"item_price": "800.00",
"mp_processing_time_ms": 1652850348702
}
},
{
"event": "Items sold",
"properties": {
"time": 1652423938,
"distinct_id": "test@test.com",
"$insert_id": "935d87b1-00cd-41b7-be34-b9d98dd08b70",
"$mp_api_endpoint": "api.mixpanel.com",
"$mp_api_timestamp_ms": 1652449138115,
"item_id": "29036",
"item_name": "chair",
"item_price": "5000.00",
"mp_processing_time_ms": 1652449138173
}
},
{
"event": "Items sold",
"properties": {
"time": 1652854256,
"distinct_id": "test@test.com",
"$insert_id": "935d87b1-00cd-41b7-be34-b9d98dd08b70",
"$mp_api_endpoint": "api.mixpanel.com",
"$mp_api_timestamp_ms": 1652879456538,
"item_id": "29066",
"item_name": "mobile",
"item_price": "7000.00",
"mp_processing_time_ms": 1652879456604
}
},
{
"event": "Sign off",
"properties": {
"time": 1648140611,
"distinct_id": "test@test.com",
"$insert_id": "935d87b1-00cd-41b7-be34-b9d98dd08b75",
"$mp_api_endpoint": "api.mixpanel.com",
"$mp_api_timestamp_ms": 1648555709515,
"item_id": "29073",
"item_name": "Watch",
"item_price": "50000.00",
"mp_processing_time_ms": 1648555710375
}
},
{
"event": "Items sold",
"properties": {
"time": 1648140612,
"distinct_id": "test@test.com",
"$insert_id": "935d87b1-00cd-41b7-be34-b9d98dd08b75",
"$mp_api_endpoint": "api.mixpanel.com",
"$mp_api_timestamp_ms": 1648556481708,
"item_id": "29073",
"item_name": "Pen",
"item_price": "1000.00",
"mp_processing_time_ms": 1648556481880
}
},
{
"event": "Sign in",
"properties": {
"time": 1648140614,
"distinct_id": "test1@test.com",
"$import": true,
"$insert_id": "935d87b1-00cd-41b7-be34-b9d98dd08b75",
"$mp_api_endpoint": "api.mixpanel.com",
"$mp_api_timestamp_ms": 1648556032401,
"item_id": "29073",
"item_name": "Watch",
"item_price": "50000.00",
"mp_processing_time_ms": 1648556032462
}
},
{
"event": "Item Purchased",
"properties": {
"time": 1648165814,
"distinct_id": "test1@test.com",
"$insert_id": "935d87b1-00cd-41b7-be34-b9d98dd08b74",
"$mp_api_endpoint": "api.mixpanel.com",
"$mp_api_timestamp_ms": 1648480684785,
"item_id": "29073",
"item_name": "Watch",
"item_price": "50000.00",
"mp_processing_time_ms": 1648480685058
}
},
{
"event": "Item Purchased",
"properties": {
"time": 1648165814,
"distinct_id": "test1@test.com",
"$insert_id": "935d87b1-00cd-41b7-be34-b9d98dd08b75",
"$mp_api_endpoint": "api.mixpanel.com",
"$mp_api_timestamp_ms": 1648551687866,
"item_id": "29073",
"item_name": "Watch",
"item_price": "50000.00",
"mp_processing_time_ms": 1648551687922
}
},
{
"event": "Sign off",
"properties": {
"time": 1648530419,
"distinct_id": "test1@test.com",
"$insert_id": "935d87b1-00cd-41b7-be34-b9d98dd08b75",
"$mp_api_endpoint": "api.mixpanel.com",
"$mp_api_timestamp_ms": 1648555619274,
"item_id": "29073",
"item_name": "Watch",
"item_price": "50000.00",
"mp_processing_time_ms": 1648555619326
}
},
{
"event": "Items sold",
"properties": {
"time": 1648566534,
"distinct_id": "test1@test.com",
"$import": true,
"$insert_id": "935d87b1-00cd-41b7-be34-b9d98dd08b75",
"$mp_api_endpoint": "api.mixpanel.com",
"$mp_api_timestamp_ms": 1648635830114,
"item_id": "29073",
"item_name": "Pen",
"item_price": "1000.00",
"mp_processing_time_ms": 1648635831010
}
}
]
}
创建源连接 source-connection
您可以通过向以下对象发出POST请求来创建源连接: Flow Service API。 源连接由连接ID、源数据文件的路径以及连接规范ID组成。
API格式
POST /sourceConnections
请求
以下请求为创建源连接 Mixpanel:
curl -X POST \
'https://platform.adobe.io/data/foundation/flowservice/sourceConnections' \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H 'x-sandbox-name: {SANDBOX_NAME}' \
-H 'Content-Type: application/json' \
-d '{
"name": "Mixpanel source connection",
"description": "Mixpanel source connection",
"baseConnectionId": "70383d02-2777-4be7-a309-9dd6eea1b46d",
"connectionSpec": {
"id": "fd2c8ff3-1de0-4f6b-8fa8-4264784870eb",
"version": "1.0"
},
"data": {
"format": "json"
},
"params": {
"projectId": "{PROJECT_ID}",
"timezone": "{TIMEZONE}"
}
}'
name
description
baseConnectionId
connectionSpec.id
data.format
json
.params.projectId
params.timezone
响应
成功的响应将返回唯一标识符(id
)。 此ID是稍后步骤创建数据流所必需的。
{
"id": "246d052c-da4a-494a-937f-a0d17b1c6cf5",
"etag": "\"712a8c08-fda7-41c2-984b-187f823293d8\""
}
创建目标XDM架构 target-schema
为了在Platform中使用源数据,必须创建目标架构,以根据您的需求构建源数据。 然后,使用目标架构创建包含源数据的Platform数据集。
可以通过向以下对象执行POST请求来创建目标XDM架构 架构注册表API.
有关如何创建目标XDM架构的详细步骤,请参阅关于的教程 使用API创建架构.
创建目标数据集 target-dataset
可以通过向执行POST请求来创建目标数据集 目录服务API,在有效负载中提供目标架构的ID。
有关如何创建目标数据集的详细步骤,请参阅关于的教程 使用API创建数据集.
创建目标连接 target-connection
目标连接表示与要存储所摄取数据的目标的连接。 要创建目标连接,您必须提供对应于数据湖的固定连接规范ID。 此ID为: c604ff05-7f1a-43c0-8e18-33bf874cb11c
.
现在,您拥有目标架构、目标数据集以及到数据湖的连接规范ID。 使用这些标识符,您可以使用 Flow Service 用于指定将包含入站源数据的数据集的API。
API格式
POST /targetConnections
请求
以下请求创建目标连接 Mixpanel:
curl -X POST \
'https://platform.adobe.io/data/foundation/flowservice/targetConnections' \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H 'x-sandbox-name: {SANDBOX_NAME}' \
-H 'Content-Type: application/json' \
-d '{
"name": "{Mixpanel} Target Connection",
"description": "{Mixpanel} Target Connection",
"connectionSpec": {
"id": "fd2c8ff3-1de0-4f6b-8fa8-4264784870eb",
"version": "1.0"
},
"data": {
"format": "json"
},
"params": {
"dataSetId": "5ef4551c52e054191a61a99f"
}
}'
name
description
connectionSpec.id
fd2c8ff3-1de0-4f6b-8fa8-4264784870eb
.data.format
params.dataSetId
响应
成功的响应将返回新目标连接的唯一标识符(id
)。 此ID在后续步骤中是必需的。
{
"id": "7c96c827-3ffd-460c-a573-e9558f72f263",
"etag": "\"a196f685-f5e8-4c4c-bfbd-136141bb0c6d\""
}
创建映射 mapping
要将源数据摄取到目标数据集中,必须首先将其映射到目标数据集所遵循的目标架构。 这可以通过向以下对象执行POST请求来实现 Data Prep API 请求有效负载中定义的数据映射。
API格式
POST /conversion/mappingSets
请求
curl -X POST \
'https://platform.adobe.io/data/foundation/conversion/mappingSets' \
-H 'Authorization: Bearer {ACCESS_TOKEN}' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H 'x-sandbox-name: {SANDBOX_NAME}' \
-H 'Content-Type: application/json' \
-d '{
"version": 0,
"xdmSchema": "https://ns.adobe.com/{TENANT_ID}/schemas/995dabbea86d58e346ff91bd8aa741a9f36f29b1019138d4",
"xdmVersion": "1.0",
"id": null,
"mappings": [
{
"sourceType": "ATTRIBUTE",
"source": "data.distinct_id",
"destination": "_extconndev.distinct_id",
"name": "distinct_id",
"description": "Mixpanel"
},
{
"sourceType": "ATTRIBUTE",
"source": "data.event_name",
"destination": "_extconndev.event_name"
},
{
"sourceType": "ATTRIBUTE",
"source": "data.import",
"destination": "_extconndev.import"
},
{
"sourceType": "ATTRIBUTE",
"source": "data.insert_id",
"destination": "_extconndev.insert_id"
},
{
"sourceType": "ATTRIBUTE",
"source": "data.item_id",
"destination": "_extconndev.item_id"
},
{
"sourceType": "ATTRIBUTE",
"source": "data.item_name",
"destination": "_extconndev.item_name"
},
{
"sourceType": "ATTRIBUTE",
"source": "data.item_price",
"destination": "_extconndev.item_price"
},
{
"sourceType": "ATTRIBUTE",
"source": "data.mp_api_endpoint",
"destination": "_extconndev.mp_api_endpoint"
},
{
"sourceType": "ATTRIBUTE",
"source": "data.mp_api_timestamp_ms",
"destination": "_extconndev.mp_api_timestamp_ms"
},
{
"sourceType": "ATTRIBUTE",
"source": "data.mp_processing_time_ms",
"destination": "_extconndev.mp_processing_time_ms"
},
{
"sourceType": "ATTRIBUTE",
"source": "data.time",
"destination": "_extconndev.time"
}
]
}'
xdmSchema
mappings.destinationXdmPath
mappings.sourceAttribute
mappings.identity
响应
成功响应将返回新创建映射的详细信息,包括其唯一标识符(id
)。 在后续步骤中需要使用此值来创建数据流。
{
"id": "bf5286a9c1ad4266baca76ba3adc9366",
"version": 0,
"createdDate": 1597784069368,
"modifiedDate": 1597784069368,
"createdBy": "{CREATED_BY}",
"modifiedBy": "{MODIFIED_BY}"
}
创建流 flow
从以下来源获取数据的最后一步 Mixpanel 到Platform就是创建数据流。 现在,您已准备以下必需值:
数据流负责从源中计划和收集数据。 您可以通过在有效负载中提供上述值时执行POST请求来创建数据流。
要计划摄取,您必须先将开始时间值设置为纪元时间(以秒为单位)。 然后,必须将频率值设置为五个选项之一: once
, minute
, hour
, day
,或 week
. 间隔值用于指定两次连续摄取之间的时间段,但是,创建一次性摄取不需要设置间隔。 对于所有其他频率,间隔值必须设置为等于或大于 15
.
API格式
POST /flows
请求
curl -X POST \
'https://platform.adobe.io/data/foundation/flowservice/flows' \
-H 'x-api-key: {API_KEY}' \
-H 'x-gw-ims-org-id: {ORG_ID}' \
-H 'x-sandbox-name: {SANDBOX_NAME}' \
-H 'Content-Type: application/json' \
-d '{
"name": "{Mixpanel} dataflow",
"description": "{Mixpanel} dataflow",
"flowSpec": {
"id": "6499120c-0b15-42dc-936e-847ea3c24d72",
"version": "1.0"
},
"sourceConnectionIds": [
"246d052c-da4a-494a-937f-a0d17b1c6cf5"
],
"targetConnectionIds": [
"7c96c827-3ffd-460c-a573-e9558f72f263"
],
"transformations": [
{
"name": "Mapping",
"params": {
"mappingId": "bf5286a9c1ad4266baca76ba3adc9366",
"mappingVersion": "0"
}
}
],
"scheduleParams": {
"startTime": "1625040887",
"frequency": "minute",
"interval": 15
}
}'
name
description
flowSpec.id
6499120c-0b15-42dc-936e-847ea3c24d72
.flowSpec.version
1.0
.sourceConnectionIds
targetConnectionIds
transformations
transformations.name
transformations.params.mappingId
transformations.params.mappingVersion
0
.scheduleParams.startTime
scheduleParams.frequency
once
, minute
, hour
, day
,或 week
.scheduleParams.interval
once
并且应大于或等于 15
其他频率值。响应
成功的响应会返回ID (id
)。 您可以使用此ID监视、更新或删除数据流。
{
"id": "993f908f-3342-4d9c-9f3c-5aa9a189ca1a",
"etag": "\"510bb1d4-8453-4034-b991-ab942e11dd8a\""
}
附录
以下部分提供了有关监视、更新和删除数据流的步骤的信息。
监测数据流
创建数据流后,您可以监视通过它摄取的数据,以查看有关流运行、完成状态和错误的信息。 有关完整的API示例,请阅读以下指南: 使用API监控源数据流.
更新您的数据流
通过向发出PATCH请求,更新数据流的详细信息,例如其名称和描述,以及其运行计划和关联的映射集。 /flows
端点 Flow Service API,同时提供数据流的ID。 发出PATCH请求时,必须提供数据流的唯一值 etag
在 If-Match
标题。 有关完整的API示例,请阅读以下指南: 使用API更新源数据流.
更新您的帐户
PATCH通过向 Flow Service API,同时将您的基本连接ID作为查询参数提供。 发出PATCH请求时,必须提供源帐户的唯一帐户 etag
在 If-Match
标题。 有关完整的API示例,请阅读以下指南: 使用API更新源帐户.
删除您的数据流
通过向以下对象执行DELETE请求来删除您的数据流: Flow Service API,同时提供您要作为查询参数的一部分删除的数据流的ID。 有关完整的API示例,请阅读以下指南: 使用API删除数据流.
删除您的帐户
向以下网站发出DELETE请求,删除您的帐户: Flow Service API,同时提供要删除帐户的基本连接ID。 有关完整的API示例,请阅读以下指南: 使用API删除源帐户.