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:

  1. Go to the API Keys section
  2. Click "Generate API Key"
  3. Select your preferred region
  4. Add an optional description to help you identify this key later
  5. 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:

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