Private Key: It is used to generate the signature (only visible once after creation)
Every user can create at most 10 API Keys,every API Key can bind maximum 10 IP address.
Interface URL
https://stakingapi.xhash.com:18000
Authentication
All interfaces are requested using the private key signature and public key verification
The request header contains the following signature information:
access_key: The 'accessKey' in your API Key
sign: The value after signed, it uses MD5withRSA, MD5withRSA(requestBody+timestamp), requestBody equal "" if no request param。
timestamp: The time stamp(ms)
All interfaces use post requests with request parameters placed in requestBody
such as : /api/v1/xhash/getUserDailyIncome
header:
"access_key":"50CEA00402A84BFF9B47CF44A947DA0B"
"sign":"sEm3E4qD8fD7mb54SxJLKajf28gItAkHNjk44QJgrjRqh9XQX6xNMdhsKXSAabcfQ77Mpp/PI6i9hW1XPnfkrLKDlAeaTMXKWxQaRKryzB99p782Re0mRoWFW1iZcvaUFzgb3aY3Oj7/xD0Qz6Y+cg/SZGM6KcTC2IL3PosoWPk="
"timestamp":"1666854104527"
requestBody:
{
"pageNum": 1,
"pageSetNum": 10
}
Response Format
{
"code": "",
"data": object,
"msg": ""
}
code="200" is success, other is fail
Example
String accessKey = "A95B2CFA7B1940B799EFCE792AD...";
String privateKey = "MIICeAIBADANBgkqhkiG9w0BAQEFAASCAmIwggJeAgEAAoGBAMQzb3GI8fTGUUXaZsZxnLBWnihO9iSua4z7v9tY...";
String url = "https://stakingapi.xhash.com:18000/api/v1/xhash/getUserDailyIncome";
Map<String, Object> requestBody = new HashMap<>();
requestBody.put("pageNum", 1);
requestBody.put("pageSetNum", 10);
String content = new GsonBuilder().serializeNulls().create().toJson(requestBody);
long timestamp = System.currentTimeMillis();
System.out.println(content + timestamp);
String sign = RSACoder.sign((content + timestamp).getBytes(), privateKey);
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.add("access_key",accessKey);
httpHeaders.add("timestamp",timestamp + "");
httpHeaders.add("sign",sign);
HttpEntity<String> httpEntity = new HttpEntity<>(content, httpHeaders);
RestTemplate restTemplate = new RestTemplate();
ResponseEntity<String> result = restTemplate.postForEntity(url, httpEntity, String.class);
System.out.println(result);