This repository contains tools and scripts for testing and querying the Unraid GraphQL API. It includes both a Python client and a shell script for different usage scenarios.
- Python 3.6+
- Required Python packages (install with
pip install -r requirements.txt
) - For shell script usage: bash, curl, and optionally jq for pretty-printing JSON
- Clone or download this repository
- Install required dependencies:
pip install -r requirements.txt
The Python client (unraid_api_client.py
) provides a comprehensive interface for working with the Unraid GraphQL API.
Basic usage:
# Query basic server information
python3 unraid_api_client.py --ip 192.168.1.100 --key YOUR_API_KEY
# Query array status
python3 unraid_api_client.py --ip 192.168.1.100 --key YOUR_API_KEY --query array
# Run multiple queries
python3 unraid_api_client.py --ip 192.168.1.100 --key YOUR_API_KEY --query all
Available query types:
info
: Basic server informationversions
: Version information for OS, kernel, etc.array
: Array status overviewarray-disks
: Detailed array disk informationparity
: Parity check statusdocker
: Docker containersdocker-networks
: Docker networksdisks
: Physical disks informationnetwork
: Network interfacesshares
: Network sharesvms
: Virtual machinesusers
: User accountsnotifications
: System notificationsapi-keys
: API keys informationflash
: Flash storage informationall
: Run all queries
Additional options:
--https
: Use HTTPS instead of HTTP--direct
: Skip redirect detection and connect directly to the IP--custom "query { ... }"
: Run a custom GraphQL query--important-only
: When querying notifications, only show important ones
The shell script (test_api_curl.sh
) provides a simpler alternative using curl:
# Query basic server information
./test_api_curl.sh --ip 192.168.1.100 --key YOUR_API_KEY
# Query docker containers
./test_api_curl.sh --ip 192.168.1.100 --key YOUR_API_KEY --type docker
# Use HTTPS
./test_api_curl.sh --ip 192.168.1.100 --key YOUR_API_KEY --https --type network
The Unraid API provides a GraphQL interface that allows you to interact with your Unraid server. This section will help you get started with exploring and using the API.
-
First, enable developer mode using the CLI:
unraid-api developer
-
Follow the prompts to enable the sandbox. This will allow you to access the Apollo Sandbox interface.
-
Access the GraphQL playground by navigating to:
http://YOUR_SERVER_IP/graphql
Most queries and mutations require authentication. You can authenticate using either:
- API Keys
- Cookies (default method when signed into the WebGUI)
Use the CLI to create an API key:
unraid-api apikey --create
Follow the prompts to set:
- Name
- Description
- Roles
- Permissions
The generated API key should be included in your GraphQL requests as a header:
{
"x-api-key": "YOUR_API_KEY"
}
The Unraid GraphQL API provides access to various aspects of your Unraid server:
- Server information (CPU, memory, OS)
- Array status and disk management
- Docker containers and networks
- Network interfaces and shares
- Virtual machines
- User accounts
- Notifications
- API key management
- And more...
The API includes several core types:
Node
: Interface for objects with unique IDs - please see Object IdentificationJSON
: For complex JSON dataDateTime
: For timestamp valuesLong
: For 64-bit integers
Array
: Array and disk managementDocker
: Container and network managementInfo
: System informationConfig
: Server configurationConnect
: Remote access settings
Available roles:
admin
: Full accessconnect
: Remote access featuresguest
: Limited read access
Here are example GraphQL queries you can use:
query {
info {
os {
platform
distro
release
uptime
}
cpu {
manufacturer
brand
cores
threads
}
memory {
total
free
used
}
}
}
query {
array {
state
capacity {
disks {
free
used
total
}
}
disks {
name
size
status
temp
}
}
}
query {
dockerContainers {
id
names
state
status
autoStart
image
}
}
- 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
The API implements rate limiting to prevent abuse. Ensure your applications handle rate limit responses appropriately.
The API returns standard GraphQL errors in the following format:
{
"errors": [
{
"message": "Error description",
"locations": [...],
"path": [...]
}
]
}
- 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
.
This project is open-source software provided as-is.