Getting Started with HPKV
Getting Started with HPKV
1. Generate an API Key
To start using HPKV, you'll need an API key. You can generate one in the API Keys section of the Dashboard:
- Go to the API Keys section
- Click "Generate API Key"
- Select your preferred region
- Add an optional description to help you identify this key later
- Save your API key securely - you won't be able to see it again
2. Choose Your API
HPKV offers three APIs for interacting with your data:
- REST API: Simple HTTP-based interface, great for getting started and typical use cases
- WebSocket API: High-performance interface, ideal for frequent operations
- Business+RIOC API: Ultra-low latency RPC protocol, perfect for performance-critical applications
3. Make Your First Request
Here's a simple example using the REST API to store and retrieve data:
Store a value:
curl -X POST https://YOUR_BASE_URL/record \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_API_KEY" \
-d '{"key": "greeting", "value": "Hello, HPKV!"}'
Retrieve the value:
curl https://YOUR_BASE_URL/record/greeting \
-H "x-api-key: YOUR_API_KEY"
4. Using WebSocket API
For high-performance applications, you can use the WebSocket API. Here's a simple example using JavaScript:
const ws = new WebSocket('wss://YOUR_BASE_URL/ws?apiKey=YOUR_API_KEY');
ws.onopen = () => {
// Store a value
ws.send(JSON.stringify({
op: 2, // Insert operation
key: 'greeting',
value: 'Hello from WebSocket!',
messageId: 1 // Optional
}));
// Retrieve a value
ws.send(JSON.stringify({
op: 1, // Get operation
key: 'greeting',
messageId: 2 // Optional
}));
};
ws.onmessage = (event) => {
const response = JSON.parse(event.data);
console.log('Received:', response);
};
5. Next Steps
Now that you've made your first requests, you can explore the full capabilities of HPKV:
- Learn about all available endpoints in the REST API documentation
- Explore the high-performance options in the WebSocket API documentation
- Check out our SDK Guides for language-specific integration examples
- Review our Best Practices to ensure you're using HPKV optimally
Important Notes
- Keep your API key secure and never expose it in client-side code
- Each API key has its own rate limits and storage quotas
- Use HTTPS/WSS for all API calls to ensure data security
- Monitor your usage to stay within your plan's limits