API Token

API Token provides a way to access the Openresty Edge Admin API without account and password, Set the HTTP request header: API-Token: {token}, such as API-Token: 1df87165-3593-4eca-a910-9ac200012345.

Example (Replace admin-host with our actual admin host name or IP address):

curl "https://{admin-host}/admin-api/global/1/ngx/?detail=1" -H "API-Token: 1df87165-3593-4eca-a910-9ac20005e6ec" -k

Get API token list

Description

Get API token list

URI

GET /admin-api/api_token

URI Parameters

  • start

    type: integer

    required: no

    description: Start offset

  • end

    type: integer

    required: no

    description: End offset

  • page

    type: integer

    required: no

    description: Results page (default 1)

  • page_size

    type: integer

    required: no

    description: Results page size (default 20)

  • detail

    type: integer

    required: no

    description: Are detailed results required (default 0)

Example Request

Shell


curl 'https://{admin-site}/admin-api/api_token?start=0&end=19&page=1&page_size=20&detail=1'

Example Response

Status: 200 OK
{
    "status":0,
    "data":{
        "data":[
            {
                "id":2,
                "_created_unix":1618905030.9693,
                "_modified_unix":1618905030.9693,
                "name":"test",
                "expire":1619769023072
            },
            {
                "id":1,
                "_created_unix":1618891253.4172,
                "_modified_unix":1618891253.4172,
                "name":"k8s-robots",
                "expire":0          // 0 means never expires
            }
        ],
        "meta":{
            "count":2
        }
    }
}

Get API token

Description

Get API token

URI

GET /admin-api/api_token/{api-token-id}

URI Parameters

  • detail

    type: integer

    required: no

    description: Are detailed results required (default 0)

Example Request

Shell


curl 'https://{admin-site}/admin-api/api_token/2?detail=1'

Example Response

Status: 200 OK
{
    "status":0,
    "data":{
        "id":2,
        "_created_unix":1618905030.9693,
        "_modified_unix":1618905030.9693,
        "name":"test",
        "expire":1619769023072
    }
}

Create API token

Description

Create API token

URI

POST /admin-api/api_token

JSON Body Parameters

{
    "name":"test-1",
    "expire":1619682623072
}

Example Request

Shell

curl  https://{admin-site}/admin-api/api_token \
  -X 'POST' \
  -H 'Content-Type: application/json;charset=UTF-8' \
  --data-raw '{"name":"test-1","expire":1619682623072}'

Example Response

Status: 200 OK
{
    "status":0,
    "data":{
        "id":3,
        "token":"f8d486b5-a953-40b2-8508-e28893074bac",
        "_modified_unix":1618907592.5399,
        "_created_unix":1618907592.5399,
        "uid":1,
        "name":"test-1",
        "expire":1619682623072
    }
}

Update API token

Description

Update API token

URI

PUT /admin-api/api_token/{api-token-id}

JSON Body Parameters

{
    "name":"test-1",
    "expire":1619682623072
}

Example Request

Shell

curl  https://{admin-site}/admin-api/api_token/2 \
  -X 'PUT' \
  -H 'Content-Type: application/json;charset=UTF-8' \
  --data-raw '{"name":"test-1","expire":1619682623072}'

Example Response

Status: 200 OK
{"status":0}

Delete API token

Description

Delete API token

URI

DELETE /admin-api/api_token/{api-token-id}

Example Request

Shell

curl  https://{admin-site}/admin-api/api_token/2 \
  -X 'DELETE'

Example Response

Status: 200 OK
{"status":0}