Admin API & HMAC
๐ XUI.ONE Admin API & HMAC Authentication Guide
This guide provides an in-depth overview of the XUI.ONE Admin API, including available endpoints, HMAC authentication mechanisms, and configuration procedures.
๐ Enabling the Admin API in XUI.ONE
To utilize the Admin API:
- Access the Admin Panel: Navigate to
Management > Access Control > Access Codes. - Create an Access Code:
- Set the Access Type to
Admin API. - Assign it to the
Administratorsgroup. - Optionally, restrict access by specifying an IP address.
- Set the Access Type to
- Generate API Key: In your admin profile, generate a unique API key
Your API endpoint will resemble
http://yourdomain.com:8000/accesscode/?api_key=YOUR_API_KEY
https://yourdomain.com:9000/accesscode/?api_key=YOUR_API_KEYTo execute API actions, append the action parameter:
https://yourdomain.com:9000/accesscode/?api_key=YOUR_API_KEY&action=desired_action๐งฐ Available API Endpoints
๐ Information Retrieval
get_usersget_linesget_streamsget_channelsget_moviesget_series_listget_episodesuser_infomysql_query
๐ Logs & Events
activity_logslive_connectionscredit_logsclient_logsuser_logsstream_errorswatch_outputsystem_logslogin_logsrestream_logsmag_events
๐ค User Management
get_usercreate_useredit_userdelete_userdisable_userenable_user
๐ถ Line Management
get_linecreate_lineedit_linedelete_linedisable_lineenable_lineban_lineunban_line
๐บ MAG & Enigma Devices
get_mag/get_enigmacreate_mag/create_enigmaedit_mag/edit_enigmadelete_mag/delete_enigmadisable_mag/disable_enigmaenable_mag/enable_enigmaban_mag/ban_enigmaunban_mag/unban_enigmaconvert_mag/convert_enigma
๐ Access Codes
get_access_codesget_access_codecreate_access_codeedit_access_codedelete_access_code
๐ Bouquets
get_bouquetsget_bouquetcreate_bouquetedit_bouquetdelete_bouquet
๐ EPG Management
get_epgsget_epgcreate_epgedit_epgdelete_epgreload_epg
๐ HMAC Keys
get_hmacsget_hmaccreate_hmacedit_hmacdelete_hmac
๐ Implementing HMAC Authentication
HMAC (Hash-based Message Authentication Code) enhances API security by ensuring message integrity and authenticity.
๐ ๏ธ Configuration Steps
- Generate HMAC Key:
- Use the
create_hmacAPI endpoint to generate a new HMAC key. - Store the
keyandsecretsecurely.
- Use the
- Client-Side Signature Generation:
- Concatenate the request method, URI, and timestamp.
- Use the
secretto generate an HMAC SHA-256 signature of the concatenated string. - Include the following headers in your request:
X-API-KEY: your_api_key
X-Signature: generated_hmac_signature
X-Timestamp: current_timestamp- Server-Side Verification:
- Upon receiving the request, the server uses the stored
secretassociated with the providedX-API-KEYto generate its own HMAC signature. - If the generated signature matches the
X-Signatureheader, the request is authenticated.
- Upon receiving the request, the server uses the stored
This mechanism ensures that requests are from trusted sources and have not been tampered with during transmission.
๐งช Example: Fetching User Information
To retrieve user details using the Admin API:
GET https://yourdomain.com:9000/accesscode/?api_key=YOUR_API_KEY&action=get_user&id=USER_ID
Replace YOUR_API_KEY with your actual API key and USER_ID with the ID of the user you wish to retrieve.
โ ๏ธ Important Considerations
- Security: Always use HTTPS to encrypt API communications.
- Key Management: Rotate your HMAC keys periodically and revoke any compromised keys immediately.
- Access Control: Restrict API access to specific IP addresses when possible.
- Logging: Monitor API usage logs to detect any unauthorized access attempts.
By following this guide, you can effectively utilize the XUI.ONE Admin API and implement HMAC authentication to secure your IPTV services.
