Authentication overview

The Messari API provides programmatic access to cryptocurrency market intelligence, on-chain data, and fundamental metrics. To ensure secure and authorized access to its resources, Messari primarily utilizes API keys for authentication. This mechanism allows the API to identify the calling application and enforce access policies based on the user's subscription tier and granted permissions.

API keys serve as a unique identifier and a secret token that clients must provide with each request. When a request reaches the Messari API, the system validates the provided API key against its records. If the key is valid and authorized for the requested endpoint, the API processes the request and returns the data. Invalid or missing API keys will result in an authentication error, typically an HTTP 401 Unauthorized or 403 Forbidden status code, depending on the specific error condition.

Messari implements API key authentication to manage rate limits, track usage, and provide a granular control over data access. Users with a Messari account can generate and manage their API keys through the dedicated section of their account dashboard. The level of data accessible through the API key is directly tied to the user's subscription plan, ranging from the Messari Basic (free) tier with limited access to the comprehensive data available via Messari Pro and Enterprise subscriptions.

Supported authentication methods

Messari's API exclusively supports API key authentication for programmatic access. This method is common for web services where server-to-server communication or client applications need to identify themselves without requiring a full user login flow on every request.

Messari API Authentication Methods
Method When to Use Security Level
API Key Programmatic access for web applications, scripts, data dashboards, and integrations requiring access to Messari data.

Moderate: Relies on the secrecy of the key. Requires secure storage and transmission (HTTPS). Vulnerable if keys are exposed.

API keys are typically passed in the request header or as a query parameter. The Messari API documentation specifies that the API key should be included as a query parameter named x-messari-api-key in all requests to authenticated endpoints. This approach is straightforward to implement and widely understood by developers integrating with various APIs.

While API keys offer a practical solution for authentication, their security relies heavily on proper handling. Developers should treat API keys as sensitive credentials, similar to passwords, and implement robust security practices to prevent unauthorized access or disclosure. This includes using encrypted connections (HTTPS), storing keys securely, and avoiding hardcoding them directly into client-side code.

Getting your credentials

To access the Messari API, you need to obtain an API key from your Messari account. The process typically involves registering for a Messari account and then navigating to the API settings within your user dashboard.

  1. Sign Up or Log In: First, create an account or log in to your existing account on the Messari website.
  2. Access API Settings: Navigate to your account settings or a dedicated API section within your dashboard. The exact path may vary but is usually found under profile settings, developer settings, or similar.
  3. Generate API Key: Look for an option to generate a new API key. Messari provides detailed instructions on how to do this within their platform. You may be prompted to name your API key for easier management, especially if you plan to use multiple keys for different applications.
  4. Copy and Store Your Key: Once generated, your API key will be displayed. It is crucial to copy this key immediately and store it securely. For security reasons, Messari may only display the full key once, and you might not be able to retrieve it again if lost. If lost, you would typically need to generate a new key and revoke the old one.

Your API key grants access to Messari's data based on your current subscription level. Users on the Basic (free) plan will have limited access to data and endpoints, while Pro and Enterprise subscribers will have access to a broader range of data and higher rate limits. Refer to the Messari API documentation for specifics on endpoint access and rate limits per subscription tier.

Authenticated request example

Once you have obtained your Messari API key, you can use it to make authenticated requests to the API. The API key must be included as a query parameter named x-messari-api-key in every authenticated request.

Below is an example of an authenticated request using curl to fetch data for a specific asset, such as Bitcoin (btc). Replace YOUR_API_KEY with your actual Messari API key.


curl -X GET "https://api.messari.io/api/v1/assets/btc/metrics?x-messari-api-key=YOUR_API_KEY"

In this example:

  • -X GET specifies the HTTP GET method.
  • "https://api.messari.io/api/v1/assets/btc/metrics" is the endpoint for retrieving metrics for Bitcoin.
  • ?x-messari-api-key=YOUR_API_KEY is the query parameter where your API key is passed.

For client-side applications or environments where JavaScript is used, an example using the fetch API might look like this:


const apiKey = 'YOUR_API_KEY';
const assetId = 'btc';
const apiUrl = `https://api.messari.io/api/v1/assets/${assetId}/metrics?x-messari-api-key=${apiKey}`;

fetch(apiUrl)
  .then(response => {
    if (!response.ok) {
      throw new Error(`HTTP error! status: ${response.status}`);
    }
    return response.json();
  })
  .then(data => {
    console.log(data);
  })
  .catch(error => {
    console.error('Error fetching data:', error);
  });

Always ensure that your API key is not exposed in client-side code in production environments. For browser-based applications, consider using a backend proxy to make API calls, thus keeping your API key server-side and away from public view. Other programming languages and HTTP client libraries will have similar ways to append query parameters to URLs.

Security best practices

Securing your Messari API key is critical to prevent unauthorized access to your account's data and usage limits. Adhering to security best practices helps protect your applications and data from potential vulnerabilities.

  1. Keep API Keys Secret: Treat your API keys like passwords. Never hardcode them directly into client-side code (e.g., JavaScript in a public webpage) or commit them to public version control systems (e.g., GitHub). Store them in environment variables, secret management services, or encrypted configuration files. The Google Cloud API keys documentation provides general guidance on key security.
  2. Use HTTPS for All Requests: Always use HTTPS when communicating with the Messari API. This encrypts the data in transit, protecting your API key and the data exchanged from eavesdropping. The Messari API inherently operates over HTTPS.
  3. Restrict Key Permissions (if applicable): While Messari API keys generally grant access based on your subscription level, if Messari were to introduce more granular permissions in the future, always configure your keys with the minimal necessary permissions required for the specific application.
  4. Rotate API Keys Regularly: Periodically generate new API keys and revoke old ones. This practice reduces the window of opportunity for a compromised key to be exploited. If you suspect a key has been compromised, revoke it immediately and generate a new one.
  5. Monitor API Usage: Regularly review your API usage logs (if available through Messari's dashboard) to detect any unusual activity that might indicate unauthorized use of your API key.
  6. Implement Server-Side API Calls: For web applications, especially those accessible via a browser, ensure that API calls involving your Messari API key are made from your backend server. This prevents the API key from being exposed in the user's browser or network requests, where it could be intercepted. Services like Cloudflare Workers can also serve as a proxy for API calls, abstracting the key from client-side code.
  7. Error Handling: Implement robust error handling in your application to gracefully manage authentication failures. This can prevent sensitive information from being leaked in error messages and provide a better user experience.
  8. Avoid Query String for Sensitive Keys: While Messari specifies the API key in the query string, for highly sensitive APIs in general, it is often preferred to pass keys in HTTP headers (e.g., Authorization header with a custom scheme) to reduce the risk of logging in web server access logs or browser history. However, for Messari, follow their official documentation for parameter placement.

By following these best practices, developers can significantly enhance the security posture of their applications integrating with the Messari API, protecting both their data and their users.