0572.html 6.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>Quick Overview of Proxmox VE REST API</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <meta charset="UTF-8">
  7. <meta name="keywords" content="Proxmox,Proxmox VE,Hypervisor,API,Application Programming Interface,Linux,Debian,Postman,How To,Tutorial,i12bretro">
  8. <meta name="author" content="i12bretro">
  9. <meta name="description" content="Quick Overview of Proxmox VE REST API">
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  11. <meta name="revised" content="05/28/2022 01:41:03 PM" />
  12. <link rel="icon" type="image/x-icon" href="includes/favicon.ico">
  13. <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
  14. <script type="text/javascript" src="includes/js/steps.js"></script>
  15. <link href="css/steps.css" rel="stylesheet" type="text/css" />
  16. </head>
  17. <body>
  18. <div id="gridContainer">
  19. <div class="topMargin"></div>
  20. <div id="listName" class="topMargin">
  21. <h1>Quick Overview of Proxmox VE REST API</h1>
  22. </div>
  23. <div></div>
  24. <div id="content">
  25. <h2>Creating An API User</h2>
  26. <ol>
  27. <li>Log into the Proxmox VE web UI</li>
  28. <li>Select Datacenter from the left navigation menu</li>
  29. <li>Select Users from the left sub-navigation menu</li>
  30. <li>Click the Add button at the top of the main content area</li>
  31. <li>Enter the Username API, set the Realm to Proxmox VE authentication server and set and confirm a password &gt; Click Add</li>
  32. <li>Select API Tokens from the left sub-navigation menu</li>
  33. <li>Select API@pve for the username</li>
  34. <li>Enter a secret key into the Token ID field &gt; Click Add
  35. <p><em>TIP: Use a random string generator to create a unique Token ID</em> <a href="https://www.random.org/passwords/?num=1&amp;len=24&amp;format=plain&amp;rnd=new" target="_blank">String Generator</a></p>
  36. </li>
  37. <li>Copy the displayed Token ID and Secret to a text document for use later</li>
  38. <li>Close the dialog</li>
  39. <li>Select Roles from the left sub-navigation menu</li>
  40. <li>Click the Create button at the top of the main content area</li>
  41. <li>Name the new role APIAdmin and select all available Privileges &gt; Click Create
  42. <p>NOTE: These permissions can be fine-tuned later<br />
  43. INFO: More information on each privilege can be found <a href="https://pve.proxmox.com/pve-docs/pve-admin-guide.html#pveum_permission_management" target="_blank">here</a></p>
  44. </li>
  45. <li>Select Permissions from the left sub-navigation menu</li>
  46. <li>Select the Add &gt; User permission at the top of the main content area</li>
  47. <li>Set the Path to /, select the API@pve user and set the Role to APIAdmin &gt; Click Add</li>
  48. </ol>
  49. <h2>Downloading Postman</h2>
  50. <p><em>Postman is an API platform for building and using APIs. Postman simplifies each step of the API lifecycle and streamlines collaboration so you can create better APIs&mdash;faster.</em> - <a href="https://postman.com" target="_blank">https://postman.com</a></p>
  51. <ol>
  52. <li>Download Postman <a href="https://github.com/portapps/postman-portable/releases" target="_blank">Download</a></li>
  53. <li>Extract or install Postman</li>
  54. <li>Launch Postman</li>
  55. <li>Click the Skip and go to app link at the bottom left of the splash screen</li>
  56. <li>Select File &gt; Settings from the top menu bar</li>
  57. <li>Disable SSL Certificate Verification and Send anonymous usage data to Postman &gt; Close the Settings dialog window</li>
  58. </ol>
  59. <h2>Proxmox API Authentication</h2>
  60. <ol>
  61. <li>In Postman, click the + next to the Overview tab to create a new HTTP request tab</li>
  62. <li>Complete the HTTP Request form as follows:
  63. <ul style="list-style-type: none;">
  64. <li>Method: POST</li>
  65. <li>URL: https://DNSorIP:8006/api2/json/access/ticket</li>
  66. <li>Body: x-www-form-urlencoded
  67. <ul>
  68. <li>username: API@pve</li>
  69. <li>password: &lt;API@pve Password&gt;</li>
  70. </ul>
  71. </li>
  72. </ul>
  73. </li>
  74. <li>Click the Send button</li>
  75. <li>From the response, copy the ticket value and CSRFPreventionToken values to a text document for use later</li>
  76. </ol>
  77. <h2>Proxmox Version API Call</h2>
  78. <ol>
  79. <li>In Postman, click the + next to the Overview tab to create a new HTTP request tab</li>
  80. <li>Click the Cookies link below the send button</li>
  81. <li>Type the API URL up to /json/, (ie https://DNSorIP:8006/api2/json/) &gt; Click Add</li>
  82. <li>Click Add Cookie</li>
  83. <li>Replace the Cookie_1 key with PVEAuthCookie</li>
  84. <li>Replace the value with the ticket value from authentication response, the result should look like
  85. <p>PVEAuthCookie=PVE:API@pve:611F9752::aXrYKYqiv8oV/MetlZl6FC40HSULSj4gt9EjDsTIwq+GXVXpkGyqvMlXqmGP6LP/rUYUgIKkSh9ioEhz91kR9/i+jDobDFIAtjBGLIP4yJVbxbtU6hfJL91YQNyYgvHqkPv4/W6EYWir5+LFQc3womgqVE9gKApk61J8zxFNTTjwh87HbMAtv12fvAqiICEqRMdqvE6ySJF5a8E+rOlqa46MlTbUTnzCbqPTY6tWBYHryy8WS8Typ3aSkOKecup18sCBtzqxnkm9bpws+f8vW9FdJV8eKnR+MbFLQtv/re5Cw/J7RpdvcQvMsZ0JLFWqnTaPgRzBc/mM7xZBKeCiSA==</p>
  86. </li>
  87. <li>Click Save &gt; Close the Manage Cookies dialog window</li>
  88. <li>Complete the HTTP Request form as follows:
  89. <ul style="list-style-type: none;">
  90. <li>Method: GET</li>
  91. <li>URL: https://DNSorIP:8006/api2/json/version</li>
  92. <li>Headers:
  93. <ul>
  94. <li>CSRFPreventionToken: &lt;CSRFPreventionToken value from authentication response&gt;</li>
  95. </ul>
  96. </li>
  97. </ul>
  98. </li>
  99. <li>Click the Send button</li>
  100. <li>The response body should show details about the current Proxmox version</li>
  101. </ol>
  102. <h2>Proxmox Nodes API Call</h2>
  103. <ol>
  104. <li>In Postman, right click the /version HTTP request tab &gt; Duplicate Tab</li>
  105. <li>Change the URL to https://DNSorIP:8006/api2/json/nodes</li>
  106. <li>Click the Send button</li>
  107. <li>The response body should show details about the available Proxmox node(s)</li>
  108. </ol>
  109. <h2>Proxmox Node Status API Call</h2>
  110. <ol>
  111. <li>In Postman, right click the /version HTTP request tab &gt; Duplicate Tab</li>
  112. <li>Change the URL to https://DNSorIP:8006/api2/json/nodes/&lt;node name&gt;/status</li>
  113. <li>Click the Send button</li>
  114. <li>The response body should show details about the selected Proxmox node</li>
  115. </ol>
  116. <p>Simple PHP API Communication Demo <a href="https://raw.githubusercontent.com/i12bretro/tutorials/main/_Downloads/proxmox_api.php" target="_blank">Download</a></p>
  117. <p>Proxmox VE API Wiki: <a href="https://pve.proxmox.com/wiki/Proxmox_VE_API" target="_blank">https://pve.proxmox.com/wiki/Proxmox_VE_API</a><br />
  118. Proxmox VE Visual API Reference: <a href="https://pve.proxmox.com/pve-docs/api-viewer/index.html" target="_blank">https://pve.proxmox.com/pve-docs/api-viewer/index.html</a></p>
  119. </div>
  120. </div>
  121. </body>
  122. </html>