REST API OVERVIEW

最新の更新:2024-07-10

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.

Data Centers and Base URL

Data Center Base URL
Singapore https://push.api.engagelab.cc
Virginia, USA https://push-usva.api.engagelab.cc
Frankfurt, Germany https://push-defra.api.engagelab.cc
Hong Kong https://push-hk.api.engagelab.cc

When using REST API, it's necessary to combine the selected base URL with the specific API path to obtain the complete endpoint.

{base URL}/{API path}
          {base URL}/{API path}

        
このコードブロックは、フローティングウィンドウに表示されます

Here, {base URL} represents the chosen data center's base URL, and {API path} denotes the specific API endpoint path, such as v4/devices/{registration_id}.

Example:

  • Suppose the Singapore data center is selected with a base URL of https://push.api.engagelab.cc.
  • If the goal is to delete registration information for a specific device, and the API path is v4/devices/{registration_id}, then the complete API endpoint would be:
https://push.api.engagelab.cc/v4/devices/{registration_id}
          https://push.api.engagelab.cc/v4/devices/{registration_id}

        
このコードブロックは、フローティングウィンドウに表示されます

Here, {registration_id} represents the specific device's registration ID.

Using this approach, you can construct complete API endpoint URLs for accessing different data centers.

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==

        
このコードブロックは、フローティングウィンドウに表示されます
在文档中心打开
Contact Sales