Python

This page will show a quick preview on how to integrate Zenlogin using Python.


Request Example

curl https://api.zenlogin.co/v1/applications/appl0123456789/logins/checks \
--header "X_API_SECRET_KEY: your_secret_key" \
--data identity_key="usr12345" \
--data identity_email_address="name@website.com" \
--data user_agent="Mozilla/5.0 (Windows NT 6.1; rv:74.0) Gecko/20100101 Firefox/74.0" \
--data ip_address="18.97.14.83"
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.zenlogin.co/v1/applications/appl0123456789/logins/checks');
$postData = array();
$postData['identity_key'] = 'usr12345';
$postData['identity_email_address'] = 'name@website.com';
$postData['user_agent'] = 'Mozilla/5.0 (Windows NT 6.1; rv:74.0) Gecko/20100101 Firefox/74.0';
$postData['ip_address'] = '18.97.14.83';
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postData));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  'X_API_SECRET_KEY: your_secret_key'
));
$response = curl_exec($ch);
$response = json_decode($response, true);
curl_close($ch);
const axios = require('axios');
const endpoint = 'https://api.zenlogin.co/v1/applications/appl0123456789/logins/checks',
  postData = {},
  options = {};
postData.identity_key = 'usr12345';
postData.identity_email_address = 'name@website.com';
postData.user_agent = 'Mozilla/5.0 (Windows NT 6.1; rv:74.0) Gecko/20100101 Firefox/74.0';
postData.ip_address= '18.97.14.83';
options.headers = {};
options.headers.X_API_SECRET_KEY = 'your_secret_key';
axios.post(endpoint, postData, options).then(function(response) {
  console.log(response.data);
}).catch(function(error) {
  console.error(error.response.data);
});
import requests
url = 'https://api.zenlogin.co/v1/applications/appl0123456789/logins/checks'
postData = {
  'identity_key': 'usr12345',
  'identity_email_address': 'name@website.com',
  'user_agent': 'Mozilla/5.0 (Windows NT 6.1; rv:74.0) Gecko/20100101 Firefox/74.0',
  'ip_address': '18.97.14.83'
}
headers = {'X_API_SECRET_KEY': 'your_secret_key'}
response = requests.post(url, data=postData, headers=headers)
print response.content
require 'uri'
require 'net/http'

uri = URI('https://api.zenlogin.co/v1/applications/appl0123456789/logins/checks')
req = Net::HTTP::Post.new(uri.path)
req['X_API_SECRET_KEY'] = 'your_secret_key'
postData = {}
postData['identity_key'] = 'usr12345'
postData['identity_email_address'] = 'name@website.com'
postData['user_agent'] = 'Mozilla/5.0 (Windows NT 6.1; rv:74.0) Gecko/20100101 Firefox/74.0'
postData['ip_address'] = '18.97.14.83'
req.set_form_data(postData);

https = Net::HTTP.new(uri.host, uri.port)
https.use_ssl = true

response = https.request(req)
puts response.body

Please refer to our Error Handling page for details on how to deal with errors.