xuan
Published on 2024-11-25 / 70 Visits
0

Integrator API Interface

Server address: https://txapi-usa.lbai.ai

✅1. Create a user on the Little Beauty server

Interface description

Enabling Little Beauty AI capabilities for users. Create a unique user ID for the user, and give it access to memory space, file space, and AI partners. Returns the user token valid for a long time.

Interface address

GET /ai-api/v1/apiService/addUser?identifier=

Request Head

Authorization: Bearer CPN-XXXXXXXXXXXXXXXXXXXXXX (enterprise token)

Request parameters

Parameter name

Required

Type

Description

identifier

yes

String

The unique identity of the user can be a cell phone number, mailbox number, or the user id of the user in the integrator service. We will verify its uniqueness to prevent duplication. (numbers, English characters) length 10-50

groupId

yes

String

Traceable 0,1,2,3... Tag different groups of users

nickName

no

String

Nickname

headPic

no

String

Avatar URL (three-way custom link)

validity

no

int

Token valid days, long-term by default

Sample request

curl /ai-api/v1/apiService/addUser?identifier=xxx \
  -H "Content-Type: application/json" \
  -H "Authorization: xxxxx"   

Reply to sample

{
    "data": {
        "token": "xxxxxx" //returns a token to the user that needs to be added to the header for 15 days when the user requests the API  
        "userId": "13000998888932"  //Little Beauty platform user identity
    },
    "errorCode": 0,
    "message": null,
    "success": true
}

✅2. Get/update the user token

Interface description

Calling this interface generates a new token. exe. The user's old token will expire;

Interface address

GET /ai-api/v1/apiService/refreshToken?userId=

Request Head

Authorization: Bearer CPN-XXXXXXXXXXXXXXXXXXXXXX (enterprise token)

Request parameters

Parameter name

Required

Type

Description

userId

yes

String

User ID

validity

no

int

Token is valid for days, long by default

Sample request

curl /ai-api/v1/apiService/refreshToken?userId= \
 -H "Content-Type: application/json" \
 -H "Authorization: xxxxx"   

Reply to sample

{
    "data": {
        "token": "xxxxxx"  //The token returned to the user, which needs to be added to the header when the user requests the API 
    },
    "errorCode": 0,
    "message": "success",
    "success": true
}

✅3. The user logs off

Interface description

Calling this interface destroys the user token. exe.

Interface address

GET /ai-api/v1/apiService/logout

Request Head

Authorization: Bearer CPN-XXXXXXXXXXXXXXXXXXXXXX (enterprise token)

Request parameters

Parameter name

Required

Type

Description

user_id

yes

String

Sample request

curl /ai-api/v1/apiService/refreshToken?userId= \
  -H "Authorization: xxxxx"   

Reply to sample

{
    "data": null,
    "errorCode": 0,
    "message": "success",
    "success": true
}

✅4. Enterprise query balance interface

Interface description

Check account balance

Interface address

GET /ai-api/v1/account/banlance

Request Head

Authorization: Bearer CPN-XXXXXXXXXXXXXXXXXXXXXX (enterprise token)

Returns the result

{
    "data": {
        "balance": 9830602 //Balance
    },
    "errorCode": 0,
    "line": null,
    "message": "success",
    "success": true
}

5. Fee enquiries

✅5.1 user fee enquiry

Look up the total chip consumption of the user. Note that some tasks are handled asynchronously and are time-consuming, resulting in delayed consumption.

Query the user's total cost or the user's group's total cost (at least one of the userId and groupId is not empty)

Interface description

Look up chip consumption for a single user.

Interface address

GET /ai-api/v1/costByUser

Request Head

Authorization: Bearer CPN-XXXXXXXXXXXXXXXXXXXXXX (enterprise token)

Request parameters

Parameter name

Required

Type

Description

userId

no

String

groupId

no

String

Sample request

curl /ai-api/v1/costByUser?userId=11&groupId= \
  -H "Content-Type: application/json" \
  -H "Authorization: xxxxx"   

Response parameters

Parameter name

Type

Description

usage

Integer

Chip consumption

Reply to sample

{
    "data": {
      "usage": 3332
    },
    "errorCode": 0,
    "message": "success",
    "success": true
}

✅5.2 Inquiry of details of user fees

Interface description

Look up chip consumption for a single user. Reverse by time (at least one of userId and groupId is not empty)

Interface address

GET /ai-api/v1/costListByUser

Request Head

Authorization: Bearer CPN-XXXXXXXXXXXXXXXXXXXXXX (enterprise token)

Request parameters

Parameter name

Required

Type

Description

userId

no

String

groupId

no

String

startTime

no

string

2024-01-10 00:00:00

endTime

no

string

2024-01-11 00:00:00

pageSize

yes

Integer

pageNum

yes

Integer

Sample request

curl /ai-api/v1/costListByUser?userId= \
  -H "Content-Type: application/json" \
  -H "Authorization: xxxxx"   

Response parameters

Parameter name

Type

Description

id

Long

ID of the consumption record

costUsage

Integer

User chip consumption

consumeTime

Date

Consumption time

consumeName

String

Consumer item name

Reply to sample

{
    "data": {​
        "isMore": 0,​
        "items": [​
        ​    {
              "id":"9999",
              "costUsage":8888,
              "consumeTime":3239923,
              "consumeName":"AI partner dialogue"
            },{
              "id":"9999",
              "costUsage":8888,
              "consumeTime":3239923,
              "consumeName":"AI partner dialogue"
            }
        ],​
        "pageNum": 1,​
        "pageSize": 10,​
        "startIndex": 0,​
        "totalCount": 2,​
        "totalPage": 1​
    },
    "errorCode": 0,
    "message": "success",
    "success": true
}