Configure REST API


You can use the Portworx Backup API to create, delete, schedule, and restore backups. This API is organized around REST and returns responses in JSON format.

To configure rest APIs, you need to expose Swagger UI and then fetch an access token for the instance.

Expose Swagger UI

To expose Swagger UI in Portworx Backup:

  1. Expose px-backup deployment as REST interface:

    $ kubectl expose deployment -n px-backup px-backup --type=NodePort --port=10001 --name px-backup-rest service/px-backup-rest exposed
  2. Check if the service is properly created:

    $ kubectl get service -n px-backup | grep rest px-backup-rest              NodePort       <node_IP>    <none>        10001:<node_port>/TCP       25s
  3. Open the swagger UI endpoint http://(NodeIP:NodePort)/swagger-ui/ in your web browser to access the API through swagger:

    Swagger json

Fetch an access token

To fetch the token for an instance, perform the following steps:

  1. Fetch access token:

    curl --data 'grant_type=password&client_id=pxcentral&username=admin&password=Password1&token-duration=365d' http://<IP>:<Port>/auth/realms/master/protocol/openid-connect/token --silent | jq -r ".access_token"
  2. Add the token:

    • Click Authorize on the Swagger UI page.
    • Add the token generated with the Bearer prefix.
    • Click Authorize on Available authorizations.
    • Click Close.

      Authorize Window


Last edited: Tuesday, Apr 18, 2023