Skip to main content

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

  1. 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"}'
  1. Extract CSRF token from the login response:
{
"status": "success",
"data": {
"csrf_token": "abc123...",
"expires_in": 86400
}
}
  1. 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 TypeCookie RequiredCSRF Token Required
GETYesNo
POSTYesYes
PUTYesYes
DELETEYesYes
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:

ParameterDefaultDescription
page1Page number (starts at 1)
limit50Items 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

CommandDescription
lock_deviceLock the device screen
reboot_deviceRestart the device
reset_passwordReset the device password
clear_app_dataClear data for a specific app
start_lost_modeEnable lost mode with contact info
stop_lost_modeDisable lost mode
factory_resetFactory reset the device

Enrollment Modes

ModeDescription
FULLY_MANAGEDCompany-owned device with full control
WORK_PROFILEBYOD with work profile
COPECompany-owned, personally enabled
DEDICATEDKiosk or dedicated device

Need Help?

  • API Reference: Browse the complete API documentation in this section
  • Support: Contact support@devicenexus.ai