Request URL
-
AWS / Projects hosted outside of China: https://developer.veplatform.com/api/
-
Ali / Projects hosted inside China: https://developer.veplatform.cn/api/
Request Header
| Header | Description | Example |
|---|---|---|
| content-type | indicates the media type of the resource | If there is no special statement, please use application/json;charset=utf-8 |
| x-api-token | contains the JWT token to authenticate a user | eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9... |
Result Code
If the call is successful, "common.success" is returned.
If the call fails, please refer to here for the error code.
-
Get Token
POST v2/tokens
Get token, for the method of obtaining appid and appkey, please refer to here
Java Example:
signString :appid=15cf8af3ebeca443d377bd5c2658cae9
&appkey=15cf8af3ebeca443d377bd5c2658cae98a1030dd513184568e89fbbd776bc2cb
&nonce =3806143519628774
×tamp=1552185608
signature : sha256( signString )
public static String sha256( String text )
{
try {
MessageDigest message = MessageDigest.getInstance( "SHA-256" );
byte[] hash = message.digest( text.getBytes( "UTF-8" ) );
return(Hex.encodeHexString( hash ) );
} catch ( Exception e ) {
e.printStackTrace();
}
return(null);
}
public static String signature( TokenRequest request )
{
StringBuffer sign = new StringBuffer();
sign.append( String.format( "appid=%s&", request.getAppid() ) );
sign.append( String.format( "appkey=%s&", appkey ) );
sign.append( String.format( "nonce=%s&", request.getNonce() ) );
sign.append( String.format( "timestamp=%s", request.getTimestamp() ) );
return(sha256( sign.toString().toLowerCase() ) );
}
public static void testGetToken()
{
TokenRequest request = new TokenRequest();
request.setAppid( appid );
request.setNonce( RandomUtils.nextHexString( 8 ) );
request.setTimestamp( String.valueOf( (System.currentTimeMillis() / 1000) ) );
request.setSignature( signature( request ) );
System.out.println( JSONObject.toJSONString( request ) );
}
Request Parameters
| Name | Type | Required | Description |
|---|---|---|---|
| appid | string | Y | appid |
| nonce | string | Y | random number (length is 16) |
| signature | string | Y | sha256 signature |
| timestamp | string | Y | current timestamp, within 5 minutes (UTC time) |
| source | string | N | application request source. For the same request source, the valid request is the latest request |
Request Example
{
"appid": "15cf8af3ebeca443d377bd5c2658cae9",
"nonce": "3806143519628774",
"signature": "1c442f56664317d81c32e41010660f54ba1e71223fa6d766ebbe45de3906998b",
"timestamp": "1552185608"
}
Response Example
{
"code": "common.success",
"data": {
"timeToLive": 86400,
"expireTime": 1593257539,
"expire": 86400,
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJsb2dpbklkIjoiNGNhY2IyNzk3NDVjIiwiYXBwSWQiOiJhODJiN2I5MGNmMDE0ZDFhMDk5YzEzOTdmMzA5NzZiYyIsInNvdXJjZSI6ImFhYSIsImV4cCI6MTU5MzI1NzUzOSwiaWF0IjoxNTkzMTcxMTM5fQ.YhXSdmicmbjajIiZqyIPpUPWn1lFrsO6G8-JWK_yXmY"
}
}
Response Parameters
| Name | Type | Description |
|---|---|---|
| token | string | returned token |
| expire | integer | token effective time (24 hours), unit: second |
| timeTolive | integer | token remaining effective time, unit: second |
| expireTime | integer | expiry timestamp |
After getting the token, you can start sending HTTP GET/POST requests to call the blockchain service. Each time it is called, please make sure that the value of the x-api-token of the HTTP request is valid.
Comments
0 comments
Please sign in to leave a comment.