Please refer to this guide for how to use these APIs.
API name | Description |
---|---|
Get list queue | Return list of all your queues |
Create queue | Create a queue |
Create subscription | Subscribe to a queue by code |
Get list subscriptions | Get list of all subscriptions belong to a queue |
Update subscription active status | Active/De-active subscription |
Pull events from queue | Pull events from queue periodically |
Ack events from queue | Ack you received events successfully |
API get list queues
Return a list of queues you have been created
Request
GET https://api.tiki.vn/integration/v1/queues
Response
Field | Type | Description |
---|---|---|
root | List<Queue> | List of all your queues |
Example
[
{
"code": "5a84289f-ed78-4285-9670-9a34508fb4a7",
"name": "queue 1",
"status": "ACTIVE"
},
{
"code": "5a84289f-ed78-4285-9670-9a34508fb4a7",
"name": "queue 2",
"status": "ACTIVE"
}
]
API create queue
Create a queue with a name on your choice, note that the max number of queue your account can have is specify in the guideline.
You can create one queue for all event type or each queue for each event type. It depends on your workload and handling implement.
IMPORTANT
- If you are seller use your token as normal
- If you are client platform using your client credential token for it. You cannot use the token seller authorized for you as the queue is belong to you not seller.
Request
POST https://api.tiki.vn/integration/v1/queues
Request body
Name | Type | Mandatory | Example | Default value | Description |
---|---|---|---|---|---|
name | String | Y | order queue | N/A | Queue’s name |
Example
{
"name": "queue 1"
}
Response
Field | Type | Description |
---|---|---|
root | Queue | The queue just created |
Example
{
"code": "5a84289f-ed78-4285-9670-9a34508fb4a7",
"name": "queue 1",
"status": "ACTIVE"
}
API create subscription
You subscribe an event type to queue. If it success, after some minutes (specify on guideline docs), if event happen it will route to the queue
Request
POST https://api.tiki.vn/integration/v1/queues/{queueCode}/subscriptions
Request body
Name | Type | Mandatory | Example | Default value | Description |
---|---|---|---|---|---|
event_type | Enum | Y | ORDER_CREATED_SUCCESSFULLY | N/A | Type of event you want to subscribe to that queue. Go here for all current supported event types |
Example
{
"event_type": "ORDER_CREATED_SUCCESSFULLY"
}
Response
Field | Type | Description |
---|---|---|
root | Subscription | The subscription just created |
Example
{
"code": "38f9923b-a345-4437-a48a-d5938a4d6182",
"active": true,
"event_type": "ORDER_CREATED_SUCCESSFULLY",
"sid": "969BEA7515A1A27FF4F456C782653F854E6B5D2D"
}
API get list subscriptions
Return the current list of subscriptions belong to a queue code queue code
Request
GET https://api.tiki.vn/integration/v1/queues/{queueCode}/subscriptions
Response
Field | Type | Description |
---|---|---|
root | List<Subscription> | The subscription list |
Examplee
[
{
"code": "c8cbb55e-21e6-4454-924c-c4dafe124795",
"active": true,
"event_type": "PRODUCT_PRICE_UPDATED",
"sid": "969BEA7515A1A27FF4F456C782653F854E6B5D2D"
},
{
"code": "c8cbb55e-21e6-4454-924c-c4dafe1247234",
"active": true,
"event_type": "ORDER_CREATED_SUCCESSFULLY",
"sid": "969BEA7515A1A27FF4F456C782653F854E6B5D2D"
}
]
API update subscription active status
Active/de-active a subscription. You can de-active subscription if you no longer want to handling them or you subscribe the event type to other queues. You can also active subscription after anytime, after that new events will start to route to the queue
HTTP Request
POST https://api.tiki.vn/integration/v1/queues/{queueCode}/subscriptions/{subscriptionCode}/updateActive
Request body
Name | Type | Mandatory | Example | Default value | Description |
---|---|---|---|---|---|
active | Boolean | Y | true | N/A | true/false. Active/de-active the subscription |
Example
{
"active": true
}
Response
Field | Type | Description |
---|---|---|
root | Subscription | The subscription just got updated |
API pull events
It’s main api you use in event queue system. After setup queue and subscriptions. You can use this endpoint to periodically pulling and handling events from a queue.
Each time you call this endpoint we will return a list of events (if have) and an ack_id. This ack_id is there for a special purpose. It will help to prevent lost events. In the next pull request you should send the ack_id of previous ack_id so we know you are for sure received events so we will remove them and return you the next events. If you don’t send previous ack_id, you will received old events too.
The lost events case can happen with many reasons along the network round-trip between our server with your server or your system can crash when handle the events. So even we return events with HTTP 200 to you, it will not guarantee you handle them in your system successfully. Notes: If you receive an empty event list from a pull call, you better to implement a slowdown mechanism like sleep for 1 minute for the next pull call. It will save unnecessary resources in both your system and our system.
Request
POST https://api.tiki.vn/integration/v1/queues/{queueCode}/events/pull
Request body
Name | Type | Mandatory | Example | Default value | Description |
---|---|---|---|---|---|
ack_id | String | N | true | N/A | The ack_id of previous pull request. You can send null, if don’t have it or it’s your first pull request. |
Example
{
"ack_id": "c8cbb55e-21e6-4454-924c-c4dafe124725"
}
Response
Field | Type | Description |
---|---|---|
events | List<Event> | List of events. 100 max events per request, will support custom size in future. |
ack_id | String | The ack id use for next pull request |
Example
{
"events": [
{
"id": "e4ecb7e5-f12f-4807-ade9-bf4aa1512b71",
"sid": "063B7B71DF51BDB8B46C00F84F1CA928C30742A7",
"created_at": 1604388548418,
"payload": {
"order_code": "203791555",
"status": "picking"
},
"type": "ORDER_STATUS_UPDATED",
"version": "v1"
},
{
"id": "a96d8c5b-769e-426a-b051-eaf2a671a596",
"sid": "063B7B71DF51BDB8B46C00F84F1CA928C30742A7",
"created_at": 1604388764934,
"payload": {
"order_code": "203791555",
"status": "picking"
},
"type": "ORDER_STATUS_UPDATED",
"version": "v1"
}
],
"ack_id": "e586abc8-e6f5-43e0-2222-dc24a25c50fv"
}
API ack events
Request
POST https://api.tiki.vn/integration/v1/queues/{queueCode}/events/ack
Request body
Name | Type | Mandatory | Example | Default value | Description |
---|---|---|---|---|---|
ack_id | String | Y | true | N/A | The ack_id of previous pull request |
Example
{
"ack_id": "c8cbb55e-21e6-4454-924c-c4dafe124725"
}
Response
Field | Type | Description |
---|---|---|
status | String | “ok” |
Example
{
"status": "ok"
}