For the complete documentation index, see llms.txt. This page is also available as Markdown.

🔓Authentication

Utilizing Your API Key

To interact with the VeChainStats API, you have the flexibility to employ any server-side programming language capable of making HTTP requests. All requests must be directed towards the domain https://api.vechainstats.com/v2/. You have two options for incorporating your API Key into REST API calls:

  1. Preferred approach: Through a dedicated custom header named X-API-Key.

In your application, you need to add the API Key to the header of your requests for authentication. Below we provide some code examples to add the API Key to the header in different environments:

curl -X GET "https://api.vechainstats.com/v2/network/totals" -H "X-API-Key: YOUR_API_KEY_HERE"
import java.net.HttpURLConnection;
import java.net.URL;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class APIClient {
    public static void main(String[] args) {
        try {
            String apiKey = "YOUR_API_KEY";
            String apiUrl = "https://api.vechainstats.com/v2/network/totals";

            URL url = new URL(apiUrl);
            HttpURLConnection connection = (HttpURLConnection) url.openConnection();

            // Set the request method to GET
            connection.setRequestMethod("GET");

            // Set the API Key header
            connection.setRequestProperty("X-API-Key", apiKey);

            // Read the response
            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String inputLine;
            StringBuilder response = new StringBuilder();

            while ((inputLine = in.readLine()) != null) {
                response.append(inputLine);
            }

            // Close the connection and print the response
            in.close();
            System.out.println(response.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Replace "YOUR_API_KEY" with your actual API key.

  1. Convenience method: By including it as a query string parameter named VCS_API_KEY.

Example request:

https://api.vechainstats.com/v2/account/vet-vtho
    ?address=0xd0d9cd5aa98efcaeee2e065ddb8538fa977bc8eb
    &VCS_API_KEY=YOUR_API_KEY

Replace YOUR_API_KEY with your actual API key.

Last updated