Getting started overview

Integrating with ZMOK for blockchain and cryptocurrency data involves a structured process to ensure secure and efficient access to its API endpoints. This guide focuses on the foundational steps required to get an environment set up and execute a successful initial API call. The typical flow includes account creation, API key generation, and using these credentials to fetch data, often starting with a simple endpoint to confirm connectivity and authentication.

ZMOK provides access to a range of data, including real-time market data, historical cryptocurrency information, blockchain data, and NFT-specific APIs. Understanding the authentication mechanism, usually an API key, is crucial for all subsequent interactions. Developers can choose from multiple SDKs or interact directly with the RESTful API using standard HTTP client libraries.

Before proceeding, ensure you have a basic understanding of RESTful API principles and how to make HTTP requests from your chosen programming environment. Familiarity with JSON data structures will also be beneficial, as ZMOK's API typically returns data in JSON format.

Quick start reference

The following table provides a high-level overview of the steps to get started with ZMOK:

Step What to do Where
1. Sign Up Create a ZMOK account. ZMOK homepage
2. Get API Key Locate and copy your unique API key from the dashboard. ZMOK dashboard settings or API key management section
3. Choose Endpoint Select a simple API endpoint for your first request (e.g., market data). ZMOK API reference documentation
4. Construct Request Formulate an HTTP request with your API key in the header or query parameter. Your preferred development environment
5. Execute Request Send the request and verify the JSON response. Terminal (cURL), Postman, or code editor

Create an account and get keys

To begin using ZMOK's services, you must first create an account. This process typically involves providing an email address, setting a password, and agreeing to the terms of service. ZMOK offers a Developer Plan free tier, which provides 50,000 requests per month, suitable for initial development and testing.

  1. Navigate to the ZMOK Homepage: Open your web browser and go to the official ZMOK website.
  2. Sign Up: Look for a "Sign Up" or "Get Started" button, usually located in the top right corner of the page.
  3. Complete Registration: Follow the prompts to enter your details. This typically includes your email address and a secure password. You may need to verify your email address after registration.
  4. Access the Dashboard: Once registered and logged in, you will be directed to your ZMOK user dashboard.
  5. Locate API Keys: Within the dashboard, find a section labeled "API Keys", "Settings", or "Credentials". This section will contain your unique API key(s). API keys are essential for authenticating your requests to ZMOK's endpoints.
  6. Copy Your API Key: Copy your API key. Treat this key like a password; it grants access to your ZMOK account and its allocated request quota. Do not hardcode it directly into client-side code or publicly expose it.

ZMOK's documentation on API key management provides further details on how to handle and rotate keys if necessary.

Your first request

After obtaining your API key, the next step is to make an authenticated request to a ZMOK API endpoint. This example will demonstrate a request using cURL, a common command-line tool for making HTTP requests, and then show an equivalent in Python. This approach helps confirm that your API key is valid and that you can successfully connect to the service.

Using cURL

For your first request, we'll target a simple public market data endpoint, such as retrieving current cryptocurrency prices. You will need to replace YOUR_API_KEY with the actual key you obtained from your ZMOK dashboard.

Example cURL request for a market data endpoint (e.g., getting Bitcoin price):

curl -X GET \
  'https://api.zmok.io/v1/market/prices?symbol=BTCUSDT' \
  -H 'X-API-KEY: YOUR_API_KEY'

Explanation:

  • -X GET: Specifies the HTTP method as GET.
  • 'https://api.zmok.io/v1/market/prices?symbol=BTCUSDT': This is the target URL for the API endpoint, querying the price for Bitcoin (BTC) against Tether (USDT).
  • -H 'X-API-KEY: YOUR_API_KEY': This header is crucial for authentication. Replace YOUR_API_KEY with your actual ZMOK API key.

Upon successful execution, you should receive a JSON response containing the requested market data, similar to this (actual response may vary):

{
  "symbol": "BTCUSDT",
  "price": "60000.00",
  "timestamp": 1678886400
}

Using Python

For developers working with Python, the requests library is a common choice for making HTTP requests. Ensure you have it installed (pip install requests).

import requests
import os

# It's recommended to store your API key as an environment variable
# For testing, you can replace os.environ.get with your key directly, but avoid in production
api_key = os.environ.get('ZMOK_API_KEY', 'YOUR_API_KEY_HERE') # Replace 'YOUR_API_KEY_HERE' for direct testing

url = 'https://api.zmok.io/v1/market/prices?symbol=ETHUSDT'
headers = {
    'X-API-KEY': api_key
}

try:
    response = requests.get(url, headers=headers)
    response.raise_for_status() # Raise an exception for HTTP errors (4xx or 5xx)
    data = response.json()
    print("Successfully fetched data:")
    print(data)
except requests.exceptions.HTTPError as err:
    print(f"HTTP error occurred: {err}")
    print(f"Response body: {response.text}")
except requests.exceptions.RequestException as err:
    print(f"An error occurred: {err}")

Explanation:

  • api_key = os.environ.get('ZMOK_API_KEY', 'YOUR_API_KEY_HERE'): Retrieves the API key. Using environment variables is a best practice for security, but for initial testing, you can temporarily hardcode it.
  • url: Defines the target API endpoint.
  • headers: A dictionary containing the X-API-KEY header with your API key.
  • requests.get(url, headers=headers): Sends the GET request with the specified URL and headers.
  • response.raise_for_status(): Checks if the request was successful (status code 200). If not, it raises an HTTPError.
  • response.json(): Parses the JSON response body into a Python dictionary.

This Python script will print the fetched data (e.g., Ethereum price) or an error message if the request fails.

Common next steps

After successfully making your first API call, you can explore ZMOK's capabilities further. Here are some common next steps:

  • Explore API Endpoints: Review the comprehensive ZMOK API reference to understand the full range of available endpoints, including those for historical data, NFT APIs, and specific blockchain interactions. Each endpoint will have its own parameters and response structures.
  • Utilize SDKs: ZMOK provides SDKs in multiple languages (JavaScript, Python, Go, Ruby, Java, C#). Using an SDK can simplify API interactions by abstracting HTTP requests and handling data parsing, allowing you to integrate more rapidly.
  • Error Handling and Rate Limits: Implement robust error handling in your application to gracefully manage API errors, such as invalid requests or server issues. Familiarize yourself with ZMOK's rate limits to ensure your application respects them and avoids being throttled.
  • Secure API Keys: Beyond environment variables, consider using secret management services for production applications (e.g., AWS Secrets Manager, Google Secret Manager, or Azure Key Vault) to protect your API keys. General best practices for API key security are detailed by providers like Google Developers on API security.
  • Monitor Usage: Regularly check your ZMOK dashboard to monitor your API usage and ensure you remain within your plan's request limits. This helps prevent unexpected service interruptions.
  • Upgrade Plan: If your application's needs exceed the Developer Plan's limits, consider upgrading to a paid plan, such as the Startup Plan, which offers 1,000,000 requests per month.

Troubleshooting the first call

Encountering issues during your first API call is common. Here are some troubleshooting tips:

  • Check API Key: Ensure your API key is correct and has not expired. Double-check for typos or extra spaces when copying it from the ZMOK dashboard. An incorrect key will typically result in a 401 Unauthorized error.
  • Verify Endpoint URL: Confirm that the API endpoint URL is accurate and matches the one specified in the ZMOK API documentation. A wrong URL can lead to 404 Not Found errors.
  • Inspect Headers: Make sure the X-API-KEY header is correctly formatted and included in your request. Some APIs might expect the key in a different header or as a query parameter; always refer to the specific API documentation.
  • Review HTTP Status Codes:
    • 200 OK: Success. The request was processed, and data was returned.
    • 400 Bad Request: The request was malformed (e.g., missing a required parameter, invalid parameter value). Check your query parameters and request body against the API documentation.
    • 401 Unauthorized: Authentication failed. Your API key is likely missing, invalid, or expired.
    • 403 Forbidden: You are authenticated, but lack the necessary permissions to access the requested resource, or your account might be rate-limited.
    • 429 Too Many Requests: You have exceeded the API's rate limits. Implement exponential backoff or increase your plan.
    • 5xx Server Error: An issue on the ZMOK server side. These are typically temporary; retrying the request after a short delay may resolve the issue.
  • Consult ZMOK Documentation: The official ZMOK documentation is the primary resource for detailed error codes and troubleshooting specific endpoints.
  • Use a Tool like Postman: If you're struggling with code, use an API client like Postman or Insomnia to construct and test requests visually. This can help isolate issues related to code versus API configuration.