0572.html 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  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="How To,Tutorial,i12bretro,Proxmox,Proxmox VE,Hypervisor,API,Application Programming Interface,Linux,Debian,Postman">
  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. <link rel="icon" type="image/x-icon" href="includes/favicon.ico">
  12. <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
  13. <script type="text/javascript" src="includes/js/steps.js"></script>
  14. <link href="css/steps.css" rel="stylesheet" type="text/css" />
  15. </head>
  16. <body>
  17. <div id="gridContainer">
  18. <div class="topMargin"></div>
  19. <div id="listName" class="topMargin">
  20. <h1>Quick Overview of Proxmox VE REST API</h1>
  21. </div>
  22. <div></div>
  23. <div id="content">
  24. <h2>Creating An API User</h2>
  25. <ol>
  26. <li>Log into the Proxmox VE web UI</li>
  27. <li>Select Datacenter from the left navigation menu</li>
  28. <li>Select Users from the left sub-navigation menu</li>
  29. <li>Click the Add button at the top of the main content area</li>
  30. <li>Enter the Username API, set the Realm to Proxmox VE authentication server and set and confirm a password &gt; Click Add</li>
  31. <li>Select API Tokens from the left sub-navigation menu</li>
  32. <li>Select API@pve for the username</li>
  33. <li>Enter a secret key into the Token ID field &gt; Click Add
  34. <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>
  35. </li>
  36. <li>Copy the displayed Token ID and Secret to a text document for use later</li>
  37. <li>Close the dialog</li>
  38. <li>Select Roles from the left sub-navigation menu</li>
  39. <li>Click the Create button at the top of the main content area</li>
  40. <li>Name the new role APIAdmin and select all available Privileges &gt; Click Create
  41. <p>NOTE: These permissions can be fine-tuned later<br />
  42. 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>
  43. </li>
  44. <li>Select Permissions from the left sub-navigation menu</li>
  45. <li>Select the Add &gt; User permission at the top of the main content area</li>
  46. <li>Set the Path to /, select the API@pve user and set the Role to APIAdmin &gt; Click Add</li>
  47. </ol>
  48. <h2>Downloading Postman</h2>
  49. <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>
  50. <ol>
  51. <li>Download Postman <a href="https://github.com/portapps/postman-portable/releases" target="_blank">Download</a></li>
  52. <li>Extract or install Postman</li>
  53. <li>Launch Postman</li>
  54. <li>Click the Skip and go to app link at the bottom left of the splash screen</li>
  55. <li>Select File &gt; Settings from the top menu bar</li>
  56. <li>Disable SSL Certificate Verification and Send anonymous usage data to Postman &gt; Close the Settings dialog window</li>
  57. </ol>
  58. <h2>Proxmox API Authentication</h2>
  59. <ol>
  60. <li>In Postman, click the + next to the Overview tab to create a new HTTP request tab</li>
  61. <li>Complete the HTTP Request form as follows:
  62. <ul style="list-style-type: none;">
  63. <li>Method: POST</li>
  64. <li>URL: https://DNSorIP:8006/api2/json/access/ticket</li>
  65. <li>Body: x-www-form-urlencoded
  66. <ul>
  67. <li>username: API@pve</li>
  68. <li>password: &lt;API@pve Password&gt;</li>
  69. </ul>
  70. </li>
  71. </ul>
  72. </li>
  73. <li>Click the Send button</li>
  74. <li>From the response, copy the ticket value and CSRFPreventionToken values to a text document for use later</li>
  75. </ol>
  76. <h2>Proxmox Version API Call</h2>
  77. <ol>
  78. <li>In Postman, click the + next to the Overview tab to create a new HTTP request tab</li>
  79. <li>Click the Cookies link below the send button</li>
  80. <li>Type the API URL up to /json/, (ie https://DNSorIP:8006/api2/json/) &gt; Click Add</li>
  81. <li>Click Add Cookie</li>
  82. <li>Replace the Cookie_1 key with PVEAuthCookie</li>
  83. <li>Replace the value with the ticket value from authentication response, the result should look like
  84. <p>PVEAuthCookie=PVE:API@pve:611F9752::aXrYKYqiv8oV/MetlZl6FC40HSULSj4gt9EjDsTIwq+GXVXpkGyqvMlXqmGP6LP/rUYUgIKkSh9ioEhz91kR9/i+jDobDFIAtjBGLIP4yJVbxbtU6hfJL91YQNyYgvHqkPv4/W6EYWir5+LFQc3womgqVE9gKApk61J8zxFNTTjwh87HbMAtv12fvAqiICEqRMdqvE6ySJF5a8E+rOlqa46MlTbUTnzCbqPTY6tWBYHryy8WS8Typ3aSkOKecup18sCBtzqxnkm9bpws+f8vW9FdJV8eKnR+MbFLQtv/re5Cw/J7RpdvcQvMsZ0JLFWqnTaPgRzBc/mM7xZBKeCiSA==</p>
  85. </li>
  86. <li>Click Save &gt; Close the Manage Cookies dialog window</li>
  87. <li>Complete the HTTP Request form as follows:
  88. <ul style="list-style-type: none;">
  89. <li>Method: GET</li>
  90. <li>URL: https://DNSorIP:8006/api2/json/version</li>
  91. <li>Headers:
  92. <ul>
  93. <li>CSRFPreventionToken: &lt;CSRFPreventionToken value from authentication response&gt;</li>
  94. </ul>
  95. </li>
  96. </ul>
  97. </li>
  98. <li>Click the Send button</li>
  99. <li>The response body should show details about the current Proxmox version</li>
  100. </ol>
  101. <h2>Proxmox Nodes API Call</h2>
  102. <ol>
  103. <li>In Postman, right click the /version HTTP request tab &gt; Duplicate Tab</li>
  104. <li>Change the URL to https://DNSorIP:8006/api2/json/nodes</li>
  105. <li>Click the Send button</li>
  106. <li>The response body should show details about the available Proxmox node(s)</li>
  107. </ol>
  108. <h2>Proxmox Node Status API Call</h2>
  109. <ol>
  110. <li>In Postman, right click the /version HTTP request tab &gt; Duplicate Tab</li>
  111. <li>Change the URL to https://DNSorIP:8006/api2/json/nodes/&lt;node name&gt;/status</li>
  112. <li>Click the Send button</li>
  113. <li>The response body should show details about the selected Proxmox node</li>
  114. </ol>
  115. <p>Simple PHP API Communication Demo <a href="https://raw.githubusercontent.com/i12bretro/tutorials/main/_Downloads/proxmox_api.php" target="_blank">Download</a></p>
  116. <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 />
  117. 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>
  118. </div>
  119. </div>
  120. </body>
  121. </html>