Authentication overview
Ethplorer secures access to its Public and Pro APIs through a proprietary API key system. This method ensures that all requests made to the Ethplorer platform are attributable to a specific user or application, allowing for rate limiting, feature access control, and usage monitoring. Regardless of whether you are using the free tier or a paid Pro API plan, an API key is a mandatory component for authenticating your requests and accessing Ethereum blockchain data, including transaction tracking and token information.
API keys serve as unique identifiers and secret tokens. When an API key is included in an API request, the Ethplorer server verifies its validity and permissions before processing the request. This mechanism is common among many web services for managing access to resources and differentiating between various levels of service or user privileges. For Ethplorer, the API key directly influences the rate limits and available features for your account, as detailed in the official Ethplorer API reference.
It is crucial to handle API keys securely to prevent unauthorized access to your account's usage quota and data. Unauthorized use of your API key could lead to unexpected charges on paid plans or exhaustion of your free tier rate limits, potentially disrupting your application's functionality. Best practices for API key management, such as environmental variable storage and restricted access, are essential for maintaining the integrity and security of your integration.
Supported authentication methods
Ethplorer exclusively supports API key authentication for accessing its Public and Pro APIs. This method involves generating a unique string from your Ethplorer account and including it as a query parameter in every API request.
The following table outlines the authentication method supported by Ethplorer:
| Method | When to Use | Security Level |
|---|---|---|
| API Key (Query Parameter) | All API access (free and paid tiers) for server-to-server or trusted client applications. | Moderate: Secure if kept confidential, but vulnerable if exposed client-side or in version control. |
While API keys offer a straightforward approach to authentication, their security relies heavily on proper handling. Unlike more complex authentication flows like OAuth 2.0, which involves token exchange and refresh mechanisms, API keys are static credentials. This simplicity makes them easy to implement but also underscores the importance of strict security practices to prevent their compromise.
Getting your credentials
To obtain your Ethplorer API key, you need to register for an account on the Ethplorer website. The process typically involves creating an account, then navigating to your user dashboard or a dedicated API key management section.
- Sign Up/Log In: Go to the Ethplorer homepage and either sign up for a new account or log in to an existing one.
- Access Dashboard: Once logged in, locate your user dashboard or account settings.
- Generate API Key: Look for a section related to "API Keys" or "Developer Settings." There should be an option to generate a new API key. Ethplorer provides detailed instructions on how to locate and generate your API key within your account settings, which are essential for proceeding with API integration.
- Copy Key: Once generated, copy your API key. It is crucial to store this key securely immediately, as it may not be retrievable again after leaving the page for security reasons.
Ethplorer's free tier provides basic API access with specific rate limits, while the Pro API plans offer higher rate limits and additional features. Your API key will determine the level of access and the rate limits applied to your requests, corresponding to your chosen plan. For developers integrating Ethereum data, understanding these distinctions is important for managing application performance and avoiding service disruptions.
Authenticated request example
Authenticating with the Ethplorer API involves appending your unique API key as a query parameter named apiKey to your request URL. This method applies to all endpoints requiring authentication, ensuring that your requests are properly authorized and accounted for under your usage plan.
Below are examples demonstrating how to make an authenticated request using curl, Python, and JavaScript.
Curl Example
This curl command fetches information about a specific Ethereum address, including your API key:
curl "https://api.ethplorer.io/getAddressInfo/0x0d874312a0d927d7E9B4208a0d2Ed0927c8d9E7B?apiKey=YOUR_API_KEY"
Replace YOUR_API_KEY with your actual Ethplorer API key to execute this request successfully.
Python Example
Using the requests library in Python, you can construct an authenticated request as follows:
import requests
API_KEY = "YOUR_API_KEY"
ADDRESS = "0x0d874312a0d927d7E9B4208a0d2Ed0927c8d9E7B"
BASE_URL = "https://api.ethplorer.io"
url = f"{BASE_URL}/getAddressInfo/{ADDRESS}"
params = {"apiKey": API_KEY}
try:
response = requests.get(url, params=params)
response.raise_for_status() # Raise an exception for HTTP errors
data = response.json()
print(data)
except requests.exceptions.RequestException as e:
print(f"Request failed: {e}")
This Python script dynamically builds the URL with the API key as a query parameter, making it flexible for different endpoints and addresses.
JavaScript (Node.js/Browser) Example
For JavaScript environments, including Node.js or browser-based applications, you can use the fetch API or a library like axios:
const API_KEY = "YOUR_API_KEY";
const ADDRESS = "0x0d874312a0d927d7E9B4208a0d2Ed0927c8d9E7B";
const BASE_URL = "https://api.ethplorer.io";
const url = `${BASE_URL}/getAddressInfo/${ADDRESS}?apiKey=${API_KEY}`;
fetch(url)
.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);
});
In all examples, remember to replace YOUR_API_KEY with your actual Ethplorer API key. It is critical to secure this key and avoid hardcoding it directly into client-side code that might be publicly accessible.
Security best practices
Securing your Ethplorer API key is paramount to protecting your account from unauthorized access, preventing service disruptions, and managing costs, especially with paid Pro API plans. Adhering to established security practices for API keys is essential.
- Do Not Expose API Keys in Client-Side Code: Never embed your API key directly into client-side code (e.g., JavaScript in web browsers or mobile applications). This makes the key visible to anyone inspecting your application's source code, leading to immediate compromise. All requests that include the API key should originate from a secure server-side environment.
- Use Environment Variables: Store API keys as environment variables on your server or in your development environment. This prevents the keys from being hardcoded into your application's codebase and lessens the risk of accidental exposure through version control systems like Git. For example, in Node.js, you might access
process.env.ETHPLORER_API_KEY. - Restrict Access to API Keys: Limit who has access to your API keys within your organization. Only individuals or systems that absolutely require the key for operational purposes should have access.
- Implement IP Whitelisting (if available): While Ethplorer's documentation does not explicitly mention IP whitelisting for API keys, it's a general security practice to restrict API key usage to a specific set of trusted IP addresses whenever an API provider offers this feature. This adds a layer of defense against unauthorized use even if the key is compromised.
- Monitor API Key Usage: Regularly check your Ethplorer account dashboard for unusual activity or spikes in API key usage. Early detection of suspicious patterns can help mitigate potential breaches.
- Rotate API Keys Periodically: 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.
- Secure Your Development Environment: Ensure that your development machines and build pipelines are secure. Malicious software or improper configurations in these environments can inadvertently expose sensitive credentials.
- Understand Rate Limits and Quotas: Familiarize yourself with the Ethplorer API documentation regarding rate limits and how they apply to your specific API key. This helps prevent unintentional overages or service interruptions that could be mistaken for a security issue.
By following these best practices, you can significantly enhance the security posture of your integration with the Ethplorer API, protecting your data and ensuring reliable service access. The Mozilla Developer Network's web security guide provides further context on general web attack vectors that can impact API security.