Quick Start
The only thing you need to start using Palenca is a user account and an API Key. You can get them here.
We have 2 environments: Sandbox and Production. For a complete reference on all our API routes click here.
https://sandbox.palenca.com/v1
https://api.palenca.com/v1
1. Get your API Key
In order to make any request to the API, you will need to identify yourself using your private API Key. This should be sent in the headers as x-api-key
.
- cURL
- JavaScript
- Python
--header 'x-api-key:private_api_key'\
--header 'Content-Type: application/json'
headers: {
'x-api-key': 'private_api_key',
'Content-Type': 'application/json'
}
headers = {
"x-api-key": "YOUR_PRIVATE_API_KEY",
"Content-Type": "application/json"
}
2. Create your first connection
In this step we will create a user
(which represents a worker) and an account
(which represents a connection to the IMSS) by making a POST request to the endpoint /users /accounts
. This request must include in the payload
the CURP of the worker (identifier
parameter) and the platform where we will establish the connection (in this case IMSS). Don't forget to include the private key in the headers.
- cURL
- JavaScript
- Python
curl --location --request POST 'https://sandbox.palenca.com/v1/users/accounts' \
--header 'x-api-key: YOUR_PRIVATE_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"identifier": "WORKER_CURP",
"country": "mx",
"platform": "imss"
"widget_id": "YOUR_WIDGET_ID" // if empty, the default widget will be used
}'
const axios = require('axios');
const data = JSON.stringify({
"identifier": "WORKER_CURP", // Replace with the CURP you want to consult
"country": "mx",
"platform": "imss"
});
const config = {
method: 'POST',
url: 'https://sandbox.palenca.com/v1/users/accounts',
headers: {
'x-api-key': 'YOUR_PRIVATE_API_KEY',
'Content-Type': 'application/json'
},
data: data
};
(async() => {
try {
const { data: responseData } = await axios(config);
console.info(JSON.stringify(responseData));
} catch (error) {
console.error(error);
}
})();
import requests
import json
headers = {
"Content-Type" : "application/json",
"x-api-key" : "YOUR_PRIVATE_API_KEY"
}
payload = {
"identifier" : "WORKER_CURP", #the CURP for which you want to consult the information should go here
"platform" : "imss",
}
response = requests.post("https://sandbox.palenca.com/v1/users/accounts", headers = headers,
params=json.dumps(payload))
If everything worked correctly, you should see a response like this and the process to obtain employment data has started:
{
"success": True,
"error": None,
"data": {
"user_id": "054d0a9d-38ec-40cb-a31c-09b483242e4a",
"country": "mx",
"platform": "imss",
"account_id": "472f02e8-6b24-43a7-b529-3f71d6ecc81c"
}
}
3. Get employment data
The process of obtaining the worker's employment data depends on each platform (on average 10 seconds). Once this time has passed, we are ready to recover the worker's employment history. To do this, we need to make a GET request to /accounts/{account_id}/employment
. You will be able to see a list of the companies in which this user has worked, the federal entities and their salaries.
- cURL
- JavaScript
- Python
curl --location --request GET 'https://sandbox.palenca.com/v1/accounts/:account_id/employment' \
--header 'x-api-key: YOUR_PRIVATE_API_KEY' \
--header 'Content-Type: application/json'
const axios = require('axios');
const headers = {
"Content-Type": "application/json",
"x-api-key": "YOUR_PRIVATE_API_KEY"
}
const accountId = "account_id"; // Replace with the current account_id from the previous step
const config = {
method: 'GET',
url: `https://sandbox.palenca.com/v1/accounts/${accountId}/employment`,
headers: headers
};
(async() => {
try {
const { data } = await axios(config);
console.info(JSON.stringify(data));
} catch (error) {
console.error(error);
}
})();
import requests
import json
headers = {
"Content-Type" : "application/json",
"x-api-key" : "YOUR_PRIVATE_API_KEY"
}
account_id = "account_id" #account
response = requests.get(f"https://sandbox.palenca.com/v1/accounts/{account_id}/employment", headers = headers)
4. Integrate a Webhook
In order not to depend on Palenca's response time (~10 seconds) and have to wait for the employment data to be ready, we recommend implementing a Webhook that will allow you to receive a notification once the data is available for consultation.