TikFinity-Third-Party-Interface

TikFinity offers the ability to integrate third party tools. Users can select the "Third-party action" option via Actions & Events. The user can then select an action of the third-party tool from two drop-down menus. If you want to write such a tool, then your tool has to expose an API on port 8832. TikFinity will access this API to query data or trigger actions.

API

Your tool must provide the following endpoints:

App Info

Returns information about your app that will be displayed in TikFinity.

GET http://127.0.0.1:8832/api/app/info

JSON Response:


{
  "data":{
    "author":"@zerodytrash",
    "name":"AwesomeApp",
    "version":"1.0"
   }
}

Get Categories

Returns a list (Array) of categories that your app supports.

GET http://127.0.0.1:8832/api/features/categories

JSON Response:


{
    "data": [
        {
            "categoryId": "smart_device_control",
            "categoryName": "Control Smart Devices"
        },
        {
            "categoryId": "serial_port_control",
            "categoryName": "Control Serial Port"
        },
        ...
     ]
}

Get Actions

Returns a list of actions of the selected category.

GET http://127.0.0.1:8832/api/features/actions?categoryId=smart_device_control

JSON Response:


{
    "data": [
        {
            "actionId": "turn_lights_off",
            "actionName": "Turn Lights Off"
        },
        {
            "actionId": "turn_lights_on",
            "actionName": "Turn Lights On"
        },
        ...
    ]
}

Execute Action

Executes the action selected by the user.

POST http://127.0.0.1:8832/api/features/actions/exec

JSON Body:


{
  "categoryId":"smart_device_control",
  "actionId":"turn_lights_on",
  "context":{
    "triggerTypeId": 3,
    "userId": "123456789",
    "username": "Tesuser",
    "coins": 12
  }
}

JSON Response:


{
  "data":[]
}

Cross-origin resource sharing

Since TikFinity is a web app, your API must explicitly allow access by setting headers and responding to preflight OPTIONS requests. Otherwise access will fail. Please return the following headers for all responses:


Access-Control-Allow-Origin: *
Access-Control-Allow-Headers: *
Access-Control-Allow-Methods: *

Trigger Information

The POST /api/features/actions/exec request contains the attribute triggerTypeId in the context which can be used to determine what triggered the event. Here is a list of possible trigger reasons:


1 = Share
2 = Command
3 = Gift (min coins value)
4 = Gift (specific gift)
6 = Join
7 = Likes (taps)
9 = Follow
10 = Subscribe
11 = Chat (any message)
12 = Emote
13 = First User Activity

Error Handling

If your application encounters an error while processing the requests or you want to alert the user about something, just add the attribute "message" to the response. The TikFinity UI will then display a message.

Example Response:


{
  "message": "An error occurred while processing your request."
}

Support

If you have any questions or problems, please contact us on the TikFinity Discord.