[Beta 版]{class="badge informative"}
为创建流源连接和数据流 Shopify 使用流量服务API的数据
以下教程提供了有关如何创建流源连接和数据流以从中流式传输数据的步骤 Shopify 到Adobe Experience Platform,使用 Flow Service API.
快速入门 getting-started
本指南要求您对 Experience Platform 的以下组件有一定了解:
使用平台API
有关如何成功调用Platform API的信息,请参阅 Platform API快速入门.
流 Shopify 使用流服务API将数据发送到Platform
下面概述了创建源连接和数据流所需的步骤 Shopify 数据到Platform。
创建源连接 source-connection
通过向发出POST请求来创建源连接 Flow Service API,同时提供源的连接规范ID、名称和描述等详细信息以及数据的格式。
API格式
POST /sourceConnections
请求
以下请求为创建源连接 YOURSOURCE:
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": "Shopify Streaming Source Connection",
"providerId": "521eee4d-8cbe-4906-bb48-fb6bd4450033",
"description": "Shopify Streaming Source Connection",
"connectionSpec": {
"id": "e77fd9d2-22a8-11ed-861d-0242ac120002",
"version": "1.0"
},
"data": {
"format": "json"
}
}'
name
description
connectionSpec.id
data.format
json
.响应
成功的响应将返回唯一标识符(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
请求
以下请求创建目标连接 Shopify:
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": "Shopify Streaming Target Connection",
"description": "Shopify Streaming Target Connection",
"connectionSpec": {
"id": "c604ff05-7f1a-43c0-8e18-33bf874cb11c",
"version": "1.0"
},
"data": {
"format": "json",
"schema": {
"id": "{TARGET_XDM_SCHEMA}",
"version": "application/vnd.adobe.xed-full+json;version=1"
}
},
"params": {
"dataSetId": "{TARGET_DATASET}"
}
}'
name
description
connectionSpec.id
c604ff05-7f1a-43c0-8e18-33bf874cb11c
.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/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": "{TARGET_XDM_SCHEMA}",
"xdmVersion": "1.0",
"mappings": [
{
"destinationXdmPath": "person.name.firstName",
"sourceAttribute": "firstName",
"identity": false,
"version": 0
},
{
"destinationXdmPath": "person.name.lastName",
"sourceAttribute": "lastName",
"identity": false,
"version": 0
}
]
}'
xdmSchema
mappings.destinationXdmPath
mappings.sourceAttribute
mappings.identity
响应
成功响应将返回新创建映射的详细信息,包括其唯一标识符(id
)。 在后续步骤中需要使用此值来创建数据流。
{
"id": "bf5286a9c1ad4266baca76ba3adc9366",
"version": 0,
"createdDate": 1597784069368,
"modifiedDate": 1597784069368,
"createdBy": "{CREATED_BY}",
"modifiedBy": "{MODIFIED_BY}"
}
创建流 flow
从以下来源获取数据的最后一步 Shopify 到Platform就是创建数据流。 现在,您已准备以下必需值:
数据流负责从源中计划和收集数据。 您可以通过在有效负载中提供上述值时执行POST请求来创建数据流。
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": "Shopify Streaming Dataflow",
"description": "Shopify Streaming Dataflow",
"flowSpec": {
"id": "e77fde5a-22a8-11ed-861d-0242ac120002",
"version": "1.0"
},
"sourceConnectionIds": [
"246d052c-da4a-494a-937f-a0d17b1c6cf5"
],
"targetConnectionIds": [
"7c96c827-3ffd-460c-a573-e9558f72f263"
],
"transformations": [
{
"name": "Mapping",
"params": {
"mappingId": "bf5286a9c1ad4266baca76ba3adc9366",
"mappingVersion": 0
}
}
]
}'
name
description
flowSpec.id
e77fde5a-22a8-11ed-861d-0242ac120002
.flowSpec.version
1.0
.sourceConnectionIds
targetConnectionIds
transformations
transformations.name
transformations.params.mappingId
transformations.params.mappingVersion
0
.响应
成功的响应会返回ID (id
)。 您可以使用此ID监视、更新或删除数据流。
{
"id": "993f908f-3342-4d9c-9f3c-5aa9a189ca1a",
"etag": "\"510bb1d4-8453-4034-b991-ab942e11dd8a\""
}
获取您的流端点URL
创建数据流后,您现在可以检索流端点URL。 您将使用此端点URL将源订阅到webhook,从而允许源与Experience Platform通信。
GET要检索您的流端点URL,请向 /flows
端点并提供数据流的ID。
API格式
GET /flows/{FLOW_ID}
请求
curl -X GET \
'https://platform.adobe.io/data/foundation/flowservice/flows/993f908f-3342-4d9c-9f3c-5aa9a189ca1a' \
-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}'
响应
成功的响应会返回有关数据流的信息,包括标记为的端点URL inletUrl
.
{
"header":{
"xactionId":"1658464615769:0062:161",
"source":{
"name":"shopify"
},
"sandboxId":"d537df80-c5d7-11e9-aafb-87c71c35cac8",
"sandboxName":"prod",
"originalTimestamp":1658464615770,
"msgId":"1658464615769:0062:161",
"msgVersion":"1.0",
"traceContext":{
"traceId":"ff3e7544618471eee6b934a4c5929d4e",
"spanId":"74a759c5cc5f5a06",
"isSampled":1.0
},
"_dcsMeta":{
"inletId":"9d411a24aa3c0a3eded92bac6c64d0da986ee7a8212f87168c5fb42d9ddc3227",
"authenticatedRequest":false,
"debug":true
}
},
"body":{
"id":4135234371722,
"admin_graphql_api_id":"gid://shopify/Order/4135234371722",
"app_id":1354745,
"browser_ip":null,
"buyer_accepts_marketing":false,
"cancel_reason":null,
"cancelled_at":null,
"cart_token":null,
"checkout_id":21706716217482,
"checkout_token":"b143503216124d50141fe0832fa3f4b0",
"client_details":{
"accept_language":null,
"browser_height":null,
"browser_ip":null,
"browser_width":null,
"session_hash":null,
"user_agent":null
},
"closed_at":null,
"confirmed":true,
"contact_email":null,
"created_at":"2022-07-22T00:36:48-04:00",
"currency":"INR",
"current_subtotal_price":"40000.00",
"current_subtotal_price_set":{
"shop_money":{
"amount":"40000.00",
"currency_code":"INR"
},
"presentment_money":{
"amount":"40000.00",
"currency_code":"INR"
}
},
"current_total_discounts":"0.00",
"current_total_discounts_set":{
"shop_money":{
"amount":"0.00",
"currency_code":"INR"
},
"presentment_money":{
"amount":"0.00",
"currency_code":"INR"
}
},
"current_total_duties_set":null,
"current_total_price":"47200.00",
"current_total_price_set":{
"shop_money":{
"amount":"47200.00",
"currency_code":"INR"
},
"presentment_money":{
"amount":"47200.00",
"currency_code":"INR"
}
},
"current_total_tax":"7200.00",
"current_total_tax_set":{
"shop_money":{
"amount":"7200.00",
"currency_code":"INR"
},
"presentment_money":{
"amount":"7200.00",
"currency_code":"INR"
}
},
"customer_locale":null,
"device_id":null,
"discount_codes":[
],
"email":"",
"estimated_taxes":false,
"financial_status":"paid",
"fulfillment_status":null,
"gateway":"manual",
"landing_site":null,
"landing_site_ref":null,
"location_id":39129743498,
"name":"#1005",
"note":null,
"note_attributes":[
],
"number":5,
"order_number":1005,
"order_status_url":"https://connnectors-test.myshopify.com/31913214090/orders/ffd48198c78ef460177e44e22b19e6ab/authenticate?key=79a40d7da4b23d6a0beb2ba774f6ac83",
"original_total_duties_set":null,
"payment_gateway_names":[
"manual"
],
"phone":null,
"presentment_currency":"INR",
"processed_at":"2022-07-22T00:36:48-04:00",
"processing_method":"manual",
"reference":null,
"referring_site":null,
"source_identifier":null,
"source_name":"shopify_draft_order",
"source_url":null,
"subtotal_price":"40000.00",
"subtotal_price_set":{
"shop_money":{
"amount":"40000.00",
"currency_code":"INR"
},
"presentment_money":{
"amount":"40000.00",
"currency_code":"INR"
}
},
"tags":"",
"tax_lines":[
{
"price":"7200.00",
"rate":0.18,
"title":"IGST",
"price_set":{
"shop_money":{
"amount":"7200.00",
"currency_code":"INR"
},
"presentment_money":{
"amount":"7200.00",
"currency_code":"INR"
}
},
"channel_liable":false
}
],
"taxes_included":false,
"test":false,
"token":"ffd48198c78ef460177e44e22b19e6ab",
"total_discounts":"0.00",
"total_discounts_set":{
"shop_money":{
"amount":"0.00",
"currency_code":"INR"
},
"presentment_money":{
"amount":"0.00",
"currency_code":"INR"
}
},
"total_line_items_price":"40000.00",
"total_line_items_price_set":{
"shop_money":{
"amount":"40000.00",
"currency_code":"INR"
},
"presentment_money":{
"amount":"40000.00",
"currency_code":"INR"
}
},
"total_outstanding":"0.00",
"total_price":"47200.00",
"total_price_set":{
"shop_money":{
"amount":"47200.00",
"currency_code":"INR"
},
"presentment_money":{
"amount":"47200.00",
"currency_code":"INR"
}
},
"total_price_usd":"589.95",
"total_shipping_price_set":{
"shop_money":{
"amount":"0.00",
"currency_code":"INR"
},
"presentment_money":{
"amount":"0.00",
"currency_code":"INR"
}
},
"total_tax":"7200.00",
"total_tax_set":{
"shop_money":{
"amount":"7200.00",
"currency_code":"INR"
},
"presentment_money":{
"amount":"7200.00",
"currency_code":"INR"
}
},
"total_tip_received":"0.00",
"total_weight":800,
"updated_at":"2022-07-22T00:36:49-04:00",
"user_id":44968935562,
"discount_applications":[
],
"fulfillments":[
],
"line_items":[
{
"id":10630730743946,
"admin_graphql_api_id":"gid://shopify/LineItem/10630730743946",
"fulfillable_quantity":1,
"fulfillment_service":"manual",
"fulfillment_status":null,
"gift_card":false,
"grams":800,
"name":"Mobile Phones",
"origin_location":{
"id":3141069111434,
"country_code":"IN",
"province_code":"UP",
"name":"Noida",
"address1":"Noida",
"address2":"",
"city":"Noida",
"zip":"201301"
},
"price":"40000.00",
"price_set":{
"shop_money":{
"amount":"40000.00",
"currency_code":"INR"
},
"presentment_money":{
"amount":"40000.00",
"currency_code":"INR"
}
},
"product_exists":true,
"product_id":4525859963018,
"properties":[
],
"quantity":1,
"requires_shipping":true,
"sku":"",
"taxable":true,
"title":"Mobile Phones",
"total_discount":"0.00",
"total_discount_set":{
"shop_money":{
"amount":"0.00",
"currency_code":"INR"
},
"presentment_money":{
"amount":"0.00",
"currency_code":"INR"
}
},
"variant_id":32045196640394,
"variant_inventory_management":"shopify",
"variant_title":"",
"vendor":"Connnectors Test",
"tax_lines":[
{
"channel_liable":false,
"price":"7200.00",
"price_set":{
"shop_money":{
"amount":"7200.00",
"currency_code":"INR"
},
"presentment_money":{
"amount":"7200.00",
"currency_code":"INR"
}
},
"rate":0.18,
"title":"IGST"
}
],
"duties":[
],
"discount_allocations":[
]
}
],
"payment_terms":null,
"refunds":[
],
"shipping_lines":[
]
}
}
附录
以下部分提供了有关监视、更新和删除数据流可以采取的步骤的信息。
监测数据流
创建数据流后,您可以监视通过它摄取的数据,以查看有关流运行、完成状态和错误的信息。 有关完整的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删除源帐户.