API Specification of the Relay

The OpenAPI specification of the Relay

Resources

The JSON schema of the OpenAPI Specification of the Relay can be found at:

The rendered document of the specification can be accessed at:

API List

Create an inference task

POST/v1/inference_tasks
Body
signature*string

Signature

task_args*string

Task arguments

task_id*integer (int64)

Task id

timestamp*integer (int64)

Signature timestamp

Response

OK

Body
dataInferenceTask (object)
messagestring

The response message. Will be 'success' or a detailed error type

Request
const response = await fetch('/v1/inference_tasks', {
    method: 'POST',
    headers: {
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      "signature": "text",
      "task_args": "text"
    }),
});
const data = await response.json();
Response
{
  "data": {
    "CreatedAt": "2024-07-23T12:14:18.177Z",
    "DeletedAt": {
      "Time": "2024-07-23T12:14:18.177Z",
      "Valid": false
    },
    "SelectedNodes": [
      {
        "CreatedAt": "2024-07-23T12:14:18.177Z",
        "DeletedAt": {
          "Time": "2024-07-23T12:14:18.177Z",
          "Valid": false
        },
        "IsResultSelected": false,
        "NodeAddress": "text",
        "Result": "text",
        "UpdatedAt": "2024-07-23T12:14:18.177Z"
      }
    ],
    "UpdatedAt": "2024-07-23T12:14:18.177Z",
    "creator": "text",
    "data_hash": "text",
    "task_args": "text",
    "task_hash": "text"
  },
  "message": "text"
}

Get an inference task by task id

GET/v1/inference_tasks/{task_id}
Path parameters
task_id*integer (int64)

The task id

Query parameters
Response

OK

Body
dataInferenceTask (object)
messagestring

The response message. Will be 'success' or a detailed error type

Request
const response = await fetch('/v1/inference_tasks/{task_id}', {
    method: 'GET',
    headers: {},
});
const data = await response.json();
Response
{
  "data": {
    "CreatedAt": "2024-07-23T12:14:18.177Z",
    "DeletedAt": {
      "Time": "2024-07-23T12:14:18.177Z",
      "Valid": false
    },
    "SelectedNodes": [
      {
        "CreatedAt": "2024-07-23T12:14:18.177Z",
        "DeletedAt": {
          "Time": "2024-07-23T12:14:18.177Z",
          "Valid": false
        },
        "IsResultSelected": false,
        "NodeAddress": "text",
        "Result": "text",
        "UpdatedAt": "2024-07-23T12:14:18.177Z"
      }
    ],
    "UpdatedAt": "2024-07-23T12:14:18.177Z",
    "creator": "text",
    "data_hash": "text",
    "task_args": "text",
    "task_hash": "text"
  },
  "message": "text"
}

Upload inference task result

POST/v1/inference_tasks/{task_id}/results
Path parameters
task_id*integer (int64)

Task id

Body
signature*string

Signature

timestamp*integer (int64)

Signature timestamp

Response

OK

Body
messagestring

The response message. Will be 'success' or a detailed error type

Request
const response = await fetch('/v1/inference_tasks/{task_id}/results', {
    method: 'POST',
    headers: {
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      "signature": "text"
    }),
});
const data = await response.json();
Response
{
  "message": "text"
}

Get the result of the inference task by node address

GET/v1/inference_tasks/{task_id}/results/{image_num}
Path parameters
image_num*string

Image number

task_id*integer (int64)

Task id

Query parameters
Response

OK

Request
const response = await fetch('/v1/inference_tasks/{task_id}/results/{image_num}', {
    method: 'GET',
    headers: {},
});
const data = await response.json();

Get total TFLOPS of the network

GET/v1/network
Response

OK

Body
dataNetworkTFLOPS (object)
messagestring

The response message. Will be 'success' or a detailed error type

Request
const response = await fetch('/v1/network', {
    method: 'GET',
    headers: {},
});
const data = await response.json();
Response
{
  "data": {
    "tflops": 0
  },
  "message": "text"
}

Get the info of all the nodes in the network

GET/v1/network/nodes/data
Query parameters
Response

OK

Body
dataarray of NetworkNodeData (object)
messagestring

The response message. Will be 'success' or a detailed error type

Request
const response = await fetch('/v1/network/nodes/data', {
    method: 'GET',
    headers: {},
});
const data = await response.json();
Response
{
  "data": [
    {
      "CreatedAt": "2024-07-23T12:14:18.177Z",
      "DeletedAt": {
        "Time": "2024-07-23T12:14:18.177Z",
        "Valid": false
      },
      "UpdatedAt": "2024-07-23T12:14:18.177Z",
      "address": "text",
      "card_model": "text"
    }
  ],
  "message": "text"
}

Get total nodes number in the network

GET/v1/network/nodes/number
Response

OK

Body
dataAllNodeNumber (object)
messagestring

The response message. Will be 'success' or a detailed error type

Request
const response = await fetch('/v1/network/nodes/number', {
    method: 'GET',
    headers: {},
});
const data = await response.json();
Response
{
  "data": {},
  "message": "text"
}

Get total task number in the network

GET/v1/network/tasks/number
Response

OK

Body
dataAllTaskNumber (object)
messagestring

The response message. Will be 'success' or a detailed error type

Request
const response = await fetch('/v1/network/tasks/number', {
    method: 'GET',
    headers: {},
});
const data = await response.json();
Response
{
  "data": {},
  "message": "text"
}

Other APIs

Get current unix timestamp of server

GET/v1/now
Response

OK

Body
dataNowTimestamp (object)
messagestring

The response message. Will be 'success' or a detailed error type

Request
const response = await fetch('/v1/now', {
    method: 'GET',
    headers: {},
});
const data = await response.json();
Response
{
  "data": {},
  "message": "text"
}

Last updated