Using the Unraid API
The Unraid API provides a powerful GraphQL interface for managing your server. This guide covers authentication, common queries, and best practices.
The Unraid API provides a GraphQL interface that allows you to interact with your Unraid server. This guide will help you get started with exploring and using the API.
๐ฎ Enabling the GraphQL Sandboxโ
Web GUI Method (Recommended)โ
Using the Web GUI is the easiest way to enable the GraphQL sandbox.
-
Navigate to Settings โ Management Access โ Developer Options
-
Enable the GraphQL Sandbox toggle
-
Access the GraphQL playground by navigating to:
http://YOUR_SERVER_IP/graphql
CLI Methodโ
Alternatively, you can enable developer mode using the CLI:
unraid-api developer --sandbox true
Or use the interactive mode:
unraid-api developer
๐ Authenticationโ
Most queries and mutations require authentication. Always include appropriate credentials in your requests.
You can authenticate using:
- API Keys - For programmatic access
- Cookies - Automatic when signed into the WebGUI
- SSO/OIDC - When configured with external providers
Managing API Keysโ
Navigate to Settings โ Management Access โ API Keys in your Unraid web interface to:
- View existing API keys
- Create new API keys
- Manage permissions and roles
- Revoke or regenerate keys
You can also use the CLI to create an API key:
unraid-api apikey --create
Follow the prompts to set:
- Name
- Description
- Roles
- Permissions
Using API Keysโ
The generated API key should be included in your GraphQL requests as a header:
{
"x-api-key": "YOUR_API_KEY"
}
๐ Available Schemasโ
The API provides access to various aspects of your Unraid server:
System Informationโ
- Query system details including CPU, memory, and OS information
- Monitor system status and health
- Access baseboard and hardware information
Array Managementโ
- Query array status and configuration
- Manage array operations (start/stop)
- Monitor disk status and health
- Perform parity checks
Docker Managementโ
- List and manage Docker containers
- Monitor container status
- Manage Docker networks
Remote Accessโ
- Configure and manage remote access settings
- Handle SSO configuration
- Manage allowed origins
๐ป Example Queriesโ
Check System Statusโ
query {
info {
os {
platform
distro
release
uptime
}
cpu {
manufacturer
brand
cores
threads
}
}
}
Monitor Array Statusโ
query {
array {
state
capacity {
disks {
free
used
total
}
}
disks {
name
size
status
temp
}
}
}
List Docker Containersโ
query {
dockerContainers {
id
names
state
status
autoStart
}
}
๐๏ธ Schema Typesโ
The API includes several core types:
Base Typesโ
Node
: Interface for objects with unique IDs - please see Object IdentificationJSON
: For complex JSON dataDateTime
: For timestamp valuesLong
: For 64-bit integers
Resource Typesโ
Array
: Array and disk managementDocker
: Container and network managementInfo
: System informationConfig
: Server configurationConnect
: Remote access settings
Role-Based Accessโ
Available roles:
admin
: Full accessconnect
: Remote access featuresguest
: Limited read access
โจ Best Practicesโ
- Use the Apollo Sandbox to explore the schema and test queries
- Start with small queries and gradually add fields as needed
- Monitor your query complexity to maintain performance
- Use appropriate roles and permissions for your API keys
- Keep your API keys secure and rotate them periodically
โฑ๏ธ Rate Limitingโ
The API implements rate limiting to prevent abuse. Ensure your applications handle rate limit responses appropriately.
๐จ Error Handlingโ
The API returns standard GraphQL errors in the following format:
{
"errors": [
{
"message": "Error description",
"locations": [...],
"path": [...]
}
]
}
๐ Additional Resourcesโ
- Use the Apollo Sandbox's schema explorer to browse all available types and fields
- Check the documentation tab in Apollo Sandbox for detailed field descriptions
- Monitor the API's health using
unraid-api status
- Generate reports using
unraid-api report
for troubleshooting
For more information about specific commands and configuration options, refer to the CLI documentation or run unraid-api --help
.