Skip to content
On this page

Talkee API

How to specify a site

Some APIs require you to specify a site, for example, GET /comments need to know which site you want to get comments from. There are two ways to do that:

  1. You can specify a site by setting the X-TALKEE-SITE-ID or X-TALKEE-SITE-SLUG header.
  2. You can specify a site by setting the site_id or slug query parameter.

Both ways are valid, but you can only use one of them at a time. If you specify a site by both ways, the header will be used.

Login

POST /auth/login

This API is used to login to Talkee.

Talkee's authentication is slightly different from other pando protocols. It uses own JWT token to identify users.

To get the JWT token, there are three ways:

  1. Login with Mixin access token: You need to exchange Mixin's access_token to Talkee's access_token. Assign mixin_token to method and mixin's access_token mentioned in the Authorization to mixin_access_token in the request body.

  2. Login with Ethereum: You need to sign an EIP-4361 messages to exchange for Talkee's access_token. Assign mvm to method, put the signed message to signed_message and the signature to signature in the request body.

    Please read this section to learn how to generate the signed message and signature.

After you get the access_token, save the access_token in the response to access other authenticated APIs.

Params
NameTypeInRequiredDescription
methodstringjsontruethe login method, can be "mixin_token" or "mvm"
mixin_tokenstringjsonfalsethe access token of mixin, should be signed for `/me` or a regular Mixin OAuth token. Only required when `method` is "mixin_token"
signaturestringjsonfalsethe signature of the message, generated by EIP-4361 process. Only required when `method` is "mvm"
signed_messagestringjsonfalsethe signed message. It is a JSON object contains all required fields of EIP-4361. Only required when `method` is "mvm"
langstringjsonfalsethe language of user, 2 letters, like "en", "ja" etc.

TIP

Note that the mixin_access_token is same as the access_token in the Authorization.

Response

json
{
  "ts": 1675582938650,
  "data": {
    "access_token": "eyJhbG....lBM",
    "user": {
      "id": 1,
      "mixin_user_id": "36158804-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "mixin_identity_number": "1234456",
      "full_name": "John Wick",
      "avatar_url": "https://mixin-images.zeromesh.net/...",
      "created_at": "2022-02-05T16:11:16.420872+09:00"
    }
  }
}

Get site info

GET /sites/:site_id

This API is used to get site info.

Params
NameTypeInRequiredDescription
site_idnumberurltruethe site's id

Response

json
{
  "ts": 1675583895807,
  "data": {
    "id": 1,
    "user_id": 1,
    "origins": [ "https://...", "https://..." ],
    "name": "A Test Site",
    "use_arweave": false,
    "reward_strategy": 0,
    "created_at": "2022-02-05T16:11:16.420872+09:00",
    "updated_at": "2022-02-05T16:11:16.420872+09:00"
  }
}

Create a comment

AUTHORIZATION REQUIRED
POST /comments

This API is used to create new comments.

Params
NameTypeInRequiredDescription
X-TALKEE-SITE-IDstringheadertruesite's id
X-TALKEE-SITE-SLUGstringheadertruethe slug of site
contentstringjsontruethe text content.

Response

json
{
  "ts": 1675583187295,
  "data": {
    "id": 15,
    "user_id": "4",
    "site_id": 1,
    "slug": "/posts/11",
    "favor_count": 3,
    "reply_count": 2,
    "arweave_tx_hash": "...",
    "content": "Hello!",
    "created_at": "2023-02-05T16:11:58.175076+09:00",
    "updated_at": "2023-02-05T16:11:58.175076+09:00",
    "creator": {
      "id": "4",
      "mixin_user_id": "36158804-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "mixin_identity_number": "1234456",
      "full_name": "John Wick",
      "avatar_url": "https://mixin-images.zeromesh.net/...",
      "created_at": "2022-02-05T16:11:16.420872+09:00"
    },
    "rewards": [
      { /*...*/ },
      { /*...*/ }
    ]
  }
}

Get comments

GET /comments?limit=:limit&offset=:offset&order_by=:order_by

This API is used to get comments.

Params
NameTypeInRequiredDescription
X-TALKEE-SITE-IDstringheadertruesite's id
X-TALKEE-SITE-SLUGstringheadertruethe slug of site
limitnumberurlfalsethe limitation of items in response
offsetnumberurlfalsethe offset to start from
order_bystringurlfalsethe order of items in response, can be "created_at", "created_at_asc" or "favor_count"

Response

json
{
  "ts": 1675583187295,
  "data": {
    "comments": [{
      "id": 15,
      "user_id": "4",
      "site_id": 1,
      "slug": "/posts/11",
      "favor_count": 3,
      "reply_count": 2,
      "arweave_tx_hash": "...",
      "content": "Hello!",
      "created_at": "2023-02-05T16:11:58.175076+09:00",
      "updated_at": "2023-02-05T16:11:58.175076+09:00",
      "creator": {
        "id": "4",
        "mixin_user_id": "36158804-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
        "mixin_identity_number": "1234456",
        "full_name": "John Wick",
        "avatar_url": "https://mixin-images.zeromesh.net/...",
        "created_at": "2022-02-05T16:11:16.420872+09:00"
      },
      "rewards": [
        { /*...*/ },
        { /*...*/ }
      ]
    },
    // ...
    ],
    "total": 128,
  }
}

Get a comment

GET /comments/:comment_id

This API is used to get a specific comment.

Params
NameTypeInRequiredDescription
comment_idnumberurltruethe comment's id

Response

Response

json
{
  "ts": 1675583187295,
  "data": {
    "id": 15,
    "user_id": "4",
    "site_id": 1,
    "slug": "/posts/11",
    "favor_count": 3,
    "reply_count": 2,
    "arweave_tx_hash": "...",
    "content": "Hello!",
    "created_at": "2023-02-05T16:11:58.175076+09:00",
    "updated_at": "2023-02-05T16:11:58.175076+09:00",
    "creator": {
      "id": "4",
      "mixin_user_id": "36158804-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "mixin_identity_number": "1234456",
      "full_name": "John Wick",
      "avatar_url": "https://mixin-images.zeromesh.net/...",
      "created_at": "2022-02-05T16:11:16.420872+09:00"
    },
    "rewards": [
      { /*...*/ },
      { /*...*/ }
    ]
  }
}

Favorite a comment

AUTHORIZATION REQUIRED
PUT /comments/:comment_id/fav

This API is used to favorite a comment specified in the ID parameter as the authenticating user. Returns the favorite comment when successful.

Params
NameTypeInRequiredDescription
X-TALKEE-SITE-IDstringheadertruesite's id
X-TALKEE-SITE-SLUGstringheadertruethe slug of site
comment_idnumberurltruethe comment's id

Response

json
{
  "ts": 1675583187295,
  "data": {
    "id": 15,
    "user_id": "4",
    "site_id": 1,
    "slug": "/posts/11",
    "favor_count": 3,
    "reply_count": 2,
    "arweave_tx_hash": "...",
    "content": "Hello!",
    "created_at": "2023-02-05T16:11:58.175076+09:00",
    "updated_at": "2023-02-05T16:11:58.175076+09:00",
    "creator": {
      "id": "4",
      "mixin_user_id": "36158804-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "mixin_identity_number": "1234456",
      "full_name": "John Wick",
      "avatar_url": "https://mixin-images.zeromesh.net/...",
      "created_at": "2022-02-05T16:11:16.420872+09:00"
    },
    "rewards": [
      { /*...*/ },
      { /*...*/ }
    ]
  }
}

Unfavorite a comment

AUTHORIZATION REQUIRED
PUT /comments/:comment_id/unfav

This API is used to unfavorite a comment specified in the ID parameter as the authenticating user. Returns the unfavorite comment when successful.

Params
NameTypeInRequiredDescription
X-TALKEE-SITE-IDstringheadertruesite's id
X-TALKEE-SITE-SLUGstringheadertruethe slug of site
comment_idnumberurltruethe comment's id

Response

json
{
  "ts": 1675583187295,
  "data": {
    "id": 15,
    "user_id": "4",
    "site_id": 1,
    "slug": "/posts/11",
    "favor_count": 3,
    "reply_count": 2,
    "arweave_tx_hash": "...",
    "content": "Hello!",
    "created_at": "2023-02-05T16:11:58.175076+09:00",
    "updated_at": "2023-02-05T16:11:58.175076+09:00",
    "creator": {
      "id": "4",
      "mixin_user_id": "36158804-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "mixin_identity_number": "1234456",
      "full_name": "John Wick",
      "avatar_url": "https://mixin-images.zeromesh.net/...",
      "created_at": "2022-02-05T16:11:16.420872+09:00"
    },
    "rewards": [
      { /*...*/ },
      { /*...*/ }
    ]
  }
}

Create a reply

AUTHORIZATION REQUIRED
POST /comments/:comment_id/replies

This API is used to create new reply for a specific comment.

Params
NameTypeInRequiredDescription
comment_idnumberurltruethe comment's id
contentstringjsontruethe text content.

Response

json
{
  "ts": 1675583738297,
  "data": {
    "id": 17,
    "user_id": "3",
    "comment_id": "4",
    "content": "A reply",
    "created_at": "2023-02-05T16:55:38.266176+09:00",
    "updated_at": "2023-02-05T16:55:38.266176+09:00",
    "creator": {
      "id": "4",
      "mixin_user_id": "36158804-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
      "mixin_identity_number": "1234456",
      "full_name": "John Wick",
      "avatar_url": "https://mixin-images.zeromesh.net/...",
      "created_at": "2022-02-05T16:11:16.420872+09:00"
    }
  }
}

Get replies

GET /comments/:comment_id/replies?limit=:limit&offset=:offset&

This API is used to create new reply for a specific comment.

Params
NameTypeInRequiredDescription
limitnumberurlfalsethe limitation of items in response
offsetnumberurlfalsethe offset to start from
comment_idnumberurltruethe comment's id
contentstringjsontruethe text content.

Response

json
{
  "ts": 1675583187295,
  "data": {
    "replies": [{
      "id": 17,
      "user_id": "3",
      "comment_id": "4",
      "content": "A reply",
      "created_at": "2023-02-05T16:55:38.266176+09:00",
      "updated_at": "2023-02-05T16:55:38.266176+09:00",
      "creator": {
        "id": "4",
        "mixin_user_id": "36158804-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
        "mixin_identity_number": "1234456",
        "full_name": "John Wick",
        "avatar_url": "https://mixin-images.zeromesh.net/...",
        "created_at": "2022-02-05T16:11:16.420872+09:00"
      }
    }
    // ...
    ],
    "total": 128,
  }
}

Get a user

GET /users/:user_id

This API is used to get a user info.

Params
NameTypeInRequiredDescription
user_idnumberurltruethe user's id

Response

json
{
  "ts": 1675584720934,
  "data": {
    "id": 1,
    "mixin_user_id": "36158804-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "mixin_identity_number": "1234456",
    "full_name": "John Wick",
    "avatar_url": "https://mixin-images.zeromesh.net/...",
    "created_at": "2022-02-05T16:11:16.420872+09:00"
  }
}

Get me

AUTHORIZATION REQUIRED
GET /me

This API is used to get my info.

Response

json
{
  "ts": 1675584720934,
  "data": {
    "id": 1,
    "mixin_user_id": "36158804-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
    "mixin_identity_number": "1234456",
    "full_name": "John Wick",
    "avatar_url": "https://mixin-images.zeromesh.net/...",
    "created_at": "2022-02-05T16:11:16.420872+09:00"
  }
}

DRAFT PROPOSAL

The following section is a draft proposal, it's not finalized yet.

Create an airdrop

AUTHORIZATION REQUIRED
POST /airdrops

Call the API to create an airdrop for multiple comments, a slug or a user.

Params
NameTypeInRequiredDescription
airdrop_typestringjsontruethe airdrop type. support "comments", "comment", "user", "slug"
site_idnumberjsonfalsethe site's id. It's required for "slug" and "comments" airdrop type.
slugstringjsonfalsethe site's slug. It's required for "slug" and "comments" airdrop type.
opponent_idnumberjsonfalseopponent's id. It's required for "user" and "comment" airdrop type. For "user" airdrop type, it should be the user's id. For "comment" airdrop type, it should be the comment's id.
strategy_namestringjsonfalsethe airdrop strategy name, support "topn" or "avg". It's required for "comments" airdrop type.
strategy_paramsjsonjsonfalsethe airdrop strategy params. It's required for "comments" airdrop type. For "topn", it should be a JSON object contains "n" field, like {"n": 3}.
asset_idUUIDjsontruethe asset id to airdrop
amountstringjsontruehow much to airdrop. The precision should be 8, like "1.23456789"
memostringjsontruethe memo of the airdrop transaction
redirect_urlstringjsontruethe redirect url after airdrop

There are four types of airdrops:

  1. Airdrop to a specific user: airdrop_type is set to user. opponent_id is set to the user ID.
  2. Airdrop to a specific slug: airdrop_type is set to slug. site_id and slug should be set.
  3. Air drop to a specific comment: airdrop_type is set to comment. opponent_id is set to the comment ID.
  4. Airdrop to a set of comments: airdrop_type is set to comments. site_id and slug should be set. strategy_name and strategy_params should be set.

Response

json
{
  "ts": 1680674968664,
  "data": {
    "id": 13,
    "uuid": "c85d17c8-1e51-43da-b7c5-3a988bc61022",
    "user_id": 3,
    "site_id": 1,
    "slug": "ABC",
    "opponent_id": 0,
    "tip_type": "comments",
    "strategy_name": "topn",
    "strategy_params": {
        "n": 3
    },
    "asset_id": "c6d0c728-2624-429b-8e0d-d9d19b6592fa",
    "amount": "0.0000001",
    "memo": "test",
    "status": 0,
    "created_at": "2023-04-05T15:09:28.386937+09:00",
    "updated_at": "2023-04-05T15:09:28.386937+09:00",
    "deleted_at": null,
    "mixpay_code": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
  }
}

To complete the airdrop payment, you need to redirect the user to following URL:

text
https://mixpay.me/code/:mixpay_code

in which :mixpay_code is the mixpay_code returned by the API.