Overview
The Kaspa Developer Platform (KDP) API uses API keys to authenticate requests. You can get your API key by signing up at developer.kas.fyi.
Using Your API Key
Include your API key in the x-api-key
header with each request:
curl https://api.kas.fyi/addresses/kaspa:qpzpfwcsqsxhxwup26r55fd0ghqlhyugz8cp6y3wxuddc02vcxtjg75pspnwz/tag \
-H "x-api-key: YOUR_API_KEY"
Keep your API key secure and never expose it in client-side code or public repositories.
Example Usage
JavaScript/TypeScript
const response = await fetch('https://api.kas.fyi/addresses/kaspa:qpzpfwcsqsxhxwup26r55fd0ghqlhyugz8cp6y3wxuddc02vcxtjg75pspnwz/tag', {
headers: {
'x-api-key': 'YOUR_API_KEY'
}
});
const data = await response.json();
Python
import requests
headers = {
'x-api-key': 'YOUR_API_KEY'
}
response = requests.get(
'https://api.kas.fyi/addresses/kaspa:qpzpfwcsqsxhxwup26r55fd0ghqlhyugz8cp6y3wxuddc02vcxtjg75pspnwz/tag',
headers=headers
)
data = response.json()
client := &http.Client{}
req, _ := http.NewRequest("GET", "https://api.kas.fyi/addresses/kaspa:qpzpfwcsqsxhxwup26r55fd0ghqlhyugz8cp6y3wxuddc02vcxtjg75pspnwz/tag", nil)
req.Header.Add("x-api-key", "YOUR_API_KEY")
resp, _ := client.Do(req)
Best Practices
- Store API keys securely: Use environment variables or secure key management services
- Rotate keys regularly: Generate new API keys periodically for better security
- Monitor usage: Keep track of your API usage to avoid hitting rate limits
- Use HTTPS only: Always make requests over HTTPS to protect your API key
Error Handling
If your API key is missing or invalid, you’ll receive a 401 Unauthorized
response:
{
"statusCode": 401,
"message": "x-api-key is missing from header"
}
or
{
"statusCode": 401,
"message": "Invalid API key"
}