API Key
Generating an API Key
API keys can be created on the API Access page. After you've generated your key, all you need to do is add it to the x-messari-api-key
HTTP header to start making requests.
Using the API key
To access the Messari API, you must authenticate your requests using an API key. The API key must be included in the request headers using the x-messari-api-key
header field. This ensures secure access and proper authorization for your API requests.
Example Request (cURL)
The following example demonstrates how to send a request to the Messari API using cURL with the x-messari-api-key
header:
curl --location 'https://api.messari.io/ai/v1/chat/completions' \
--header 'x-messari-api-key: YOUR_API_KEY_HERE' \
--header 'Content-Type: application/json' \
--data '{
"messages": [
{
"role": "user",
"content": "Briefly explain what the Hyperliquid HyperEVM is"
}
],
"verbosity": "succinct",
"response_format": "markdown"
}'
Security Best Practices
- Keep Your API Key Secure: Never share your API key publicly or commit it to version control (e.g., GitHub).
- Use Environment Variables: Store API keys in environment variables rather than hardcoding them in your code.
- Rotate API Keys Regularly: Periodically update your API key for security purposes.