Your cart is empty now.
Quarkifi Technologies Pvt Ltd Shop-4, Tulip Plaza Apartment, Kharghar Gram Panchayat Road, Secor-13 Shri Sadguru Kripa Printer and Stationery, Kharghar, Navi Mumbai, Raigad, Maharashtra, 410210
support@quarkifi.com
+918898424998
const axios = require('axios')
const crypto = require('crypto')
const timestamp = new Date().toISOString()
const apiKey = 'Add your API key here'
const userId = 'Add your User Id here'
const secretKey = 'Add your Secret Key here'
const content = apiKey + userId + timestamp
const signature = crypto.createHmac('sha256', secretKey)
.update(content)
.digest('hex')
const url = 'https://testapi.magiqworks.online/api/device'
const headers = {
'MQ-TIMESTAMP': timestamp,
'MQ-API-KEY': apiKey,
'MQ-SIGNATURE': signature,
'MQ-USER-ID': userId
}
const body = {
userId: userId,
action: 'GET'
}
axios.post(url, body, { headers })
.then(response => {
console.log(response.data)
})
.catch(error => {
console.error(error)
})
import requests
import json
import hashlib
import hmac
from datetime import datetime, timezone
api_key = 'Add your API key here'
user_id = 'Add your user id here'
secret_key = 'Add your secret key here'
# Function to get device
def get_all_device():
# timestamp = datetime.utcnow().isoformat() + 'Z'
timestamp = datetime.now(timezone.utc).isoformat()
content = api_key + user_id + timestamp
signature = hmac.new(secret_key.encode(), content.encode(), hashlib.sha256).hexdigest()
url = 'https://testapi.magiqworks.online/api/device'
headers = {
'MQ-TIMESTAMP': timestamp,
'MQ-API-KEY': api_key,
'MQ-SIGNATURE': signature,
'MQ-USER-ID': user_id,
'Content-Type': 'application/json'
}
body = {
"userId": user_id,
"action": "GET"
}
# Handle response appropriately
try:
response = requests.post(url, data=json.dumps(body), headers=headers)
response.raise_for_status()
return response.json()
except requests.RequestException as error:
print('Error getting device:', error)
return None
if __name__ == '__main__':
device_id = '16612385'
response = get_all_device()
if response:
print('Device found:', response)
else:
print('Error:', response)
timestamp=$(date -u +"%T %d-%m-%Y GMT")
echo "Timestamp: $timestamp"
api_key="Add your API key here"
user_id="Add your user id here"
secret_key="Add your Secret key here"
message="$api_key$user_id$timestamp"
echo "Message: $message"
signature=$(echo -n "$message" | openssl dgst -sha256 -hmac $secret_key | cut -d' ' -f2)
echo "Generated Signature: $signature"
curl -X POST \
https://testapi.magiqworks.online/api/device \
-H "MQ-TIMESTAMP: $timestamp" \
-H "MQ-API-KEY: $api_key" \
-H "MQ-SIGNATURE: $signature" \
-H "MQ-USER-ID: $user_id" \
-d '{
"userId": "'"$user_id"'",
"action": "GET"
}'
const axios = require('axios')
const crypto = require('crypto')
const apiKey = 'Add your API key here'
const userName = 'Add your User Id here'
const SecretKey = 'Add your Secret Key here'
// Function to generate HMAC SHA-256 signature
function generateSignature(content, secretKey) {
return crypto.createHmac('sha256', secretKey).update(content).digest('hex')
}
// Function to get device
async function getDevice(deviceId) {
const timestamp = new Date().toISOString()
const content = apiKey + userName + timestamp
const signature = generateSignature(content, SecretKey)
const url = `https://testapi.magiqworks.online/api/device`
const headers = {
'MQ-TIMESTAMP': timestamp,
'MQ-API-KEY': apiKey,
'MQ-SIGNATURE': signature,
'MQ-USER-ID': userName
}
const body = {
userId: userName,
deviceId: deviceId,
action: 'GET'
}
try {
const response = await axios.post(url, body, { headers })
return response.data
} catch(error) {
console.error('Error getting device:', error)
return null
}
}
// Usage Example
getDevice('1234567').then(response => {
console.log('Device found:', response)
}).catch(error => {
console.error('Error:', error)
})
import requests
import hmac
import hashlib
import json
# from datetime import datetime
from datetime import datetime, timezone
api_key = 'Add your API key here'
user_id = 'Add your user id here'
secret_key = 'Add your secret key here'
# Function to get device
def get_device(device_id):
timestamp = datetime.now(timezone.utc).isoformat()
content = api_key + user_id + timestamp
signature = hmac.new(secret_key.encode(), content.encode(), hashlib.sha256).hexdigest()
url = 'https://testapi.magiqworks.online/api/device'
headers = {
'MQ-TIMESTAMP': timestamp,
'MQ-API-KEY': api_key,
'MQ-SIGNATURE': signature,
'MQ-USER-ID': user_id,
'Content-Type': 'application/json'
}
body = {
'userId': user_id,
'deviceId': device_id,
'action': 'GET'
}
try:
response = requests.post(url, headers=headers, data=json.dumps(body))
response.raise_for_status()
return response.json()
except requests.RequestException as error:
print('Error getting device:', error)
return None
if __name__ == '__main__':
device_id = '16612385'
response = get_device(device_id)
if response:
print('Device found:', response)
else:
print('Error:', response)
# Constants
apiKey="Add your API key here"
userId="Add your user id here"
secretKey="Add your Secret key here"
deviceId="16612385"
# Generate timestamp
timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
# Generate signature
content="$apiKey$userId$timestamp"
signature=$(echo -n $content | openssl dgst -sha256 -hmac $secretKey | cut -d " " -f2)
# Get device information
get_response=$(curl -s -X POST "https://testapi.magiqworks.online/api/device" \
-H "MQ-TIMESTAMP: $timestamp" \
-H "MQ-API-KEY: $apiKey" \
-H "MQ-SIGNATURE: $signature" \
-H "MQ-USER-ID: $userId" \
-H "Content-Type: application/json" \
-d '{
"userId": "'"$userId"'",
"deviceId": "'"$deviceId"'",
"action": "GET"
}')
# Parse the response
device=$(echo $get_response | jq -r '.device' | sed "s/'/\"/g")
if [[ $device == null ]]; then
echo $get_response
else
echo "device found: $device"
fi