Explore the capabilities of our API and learn how to integrate it into your applications.
Version: 1.0.0
This API provides access to our Vizums's data, allowing you to retrieve user information, check FX rates, and manage your account.
The API signature should be included in the header of your request. Here's an example of how to format the signature headers:
Stay up-to-date with the latest foreign exchange rates to make informed financial decisions.
Integrate our financial services seamlessly into your applications with our comprehensive API documentation and examples.
curl -X GET -H "vizum-client-id: <<your-vizum-client-id>>" https://sandbox.vizum.mx
{
"id": "da7d8e08-4223-4113-a23b-ed1ea82bd93e",
"body": {
"vizum_id": "d1f04813-6e9f-42cd-a070-2f8b0bafb514",
"beneficiary_account": "638180000152900340",
"beneficiary_name": "ND",
"beneficiary_rfc": "ND",
"concept": "prueba",
"usd_requested_amount": 0.1,
"created_at": "2024-05-31T11:38:23.404-06:00",
"mxn_requested_amount": -5.85,
"vizum_fx": 16.58,
"fixed_fee_mxn": 7.5,
"variable_fee_mxn": -0.05
},
"status": 200,
"message": "Payout created successfully"
}
The signature is calculated according to the following formula:
signature = BASE64 ( HASH ( httpmethod + urlpath + salt + timestamp + accesskey + secretkey + bodystring ) )
To ensure the integrity and authenticity of API requests, we require a cryptographic signature to be included in the request headers. Here's how to create the signature:
Here's an example in Javascript using the "hmac" and "CryptoJS" libraries:
import CryptoJS from 'crypto-js';
const accessKey = '<VIZUM_CLIENT_ID>'
const secretKey = '<YOUR_SECRET_KEY>'
const log = true;
/**
* @param {string} method - HTTP method
* @param {string} url - URL path
* @param {object} body - Body of the request
*/
export async function buildRequest(method, urlPath, body = null) {
try {
let headers = {}
//console.log('body |', body);
const salt = generateRandomString();
const idempotency = new Date().getTime().toString();
const timestamp = (Math.floor(new Date().getTime() / 1000) - 10).toString();
const signature = await sign(method, urlPath, salt, timestamp, body);
headers = {
path: urlPath,
port: 443,
method: method,
headers: {
'Content-Type': 'application/json',
access_key: accessKey,
signature: signature,
timestamp: timestamp,
salt: salt,
idempotency: idempotency
},
body: body ? JSON.stringify(body) : body
}
return headers;
}
catch(err) {
log && console.log('buildRequest |', err)
}
}
function generateRandomString(size = 12) {
try {
let salt = CryptoJS.lib.WordArray.random(size);
return salt.toString();
}
catch (error) {
log && console.log('salt error |', error)
}
}
/**
* @param {string} httpMethod - HTTP method
* @param {string} urlPath - URL path
* @param {string} salt - Salt for the signature
* @param {string} timestamp - Timestamp in ISO format
* @param {object} body - Body of the request
*/
async function sign(httpMethod, urlPath, salt, timestamp, body) {
try {
let bodyString = "";
if (body) {
bodyString = JSON.stringify(body);
bodyString = bodyString == "{}" ? "" : bodyString;
}
//console.log('bodyString |', bodyString);
const toSign = httpMethod.toLowerCase() + urlPath + salt + timestamp + accessKey + secretKey + bodyString;
//console.log('toSign |', toSign);
let signature = CryptoJS.enc.Hex.stringify(
CryptoJS.HmacSHA256(toSign, secretKey)
);
signature = CryptoJS.enc.Base64.stringify(CryptoJS.enc.Utf8.parse(signature));
//console.log('signature |', signature);
return signature;
}
catch (error) {
throw error
}
}
// # How to use this function
// const url = {VIZUM_URL}{urlPath};
// return await fetch(url, headers)
// .then();
// console.log(headers);