Segmentation (ฟิลเตอร์) API
createFilter
Anchor link toPOST https://api.pushwoosh.com/json/1.3/createFilter
สร้างฟิลเตอร์ใหม่
เนื้อหาของคำขอ
| ชื่อ | จำเป็น | ประเภท | คำอธิบาย |
|---|---|---|---|
| auth* | ใช่ | string | โทเค็นการเข้าถึง API จาก Pushwoosh Control Panel |
| name* | ใช่ | string | ชื่อฟิลเตอร์ |
| filter_expression* | ใช่ | string | นิพจน์ที่สร้างขึ้นตามกฎของ ภาษา Segmentation |
| 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 toPOST 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 toPOST https://api.pushwoosh.com/json/1.3/deleteFilter
ลบฟิลเตอร์ที่มีอยู่
เนื้อหาของคำขอ
| ชื่อ | ประเภท | คำอธิบาย |
|---|---|---|
| auth* | string | โทเค็นการเข้าถึง API จาก Pushwoosh Control Panel |
| name* | string | ชื่อฟิลเตอร์ |
{ "status_code": 200, "status_message": "OK", "response": null}{ "request": { "auth": "yxoPUlwqm…………pIyEX4H", // API access token from Pushwoosh Control Panel "name": "filter name" }}exportSegment
Anchor link toPOST 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 หรือ filterCode | string | รหัสแอปพลิเคชัน 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"}{ "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 toPOST 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 ของคุณ ไฟล์ที่ดาวน์โหลดจะมีเฉพาะข้อมูลที่ร้องขอ โดยค่าเริ่มต้น ไฟล์จะมีข้อมูลผู้ใช้ดังต่อไปนี้:
| ฟิลด์ | คำอธิบาย | ตัวอย่างค่า |
|---|---|---|
| Hwid | ID ฮาร์ดแวร์ของอุปกรณ์ | 01D1BA5C-AAAA-0000-BBBB-9B81CD5823C8 |
| User ID | User 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 |