curl --request GET \
--url 'https://YOURSITE.konstantly.ai/api/v1/users/byEmail/user@example.com' \
--header 'X-API-KEY: 1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv'
import requests
from typing import Dict
def get_user_by_email(api_key: str, email: str) -> Dict:
url = f"https://YOURSITE.konstantly.ai/api/v1/users/byEmail/{email}"
headers = {
"X-API-KEY": api_key
}
try:
response = requests.get(url, headers=headers)
if response.status_code == 404:
raise ValueError(f"User with email {email} not found")
response.raise_for_status()
return response.json()[0]
except requests.exceptions.RequestException as e:
print(f"Error fetching user: {str(e)}")
if hasattr(e, 'response') and e.response is not None:
print(f"Response: {e.response.text}")
raise
# Example usage
if __name__ == "__main__":
try:
user = get_user_by_email(
api_key="1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv",
email="user@example.com"
)
print(f"Found user: {user['name']}")
print(f"ID: {user['id']}")
print(f"Language: {user['language']}")
except Exception as e:
print(f"Failed to fetch user: {str(e)}")
<?php
class UsersAPI {
private $apiKey;
private $baseUrl;
public function __construct($apiKey) {
$this->apiKey = $apiKey;
$this->baseUrl = 'https://YOURSITE.konstantly.ai/api/v1';
}
public function getUserByEmail($email) {
$ch = curl_init();
$url = "{$this->baseUrl}/users/byEmail/" . urlencode($email);
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'X-API-KEY: ' . $this->apiKey
]
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if (curl_errno($ch)) {
throw new Exception('Error: ' . curl_error($ch));
}
curl_close($ch);
$responseData = json_decode($response, true);
if ($httpCode === 404) {
throw new Exception("User with email {$email} not found");
}
if ($httpCode !== 200) {
throw new Exception("Failed to fetch user. Status code: {$httpCode}");
}
return $responseData[0];
}
}
// Example usage
try {
$usersApi = new UsersAPI('1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv');
$user = $usersApi->getUserByEmail('user@example.com');
echo "Found user: {$user['name']}\n";
echo "ID: {$user['id']}\n";
echo "Language: {$user['language']}\n";
} catch (Exception $e) {
echo "Failed to fetch user: " . $e->getMessage() . "\n";
}
?>
const axios = require('axios');
class UsersAPI {
constructor(apiKey) {
this.client = axios.create({
baseURL: 'https://YOURSITE.konstantly.ai/api/v1',
headers: {
'X-API-KEY': apiKey
}
});
}
async getUserByEmail(email) {
try {
const response = await this.client.get(`/users/byEmail/${encodeURIComponent(email)}`);
return response.data[0];
} catch (error) {
if (error.response) {
if (error.response.status === 404) {
throw new Error(`User with email ${email} not found`);
}
throw new Error(`Failed to fetch user: ${error.response.data.message || error.message}`);
}
throw error;
}
}
}
// Example usage
async function main() {
const usersApi = new UsersAPI('1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv');
try {
const user = await usersApi.getUserByEmail('user@example.com');
console.log(`Found user: ${user.name}`);
console.log(`ID: ${user.id}`);
console.log(`Language: ${user.language}`);
} catch (error) {
console.error('Failed to fetch user:', error.message);
}
}
main();
[
{
"id": "emp-1042",
"name": "John Doe",
"email": "user@example.com",
"language": "en",
"occupation": "Salesman",
"location": "London",
"timezone": "Europe/London",
"isBanned": false,
"fromApi": false,
"authType": 0,
"createdAt": 1700000000,
"lastActivity": 1700086400,
"image": null
}
]
{
"status": 404,
"message": "User not found"
}
Users
Get User by Email
Get user information by email address
GET
/
users
/
byEmail
/
{userEmail}
curl --request GET \
--url 'https://YOURSITE.konstantly.ai/api/v1/users/byEmail/user@example.com' \
--header 'X-API-KEY: 1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv'
import requests
from typing import Dict
def get_user_by_email(api_key: str, email: str) -> Dict:
url = f"https://YOURSITE.konstantly.ai/api/v1/users/byEmail/{email}"
headers = {
"X-API-KEY": api_key
}
try:
response = requests.get(url, headers=headers)
if response.status_code == 404:
raise ValueError(f"User with email {email} not found")
response.raise_for_status()
return response.json()[0]
except requests.exceptions.RequestException as e:
print(f"Error fetching user: {str(e)}")
if hasattr(e, 'response') and e.response is not None:
print(f"Response: {e.response.text}")
raise
# Example usage
if __name__ == "__main__":
try:
user = get_user_by_email(
api_key="1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv",
email="user@example.com"
)
print(f"Found user: {user['name']}")
print(f"ID: {user['id']}")
print(f"Language: {user['language']}")
except Exception as e:
print(f"Failed to fetch user: {str(e)}")
<?php
class UsersAPI {
private $apiKey;
private $baseUrl;
public function __construct($apiKey) {
$this->apiKey = $apiKey;
$this->baseUrl = 'https://YOURSITE.konstantly.ai/api/v1';
}
public function getUserByEmail($email) {
$ch = curl_init();
$url = "{$this->baseUrl}/users/byEmail/" . urlencode($email);
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'X-API-KEY: ' . $this->apiKey
]
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if (curl_errno($ch)) {
throw new Exception('Error: ' . curl_error($ch));
}
curl_close($ch);
$responseData = json_decode($response, true);
if ($httpCode === 404) {
throw new Exception("User with email {$email} not found");
}
if ($httpCode !== 200) {
throw new Exception("Failed to fetch user. Status code: {$httpCode}");
}
return $responseData[0];
}
}
// Example usage
try {
$usersApi = new UsersAPI('1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv');
$user = $usersApi->getUserByEmail('user@example.com');
echo "Found user: {$user['name']}\n";
echo "ID: {$user['id']}\n";
echo "Language: {$user['language']}\n";
} catch (Exception $e) {
echo "Failed to fetch user: " . $e->getMessage() . "\n";
}
?>
const axios = require('axios');
class UsersAPI {
constructor(apiKey) {
this.client = axios.create({
baseURL: 'https://YOURSITE.konstantly.ai/api/v1',
headers: {
'X-API-KEY': apiKey
}
});
}
async getUserByEmail(email) {
try {
const response = await this.client.get(`/users/byEmail/${encodeURIComponent(email)}`);
return response.data[0];
} catch (error) {
if (error.response) {
if (error.response.status === 404) {
throw new Error(`User with email ${email} not found`);
}
throw new Error(`Failed to fetch user: ${error.response.data.message || error.message}`);
}
throw error;
}
}
}
// Example usage
async function main() {
const usersApi = new UsersAPI('1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv');
try {
const user = await usersApi.getUserByEmail('user@example.com');
console.log(`Found user: ${user.name}`);
console.log(`ID: ${user.id}`);
console.log(`Language: ${user.language}`);
} catch (error) {
console.error('Failed to fetch user:', error.message);
}
}
main();
[
{
"id": "emp-1042",
"name": "John Doe",
"email": "user@example.com",
"language": "en",
"occupation": "Salesman",
"location": "London",
"timezone": "Europe/London",
"isBanned": false,
"fromApi": false,
"authType": 0,
"createdAt": 1700000000,
"lastActivity": 1700086400,
"image": null
}
]
{
"status": 404,
"message": "User not found"
}
Retrieve detailed information about a specific user using their email address.
Request Headers
URL Parameters
Response
Returns an array with one user object.Interface and notification language code, e.g.
en. en when the user has not chosen one.Error Responses
curl --request GET \
--url 'https://YOURSITE.konstantly.ai/api/v1/users/byEmail/user@example.com' \
--header 'X-API-KEY: 1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv'
import requests
from typing import Dict
def get_user_by_email(api_key: str, email: str) -> Dict:
url = f"https://YOURSITE.konstantly.ai/api/v1/users/byEmail/{email}"
headers = {
"X-API-KEY": api_key
}
try:
response = requests.get(url, headers=headers)
if response.status_code == 404:
raise ValueError(f"User with email {email} not found")
response.raise_for_status()
return response.json()[0]
except requests.exceptions.RequestException as e:
print(f"Error fetching user: {str(e)}")
if hasattr(e, 'response') and e.response is not None:
print(f"Response: {e.response.text}")
raise
# Example usage
if __name__ == "__main__":
try:
user = get_user_by_email(
api_key="1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv",
email="user@example.com"
)
print(f"Found user: {user['name']}")
print(f"ID: {user['id']}")
print(f"Language: {user['language']}")
except Exception as e:
print(f"Failed to fetch user: {str(e)}")
<?php
class UsersAPI {
private $apiKey;
private $baseUrl;
public function __construct($apiKey) {
$this->apiKey = $apiKey;
$this->baseUrl = 'https://YOURSITE.konstantly.ai/api/v1';
}
public function getUserByEmail($email) {
$ch = curl_init();
$url = "{$this->baseUrl}/users/byEmail/" . urlencode($email);
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'X-API-KEY: ' . $this->apiKey
]
]);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
if (curl_errno($ch)) {
throw new Exception('Error: ' . curl_error($ch));
}
curl_close($ch);
$responseData = json_decode($response, true);
if ($httpCode === 404) {
throw new Exception("User with email {$email} not found");
}
if ($httpCode !== 200) {
throw new Exception("Failed to fetch user. Status code: {$httpCode}");
}
return $responseData[0];
}
}
// Example usage
try {
$usersApi = new UsersAPI('1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv');
$user = $usersApi->getUserByEmail('user@example.com');
echo "Found user: {$user['name']}\n";
echo "ID: {$user['id']}\n";
echo "Language: {$user['language']}\n";
} catch (Exception $e) {
echo "Failed to fetch user: " . $e->getMessage() . "\n";
}
?>
const axios = require('axios');
class UsersAPI {
constructor(apiKey) {
this.client = axios.create({
baseURL: 'https://YOURSITE.konstantly.ai/api/v1',
headers: {
'X-API-KEY': apiKey
}
});
}
async getUserByEmail(email) {
try {
const response = await this.client.get(`/users/byEmail/${encodeURIComponent(email)}`);
return response.data[0];
} catch (error) {
if (error.response) {
if (error.response.status === 404) {
throw new Error(`User with email ${email} not found`);
}
throw new Error(`Failed to fetch user: ${error.response.data.message || error.message}`);
}
throw error;
}
}
}
// Example usage
async function main() {
const usersApi = new UsersAPI('1qaz2wsx3edc4rfv1qaz2wsx3edc4rfv');
try {
const user = await usersApi.getUserByEmail('user@example.com');
console.log(`Found user: ${user.name}`);
console.log(`ID: ${user.id}`);
console.log(`Language: ${user.language}`);
} catch (error) {
console.error('Failed to fetch user:', error.message);
}
}
main();
[
{
"id": "emp-1042",
"name": "John Doe",
"email": "user@example.com",
"language": "en",
"occupation": "Salesman",
"location": "London",
"timezone": "Europe/London",
"isBanned": false,
"fromApi": false,
"authType": 0,
"createdAt": 1700000000,
"lastActivity": 1700086400,
"image": null
}
]
{
"status": 404,
"message": "User not found"
}
Was this page helpful?