REST API OVERVIEW

อัพเดทล่าสุด :2023-02-27

Basic constraint

  • The API is designed to conform to HTTP and REST specifications. For example, the query request uses the Get method, and the submission request uses the POST method. If a request is not a corresponding HTTP method, an error will be returned.
  • Unless otherwise specified, the call parameter value should be transcoded as UTF-8, URL encoding.

API Resource List

Name Base URL Description
Create Push API https://push.api.engagelab.cc/v4/push Push Message API
Statistics API https://push.api.engagelab.cc/v4 Get statistics data
Scheduled Tasks API https://push.api.engagelab.cc/v4/schedules Manage scheduled push tasks

Authentication method

The Engagelab REST API uses HTTP basic authentication. The basic approach is to add Authorization to the HTTP header:

Authorization: Basic base64_auth_string
          Authorization: Basic base64_auth_string

        
โค้ดนี้โชว์เป็นหน้าต่างลอย

base64_ auth_ String generation algorithm:base64(appKey:masterSecret)
The string composed of appKey, colon and masterSecret and convert by base64.
Go to AppPush Page and get the AppKey and Master Secret infos in the APP Info Page.
image.png

Authentication example

Your appKey is "c96f42e0d2e662e45d035ab1", masterSecret is "df4d59e84eac2f9d53b36f12",calling the Push API v4 by via curl command like below:

curl --insecure -X POST -v https://push.api.engagelab.cc/v4/push -H "Content-Type: application/json" -u "c96f42e0d2e662e45d035ab1:df4d59e84eac2f9d53b36f12" -d '{ "from": "push", "to": "all", "body": { "platform": "all", "notification": { "android": { "alert": "Hi, Push!", "title": "Send to Android", "builder_id": 1, "extras": { "newsid": 321 } }, "ios": { "alert": "Hi, MTPush!", "sound": "default", "badge": "+1", "extras": { "newsid": 321 } } }, "message": { "msg_content": "Hi,MTPush", "content_type": "text", "title": "msg", "extras": { "key": "value" } }, "options": { "time_to_live": 60, "apns_production": false } }, "request_id": "12345678", "custom_args": "business info" }'
          curl --insecure -X POST -v https://push.api.engagelab.cc/v4/push -H "Content-Type: application/json" 
-u "c96f42e0d2e662e45d035ab1:df4d59e84eac2f9d53b36f12" 
-d '{
    "from": "push",
    "to": "all",
    "body": {
        "platform": "all",
        "notification": {
            "android": {
                "alert": "Hi, Push!",
                "title": "Send to Android",
                "builder_id": 1,
                "extras": {
                    "newsid": 321
                }
            },
            "ios": {
                "alert": "Hi, MTPush!",
                "sound": "default",
                "badge": "+1",
                "extras": {
                    "newsid": 321
                }
            }
        },
        "message": {
            "msg_content": "Hi,MTPush",
            "content_type": "text",
            "title": "msg",
            "extras": {
                "key": "value"
            }
        },
        "options": {
            "time_to_live": 60,
            "apns_production": false
        }
    },
    "request_id": "12345678",
    "custom_args": "business info"
}'

        
โค้ดนี้โชว์เป็นหน้าต่างลอย

HTTP Request example:

> POST /v4/push HTTP/1.1 > Authorization: Basic Yzk2ZjQyZTBkMmU2NjJlNDVkMDM1YWIxOmRmNGQ1OWU4NGVhYzJmOWQ1M2IzNmYxMg==
          > POST /v4/push HTTP/1.1
> Authorization: Basic Yzk2ZjQyZTBkMmU2NjJlNDVkMDM1YWIxOmRmNGQ1OWU4NGVhYzJmOWQ1M2IzNmYxMg==

        
โค้ดนี้โชว์เป็นหน้าต่างลอย
在文档中心打开