API Authentication
Learn how to authenticate your requests to the 0xHost API
Overview
The 0xHost API uses API keys to secure your requests. All API requests must include your API key in the request header.
Generating Your API Key
Log in to Your Account
Access your 0xHost client area by logging in at https://0xhost.net
Navigate to API Keys Section
Go to the API Keys management page at:
https://0xhost.net/keys/
Generate New API Key
Click on the "Generate New API Key" button and configure the following settings:
- Key Name: Give your key a descriptive name (e.g., "Production Server", "Development App")
- IP Restrictions (Optional): Limit key usage to specific IP addresses for enhanced security
- Expiration (Optional): Set an expiration date for temporary access
Copy and Secure Your Key
Once generated, copy your API key immediately. For security reasons, the key will only be shown once.
Use Your API Key
Include your API key in the x-api-key header of all your API requests.
API Key Authentication
Required for all API requestsUse API keys for all API communication. Generate keys from your client area with specific permissions.
Headers:
x-api-key: your_api_key_here
Content-Type: application/json
- No session management required
- Perfect for automated scripts and server-to-server communication
- Can be restricted by IP address
- Simple and secure authentication method
Implementation Examples
JavaScript (Fetch)
// Using API Key
const response = await fetch('https://0xhost.net/API/endpoint', {
method: 'GET',
headers: {
'x-api-key': 'your_api_key_here',
'Content-Type': 'application/json'
}
});
PHP (cURL)
// Using API Key
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://0xhost.net/API/endpoint');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'x-api-key: your_api_key_here',
'Content-Type: application/json'
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
Security Best Practices
Store Keys Securely
Never commit API keys to version control. Use environment variables or secure secret management.
Use IP Restrictions
Restrict API keys to specific IP addresses when possible to prevent unauthorized use.
Rotate Keys Regularly
Regularly rotate your API keys and update them in your applications.
Use HTTPS Only
Always make API requests over HTTPS to encrypt data in transit.