# API Description

# Public Parameters

Parameters required for all APIs

Parameter Type Required or Not Description
fleet_id int64 Yes Fleet id
location_country string Yes Country. Refer to “Abbreviation” in Appendix “Countries and Languages”
lang string Yes Language. Refer to “Language” in Appendix “Countries and Languages”

# Description of API Return Values

Parameter Type Description
errno int32 Return code. Refer to Appendix “Return Codes”
msg string Returned information
trace_id string Request id, a unique value is assigned for each request
data.response string Encrypted data. Decryption algorithm should be used to get the raw data, which is a string obtained through json serialization of json object

# User Data Decryption Rules

“data” in returned data will be encrypted. API users should get the data according to the decryption rules. Data Encryption Rules: CBC mode of AES decryption algorithm is used, and the population method is PKCS5UnPadding. The final output is an encrypted base64 string. The decryption key and offset will be sent to the requester via email. Encryption and decryption process example:

Server-side:

  1. Get raw data:
{
    "errno": 0,
    "msg": "success",
    "data": {
		"response":	{
        	"driver_balance": "-217.01",
        	"currency_code": "₽"
    	},
        "trace_id": "0a6072d45f3cdd6be61db3f9ffdfc9b0"
	}
}
1
2
3
4
5
6
7
8
9
10
11
  1. "response" Object serialization:
"response": "{\"driver_balance\":\"-217.01\",\"currency_code\":\"₽\"}"
1
  1. "response" Encryption:
"response": "1DS74IGSmdq/ynQljl31jqvhlZJtDRtgGela2Sq/p7PozMjv82rXdJeZzIlWxcX3zqO3xqVSUefYZGAFsc91cQ=="
1
  1. Output:
{
    "errno": 0,
    "msg": "success",
    "data": {
        "response": "1DS74IGSmdq/ynQljl31jqvhlZJtDRtgGela2Sq/p7PozMjv82rXdJeZzIlWxcX3zqO3xqVSUefYZGAFsc91cQ==",
    	"trace_id": "0a6072d45f3cdd6be61db3f9ffdfc9b0"
    }
}
1
2
3
4
5
6
7
8

User-side:

  1. Get encrypted data:
{
    "errno": 0,
    "msg": "success",
    "data": {
        "response": "1DS74IGSmdq/ynQljl31jqvhlZJtDRtgGela2Sq/p7PozMjv82rXdJeZzIlWxcX3zqO3xqVSUefYZGAFsc91cQ==",
    	"trace_id": "0a6072d45f3cdd6be61db3f9ffdfc9b0"
    }
}
1
2
3
4
5
6
7
8
  1. "response"Decryption:
"response": "{\"driver_balance\":\"-217.01\",\"currency_code\":\"₽\"}"
1
  1. Get raw data through deserialization
"response":{
        "driver_balance": "-217.01",
        "currency_code": "₽"
    }
1
2
3
4

Data decryption algorithm example: php version

// Encryption offset
const iv = '';
// AES key
const encryptKey = '';
 
// Decryption
function decrypt($encryptStr) {
    $localIV = iv;
    $encryptKey = encryptKey;
    //Open module
    $module = mcrypt_module_openMCRYPT_RIJNDAEL_128, '', MCRYPT_MODE_CBC, $localIV);
    mcrypt_generic_init($module, $encryptKey, $localIV);
    $encryptedData = base64_decode($encryptStr);
    $encryptedData = mdecrypt_generic($module, $encryptedData);

    return $encryptedData;
}

java version

import java.io.*;
import java.security.AlgorithmParameters;
import java.security.InvalidKeyException;
import java.security.Key;
import java.security.NoSuchProviderException;
import java.security.Security;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.util.Base64;

public class AES {
    // AES key		
    private static final String key = "";
    // Encryption offset
    private static final String initVector = "";
    public static String decrypt(String encrypted) {
	try {
		IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8"));
		SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");
 
		Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
		cipher.init(Cipher.DECRYPT_MODE, skeySpec, iv);
		
		byte[] original = cipher.doFinal(Base64.getDecoder().decode(encrypted.getBytes()));
		return new String(original);
	} catch (Exception ex) {
		ex.printStackTrace();
	}
 
	return null; 
   }
}

golang version

import (
    "bytes"
    "crypto/aes"
    "crypto/cipher"
    "encoding/base64"
    "fmt"
)

const (
    // AES key
    key = ""
    // Encryption offset
    iv  = ""
)

func AesDecrypt(decodeStr string, key []byte) ([]byte, error) {
    //First decrypt base64
    decodeBytes, err := base64.StdEncoding.DecodeString(decodeStr)
    if err != nil {
        return nil, err
    }
    block, err := aes.NewCipher(key)
    if err != nil {
        return nil, err
    }
    blockMode := cipher.NewCBCDecrypter(block, []byte(iv))
    origData := make([]byte, len(decodeBytes))

    blockMode.CryptBlocks(origData, decodeBytes)
    origData = PKCS5UnPadding(origData)
    return origData, nil
}

func PKCS5UnPadding(origData []byte) []byte {
    length := len(origData)
    unpadding := int(origData[length-1])
    return origData[:(length - unpadding)]
}