ข้ามไปยังเนื้อหา

Segmentation (ฟิลเตอร์) API

createFilter

Anchor link to

POST https://api.pushwoosh.com/json/1.3/createFilter

สร้างฟิลเตอร์ใหม่

เนื้อหาของคำขอ

ชื่อจำเป็นประเภทคำอธิบาย
auth*ใช่stringโทเค็นการเข้าถึง API จาก Pushwoosh Control Panel
name*ใช่stringชื่อฟิลเตอร์
filter_expression*ใช่string

นิพจน์ที่สร้างขึ้นตามกฎของ ภาษา Segmentation
ตัวอย่าง: T(“City”, eq, “Madrid”) เพื่อแบ่งกลุ่มผู้ใช้ที่เมืองคือมาดริด

applicationไม่stringรหัสแอปพลิเคชัน Pushwoosh พารามิเตอร์นี้ใช้ได้กับ High-Speed Setup เท่านั้น ให้เว้นว่างไว้ในกรณีอื่น
expiration_dateไม่stringวันหมดอายุของฟิลเตอร์ ฟิลเตอร์จะถูกลบโดยอัตโนมัติในวันที่ระบุ เว้นแต่จะถูกใช้ใน Preset หรือ RSS Feed

200

{
"status_code": 200,
"status_message": "OK",
"response": {
"name": "filter name"
}
}

ตัวอย่าง

{
"request": {
"auth": "yxoPUlwqm…………pIyEX4H",
"name": "City = Madrid",
"filter_expression": "T(\"City\", eq, \"Madrid\")",
"application": "B18XX-XXXXX",
"expiration_date": "2025-01-01"
}
}
// creating Filters for Timezones
{
"request": {
"auth": "yxoPUlwqm…………pIyEX4H", // API access token from Pushwoosh Control Panel
"name": "Timezone Filter",
"filter_expression": "T(\"Timezone\", BETWEEN, [\"UTC-12:00\", \"UTC+14:00\"])"
}
}

listFilters

Anchor link to

POST https://api.pushwoosh.com/json/1.3/listFilters

ส่งคืนรายการของเซกเมนต์ (ฟิลเตอร์) ที่มีอยู่พร้อมเงื่อนไข

เนื้อหาของคำขอ

ชื่อจำเป็นประเภทคำอธิบาย
auth*ใช่stringโทเค็นการเข้าถึง API จาก Pushwoosh Control Panel
application*ใช่stringรหัสแอปพลิเคชัน Pushwoosh

200

{
"status_code": 200,
"status_message": "OK",
"response": {
"filters": [{
"code": "52551-F2F42",
"name": "City = Madrid",
"filter_expression": "T(\"City\", eq, \"madrid\")",
"expiration_date": "2025-01-01",
"application": "B18XX-XXXXX"
}]
}
}

ตัวอย่าง

{
"request": {
"auth": "yxoPUlwqm…………pIyEX4H",
"application": "B18XX-XXXXX"
}
}

deleteFilter

Anchor link to

POST https://api.pushwoosh.com/json/1.3/deleteFilter

ลบฟิลเตอร์ที่มีอยู่

เนื้อหาของคำขอ

ชื่อประเภทคำอธิบาย
auth*stringโทเค็นการเข้าถึง API จาก Pushwoosh Control Panel
name*stringชื่อฟิลเตอร์
{
"status_code": 200,
"status_message": "OK",
"response": null
}
Example
{
"request": {
"auth": "yxoPUlwqm…………pIyEX4H", // API access token from Pushwoosh Control Panel
"name": "filter name"
}
}

exportSegment

Anchor link to

POST https://api.pushwoosh.com/api/v2/audience/exportSegment

คำขอที่ตั้งเวลาไว้ ส่งออกรายชื่อผู้ติดตามที่ตรงตามเงื่อนไขฟิลเตอร์ที่ระบุ

เนื้อหาของคำขอ

ชื่อ
จำเป็น
ประเภทคำอธิบาย
auth*ใช่stringโทเค็นการเข้าถึง API จาก Pushwoosh Control Panel
filterExpression*ใช่stringเงื่อนไขฟิลเตอร์
exportDataไม่arrayข้อมูลที่จะส่งออก ค่าที่เป็นไปได้: "hwids", "push_tokens", "users", "tags", "location" การรวม "location" จะเพิ่มคอลัมน์ Latitude และ Longitude ลงใน CSV ที่ส่งออก หากละเว้น exportData โดยค่าเริ่มต้น Latitude และ Longitude จะถูกรวมอยู่ในการส่งออก
filterCodeไม่stringรหัสฟิลเตอร์ที่สร้างไว้ล่วงหน้า สามารถใช้แทน filterExpression ได้ สามารถรับได้จาก /listFilters API หรือแถบที่อยู่ของเบราว์เซอร์ของคุณเมื่อดูฟิลเตอร์ใน Control Panel
applicationCodeจำเป็นหากคุณใช้ filterExpression หรือ filterCodestringรหัสแอปพลิเคชัน Pushwoosh
generateExportไม่booleanโดยค่าเริ่มต้นตั้งค่าเป็น true และการตอบกลับจะมีลิงก์สำหรับดาวน์โหลดไฟล์ หากเป็นเท็จ จะมีการส่งเฉพาะจำนวนอุปกรณ์ในการตอบกลับ
formatไม่stringตั้งค่ารูปแบบของไฟล์ที่ส่งออก: “csv” หรือ “json_each_line” หากละเว้น จะมีการสร้างไฟล์ CSV
tagsListไม่arrayระบุ tags ที่จะส่งออก หากต้องการรับเฉพาะแท็กที่ระบุ อาร์เรย์ “exportData” ควรมีค่า “tags”
includeWithoutTokensไม่booleanตั้งค่าเป็น true เพื่อรวมผู้ใช้ที่ไม่มี push token ในไฟล์ที่ส่งออก ค่าเริ่มต้นคือ false
{
"task_id": "177458"
}
Example
{
"auth": "yxoPUlwqm…………pIyEX4H", // required. API access token from Pushwoosh Control Panel
"filterExpression": "AT(\"12345-67890\", \"Name\", any)", // filter conditions, refer to the Segmentation Language guide for syntax
"filterCode": "12345-67890", // pre-made filter code, can be used instead of filterExpression
"applicationCode": "00000-AAAAA", // Required if you're using either `filterExpression` or `filterCode`. Pushwoosh app code. Can be obtained from /listFilters API request or address bar of your browser while viewing the filter in Control Panel.
"generateExport": true, // if false, devices count only will be sent in response; by default, a response contains a link to download the CSV file
"format": "json_each_line", // format of the file to present the data in: "csv" – the .csv file is downloaded; "json" – a JSON file with all expored devices; or "json_each_line" – JSON line for each device. If not specified, CSV is the default format.
"exportData": ["hwids", "tags"], // optional. Data to export. Possible values: "hwids", "push_tokens", "users", "tags", "location", "fcm_keys", "web keys"
"tagsList": ["Name", "Level"], // optional. Specifies tags to export. To obtain the specific tags only, the "tags" value should be sent within the "exportData" array or the "exportData" be empty.
"includeWithoutTokens": true // optional. Set to true to include users without push tokens in the exported file. Default is false.
}

ตัวอย่างเช่น หากต้องการส่งออกผู้ติดตามทั้งหมดของแอปใดแอปหนึ่ง ให้ใช้เงื่อนไขฟิลเตอร์ต่อไปนี้:

{
"auth": "yxoPUlwqm…………pIyEX4H", // API access token from Pushwoosh Control Panel
"filterExpression": "A(\"AAAAA-BBBBB\")", // Filter expression referencing app segment
"applicationCode": "AAAAA-BBBBB" // Required Pushwoosh app code
}

ผลลัพธ์ exportSegment

Anchor link to

POST https://api.pushwoosh.com/api/v2/audience/exportSegment/result

ดึงลิงก์ไปยัง CSV พร้อมผลลัพธ์ /exportSegment

เนื้อหาของคำขอ

ชื่อประเภทคำอธิบาย
auth*Stringโทเค็นการเข้าถึง API จาก Pushwoosh Control Panel
task_id*Stringตัวระบุที่ได้รับในการตอบกลับ /exportSegment ของคุณ
{
"devicesCount": "24735",
"filename": "https://static.pushwoosh.com/segment-export/export_segment_XXXXX_XXXXX_xxxxxxxxxxxxxxxxx.csv.zip",
"status": "completed"
}

ส่งผ่าน “task_id” ที่ได้รับในการตอบกลับ /exportSegment ของคุณในเนื้อหาคำขอ /exportSegment/result

ในการตอบกลับ /exportSegment/result คุณจะได้รับพารามิเตอร์ “filename” ไปตามลิงก์ที่ให้ไว้ในค่าพารามิเตอร์นั้นเพื่อดาวน์โหลดไฟล์ ZIP โดยอัตโนมัติ แตกไฟล์เพื่อดึงไฟล์ CSV หรือ JSON (ขึ้นอยู่กับ “format” ที่ระบุในคำขอของคุณ) ที่มีข้อมูลของอุปกรณ์

ตั้งแต่วันที่ 3 เมษายน 2025 เป็นต้นไป จำเป็นต้องมีการอนุญาตเพื่อดาวน์โหลดไฟล์:

  • หากดาวน์โหลดผ่าน เบราว์เซอร์ เพียงเข้าสู่ระบบ Pushwoosh Control Panel เพื่อเข้าถึง
  • หากดาวน์โหลดผ่าน ซอฟต์แวร์เซิร์ฟเวอร์ ให้รวมส่วนหัวต่อไปนี้ในคำขอของคุณ: Authorization: Token YOUR_API_TOKEN

หากคุณระบุ “exportData” ในคำขอ /exportSegment ของคุณ ไฟล์ที่ดาวน์โหลดจะมีเฉพาะข้อมูลที่ร้องขอ โดยค่าเริ่มต้น ไฟล์จะมีข้อมูลผู้ใช้ดังต่อไปนี้:

ฟิลด์คำอธิบายตัวอย่างค่า
HwidID ฮาร์ดแวร์ของอุปกรณ์01D1BA5C-AAAA-0000-BBBB-9B81CD5823C8
User IDUser ID ที่เชื่อมโยงอุปกรณ์กับผู้ใช้รายใดรายหนึ่ง หากไม่มี User ID ที่กำหนด จะใช้ HWID แทนuser8192
Push Tokenตัวระบุที่ไม่ซ้ำกันซึ่งกำหนดให้กับอุปกรณ์โดยเกตเวย์การส่งข้อความบนคลาวด์ เรียนรู้เพิ่มเติมeeeb2fd7…0fc3547
Typeประเภทแพลตฟอร์ม (จำนวนเต็ม)1
Type (humanized)ประเภทแพลตฟอร์ม (สตริง)iOS
Ageค่าของแท็ก Age เริ่มต้น29
ApplicationVersionค่าของแท็ก Application Version เริ่มต้น1.12.0.0
Cityค่าของแท็ก City เริ่มต้นus, boston
TagNameค่าของแท็กที่สร้างขึ้นในบัญชีของคุณTagValue