API Authentication
To securely interact with the PureGPU API, you need to authenticate your requests. PureGPU offers two methods of authentication: API key authentication and session cookie authentication. We highly recommend using API key authentication for its reliability and ease of use.
API Key Authentication
API key authentication is the preferred method for accessing the PureGPU API. This method involves including an X-API-Key
header in your HTTP requests.
Steps to Authenticate Using an API Key
-
Retrieve Your API Key:
- Go to your PureGPU dashboard.
- Navigate to the Settings section.
- Under API, you will find your API key. If you don't have one, generate a new API key.
-
Include the API Key in Your Requests:
- Add the
X-API-Key
header to your HTTP requests. - Example using cURL:
- Add the
curl -X GET https://api.puregpu.com/endpoint \
-H "X-API-Key: {token}"
Session Cookie Authentication
Session cookie authentication involves logging in with your user credentials to obtain a session cookie. While this method is supported, it is discouraged due to the session cookie's expiration and the need to log in frequently.
Steps to Authenticate Using a Session Cookie
-
Login to Obtain a Session Cookie:
- Send a POST request to the login endpoint with your user credentials.
- The response will include a session cookie.
-
Include the Session Cookie in Your Requests:
- Add the cookie to the
Cookie
header in your HTTP requests. - Example using cURL:
- Add the cookie to the
curl -X GET https://api.puregpu.com/endpoint \
-H "Cookie: connect.sid=your_session_cookie_here"
Example Request
curl -X GET https://api.puregpu.com/servers \
-H "Cookie: connect.sid=your_session_cookie_here"
While this method works, be aware that the session cookie may expire, requiring you to log in again.
For secure and consistent access, we recommend using API key authentication. Always keep your API key confidential and rotate it regularly to maintain security. If you have any questions or need further assistance, please refer to our detailed documentation or contact PureGPU support.