OPENAPI

Request Introduction

1.Domain name:

https://openapi.emchub.ai

2.Request Method:

POST, Content-Type is application/json.

3.Character Encoding:

UTF-8

4.Interface Parameter Description:

ParameterTypeRequiredDescription

appid

String

Yes

Fixed value issued by the open platform, e.g., cat

nonce

String

Yes

Random numeric string

action

String

Yes

Request interface name, action = specific business name

sign

String

Yes

Signature

requestBody

String

Yes

Specific business request parameters

The requestBody parameter format is a JSON string, for example: {"name":"create"}. If there are no parameters in the requestBody parameter for the request interface, pass an empty JSON string, for example: {}.

Signature Generation Steps

Step 1: Concatenate the interface parameters appid, nonce, action, and requestBody into a string called stringA using the URL key-value pair format (i.e., key1=value1&key2=value2...).

Step 2: Append the secret to the end of stringA to obtain the stringSignTemp string. Calculate the SHA1 hash of stringSignTemp to obtain the sign value, signValue.

Assuming the following parameters are being sent:

appid: cat_shark
action: walletCreate
nonce: 1226202735 
requestBody:{"phone":"13900001111","wallet_type":0}

Step 1: Generate StringA by formatting the parameters in the key=value format.

stringA="appid=cat_shark&nonce=1226202735&action=walletCreate&requestBody= {"phone":"13900001111","wallet_type":0}"

Step 2: Concatenate the API secret key.

For example, if the secret key provided by the open platform is "ef149163-276e-11ed-8589- b8599f24f354".

stringSignTemp=stringA+"&secret=ef149163-276e-11ed-8589-b8599f24f354" sign=SHA1(stringSignTemp)="376e0de35aade4117fc00c69a2c5b25421a8e083"

When using SHA1 encryption, use the UTF-8 character encoding.

Random Numeric String Generation (Nonce)

It is recommended to generate a random numeric string using a random function and then convert it to a string.

Interface and Specific Business Parameters

EXECUTETASK

API Description:

This API is used to submit a request to the server for executeTask. Upon receiving the request, the server will save the current task and add it to the processing queue. Once the processing is complete, the server will send an asynchronous notification through the provided callback interface.

API PATH : /emchub/api/client/open/executeTask

action: executeTask

requestBody Parameterrequiretypedescription

apiPath

Yes

String

apiPath

apiMethod

Yes

String

apiMethod

modelHash

Yes

String

modelHash

appOrigin

Yes

String

appOrigin

taskType

No

Integer

type value : default 4 generic

0 TEXTTOIMAGE

2 llm

4 generic

generativeParameters

Yes

Json String

parameter

callbackUrl

No

String

Async callback notification address when the text-to-image task is completed; the callback interface uses POST requests uniformly, with Content-Type in application/json format; when the json object returned by the callback interface contains the _result field of 0, it indicates a successful callback, and other cases indicate a callback failure, and a callback notification will be issued again;

generativeParameters :

{
    "eg":"11"
}

Response Example:

{
    "_result": 0,
    "_desc": "success",
    "_sid": null,
    "_login": false,
    "data": {
        "id": 1,
        "taskSn": "",
        "appId": "",
        "modelHash": "",
        "nodeId": "",
        "generativeParameters": "{"prompt":"draw a rabbit"}", "taskType": 0,
        "fileUrl": null,
        "createTime": "2023-08-30T02:35:56.872+0000", "status": 0,
        "requestTimes": null,
        "finishTime": null,
        "callbackTime": null,
        "callbackStatus": null,
        "callbackUrl": "http://",
        "callbackType": null
    }
}
NameNameDescription

id

Integer

Primary key

taskSn

String

Task serial number

appId

String

Application ID

modelHash

String

Model hash

nodeId

String

Node ID

generativeParameters

String

Generative parameters

taskType

Integer

Task type (0: Text-to-Image)

fileUrl

String

File path

createTime

Date

Creation time

Name

Type

Description

-

-

-

status

Integer

Status: 0 - Pending, 1 - In Progress, 2 - Completed, 3 - Failed, 4 - Timeout, 5 - Deleted

requestTimes

Integer

Number of task execution attempts (if exceeded, the generative process fails)

finishTime

Date

Task completion time

callbackTime

Date

Callback time

callbackStatus

Integer

Callback status: 0 - Waiting for completion callback, 1 - Callback in progress, 2 - Callback successful, 3 - Callback failed, 4 - Callback timeout

callbackUrl

String

Callback URL

callbackType

String

Callback strategy (used for retrying failed callbacks)

Query Task Result

API Description:

Query task details based on the task SN.

API PATH : /emchub/api/client/open/queryTaskBySn Action: queryTaskBySn

requestBody ParameterRequiredTypeDescription

taskSn

Yes

String

Unique task serial number

Response Example:

{
    "_result": 0,
    "_desc": "success",
    "_sid": null,
    "_login": false,
    "data": {} // task object returned 
}

Last updated