Disk/Traffic API Endpoint
This is an unofficial script that is provided for your convenience. The script is provided as-is and may not be updated or maintained by Ultra.cc. Customers are welcome to use and customize unofficial scripts for their unique needs and requirements. Unofficial support may be offered via Discord only and at the sole discretion of Ultra.cc staff. Use at your own risk.
The Disk/Traffic API Endpoint script will provide three API endpoints to your Ultra.cc service. The script will be installed as a Flask application in ~/scripts/Ultra_API
and run in a screen session called UltraAPIpoints
. At the moment, three API endpoints are provided, as shown below.
- Disk usage stats using
quota -s
. - Traffic stats using
app-traffic info
. - The above combined into one endpoint.
Installation
Before you can proceed with installing the API Endpoint script, Python needs to be version 3.6 or above.
Upgrade Python
ConnectUpgrade Python toyour3.6Ultra.ccorslot via SSH,higher, see guide here.Once connected, execute the following command:
bash <(wget -qO- https://scripts.usbx.me/util/LanguageInstaller/Python-Installer/main.sh)
Typeconfirmto proceed with the installation.Next, pick a Python version above 3.6 or type4for latest versionPressENTERto confirm.When the installation has finished, execute the following command:
source ~/.profile
With Python updated to version 3.6 or above, you can proceed the installation.
Script Installation
- Connect to your Ultra.cc slot via SSH, see guide here
- Once connected, execute the following command:
bash <(wget -qO- https://scripts.usbx.me/util/API-EndPoints/main.sh)
- Type
confirm
and pressENTER
to confirm - Press
1
andENTER
to proceed with the installation- or, if you have already installed the script, and it is not responding. Press
3
andENTER
to restart the script. - or, if you have already installed the script, and require your authentication token. Press
4
andENTER
.
- or, if you have already installed the script, and it is not responding. Press
- Choose an unused application from the list shown, type its name to borrow its port. Press
ENTER
to confirm - Type
confirm
and pressENTER
to confirm - After the installation has been successfully completed, the below output should be shown.
- In your URL's,
username.hostname
will be replaced with the username and hostname of your Ultra.cc service.
- In your URL's,
Script has been installed successfully.
Creating SQLite3 database and table...
Token successfully generated: <YOUR-AUTH-TOKEN>
Ultra service API End points to get your service stats:
■ Complete Stats........: https://username.hostname.usbx.me/ultra-api/get_stats
■ Storage Stats.........: https://username.hostname.usbx.me/ultra-api/get_quota
■ Traffic Stats.........: https://username.hostname.usbx.me/ultra-api/get_bandwidth
The script has been installed.
- The above URL's are where your API endpoints can be accessed.
Usage
Request Script
Once you have successfully installed the script, you are ready to start sending request to the API endpoints. Execute the below command to download a basic request script that we offer as a demonstration.
wget https://scripts.usbx.me/util/API-EndPoints/Requester.py
- Before you can use the request script you need to amend it and add your username, hostname, and authentication token. Execute the following command to open the script in an editor.
nano Requeser.py
- At the bottom you will see the following:
url = "https://username.hostname.usbx.me/ultra-api/endpoint" # Replace with your desired URL
auth_token = "YOUR_AUTH_TOKEN" # Replace with your actual auth token
- In the URL string, replace
username.hostname
with the username and hostname of your Ultra.cc service.- Username and hostname can be found on the UCP. The hostname of your service is the name of the server. For example, in
spica.usbx.me
the hostname isspica
.
- Username and hostname can be found on the UCP. The hostname of your service is the name of the server. For example, in
- In the auth_token string, replace
YOUR_AUTH_TOKEN
with the auth token that was generated during the installation of the script. By executing the script installation command and selecting option4
, it will print the auth token again. - Lastly, you need to amend the last bit of the URL with one of the endpoints printed at script installation. This is done by replacing
/endpoint
with either of the three endpoints provided:-
/get_stats
-
/get_quota
-
/get_bandwidth
-
- If done correctly, it should look something like what you see below, but with your specific details:
url = "https://coolguy69.spica.usbx.me/ultra-api/get_stats" # Replace with your desired URL
auth_token = "0JQ3LJOnXq7IiJyujlPFzR9S" # Replace with your actual auth token
- To save your changes and exit the editor, press
CTRL+x
andy
, then pressENTER
to confirm. - Next, run the request script by executing:
python Requester.py
- If successful, you should see your stats presented like this:
Data from GET request:
{"service_stats_info":{"free_storage_bytes":9664750157824,"free_storage_gb":9001.0,"last_traffic_reset":"2023-08-22T00:00:00","next_traffic_reset":"2023-08-22T00:00:00","total_storage_unit":"G","total_storage_value":11176,"traffic_available_percentage":97.51,"traffic_used_percentage":2.489999999999995,"used_storage_unit":"G","used_storage_value":2175}}
GET request via curl
- Execute a GET request:
curl -X GET -H "Authorization: Bearer YOUR-AUTH-TOKEN" https://username.hostname.usbx.me/ultra-api/endpoint
- Make sure to replace
YOUR-AUTH-TOKEN
,username.hostname
, and/endpoint
.
Uninstallation
- Execute the following command:
bash <(wget -qO- https://scripts.usbx.me/util/API-EndPoints/main.sh)
- Type
confirm
and pressENTER
to confirm - Press
2
andENTER
to proceed the uninstallation - Press
1
andENTER
to confirm - Done!