AndroidNexus API
The AndroidNexus API provides programmatic access to manage your Android device fleet. Use it to automate device management, integrate with your existing tools, and build custom solutions.
Base URL
https://api.devicenexus.ai/api/v1
Authentication
AndroidNexus uses cookie-based JWT authentication with CSRF protection for security.
Login Flow
- Login to get session cookies and CSRF token:
curl -X POST https://api.devicenexus.ai/api/v1/auth/login \
-H "Content-Type: application/json" \
-c cookies.txt \
-d '{"email": "admin@company.com", "password": "your-password"}'
- Extract CSRF token from the login response:
{
"status": "success",
"data": {
"csrf_token": "abc123...",
"expires_in": 86400
}
}
- Include cookies and CSRF token in subsequent requests:
# GET requests - only need cookies
curl -b cookies.txt \
https://api.devicenexus.ai/api/v1/devices
# POST/PUT/DELETE requests - need cookies AND CSRF token
curl -X POST https://api.devicenexus.ai/api/v1/devices/{id}/commands \
-b cookies.txt \
-H "Content-Type: application/json" \
-H "X-CSRF-Token: abc123..." \
-d '{"command_type": "lock_device"}'
CSRF Protection
| Request Type | Cookie Required | CSRF Token Required |
|---|---|---|
| GET | Yes | No |
| POST | Yes | Yes |
| PUT | Yes | Yes |
| DELETE | Yes | Yes |
caution
Store your CSRF token securely. It's required for all state-changing operations.
Response Format
All responses follow a consistent structure:
Success Response
{
"status": "success",
"data": {
// Response data here
}
}
Error Response
{
"status": "error",
"error": "Error message describing what went wrong"
}
Pagination
List endpoints support pagination with these parameters:
| Parameter | Default | Description |
|---|---|---|
page | 1 | Page number (starts at 1) |
limit | 50 | Items per page (max 100) |
Paginated responses include metadata:
{
"status": "success",
"data": {
"devices": [...],
"pagination": {
"page": 1,
"limit": 50,
"total": 150,
"total_pages": 3,
"has_next": true,
"has_prev": false
}
}
}
Quick Start Examples
List All Devices
curl -b cookies.txt \
"https://api.devicenexus.ai/api/v1/devices?page=1&limit=20"
Get Device Details
curl -b cookies.txt \
"https://api.devicenexus.ai/api/v1/devices/dev_abc123"
Send Lock Command
curl -X POST "https://api.devicenexus.ai/api/v1/devices/dev_abc123/commands" \
-b cookies.txt \
-H "Content-Type: application/json" \
-H "X-CSRF-Token: $CSRF_TOKEN" \
-d '{
"command_type": "lock_device",
"payload": {}
}'
Create Enrollment Token
curl -X POST "https://api.devicenexus.ai/api/v1/enrollment_tokens" \
-b cookies.txt \
-H "Content-Type: application/json" \
-H "X-CSRF-Token: $CSRF_TOKEN" \
-d '{
"name": "Sales Team Enrollment",
"enrollment_type": "amapi_enrollment",
"enrollment_mode": "FULLY_MANAGED",
"max_uses": 50
}'
SDK Examples
Python
import requests
BASE_URL = "https://api.devicenexus.ai/api/v1"
# Create a session to persist cookies
session = requests.Session()
# Login
login_response = session.post(
f"{BASE_URL}/auth/login",
json={"email": "admin@company.com", "password": "your-password"}
)
csrf_token = login_response.json()["data"]["csrf_token"]
# GET request (no CSRF needed)
devices = session.get(f"{BASE_URL}/devices").json()
# POST request (CSRF required)
command_response = session.post(
f"{BASE_URL}/devices/dev_abc123/commands",
headers={"X-CSRF-Token": csrf_token},
json={"command_type": "lock_device", "payload": {}}
)
JavaScript
const BASE_URL = 'https://api.devicenexus.ai/api/v1';
let csrfToken = null;
// Login
async function login(email, password) {
const response = await fetch(`${BASE_URL}/auth/login`, {
method: 'POST',
credentials: 'include', // Important: includes cookies
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ email, password })
});
const data = await response.json();
csrfToken = data.data.csrf_token;
return data;
}
// GET request
async function listDevices() {
const response = await fetch(`${BASE_URL}/devices`, {
credentials: 'include'
});
return response.json();
}
// POST request
async function sendCommand(deviceId, commandType) {
const response = await fetch(`${BASE_URL}/devices/${deviceId}/commands`, {
method: 'POST',
credentials: 'include',
headers: {
'Content-Type': 'application/json',
'X-CSRF-Token': csrfToken
},
body: JSON.stringify({ command_type: commandType, payload: {} })
});
return response.json();
}
Available Commands
| Command | Description |
|---|---|
lock_device | Lock the device screen |
reboot_device | Restart the device |
reset_password | Reset the device password |
clear_app_data | Clear data for a specific app |
start_lost_mode | Enable lost mode with contact info |
stop_lost_mode | Disable lost mode |
factory_reset | Factory reset the device |
Enrollment Modes
| Mode | Description |
|---|---|
FULLY_MANAGED | Company-owned device with full control |
WORK_PROFILE | BYOD with work profile |
COPE | Company-owned, personally enabled |
DEDICATED | Kiosk or dedicated device |
Need Help?
- API Reference: Browse the complete API documentation in this section
- Support: Contact support@devicenexus.ai