Working with cURL
6.4.1 Introduction
A command-line utility for sending HTTP requests. Available on any computer without additional installation: built into macOS and Linux, available on Windows starting with Windows 10.
6.4.2 Installation
Windows
curl is built into Windows 10 and newer. To check for its presence:
curl --version
If curl is not installed, download it from curl.se/download.html.
macOS
curl is built-in by default. To check the version:
curl --version
Linux
sudo apt install curl # Ubuntu/Debian
sudo yum install curl # CentOS/RHEL
6.4.3 Command Structure
Basic request syntax with a bearer token: ⚠️ This is an example (Linux/macOS syntax). In Windows, line break characters and quote escaping differ.
curl -X <METHOD> http://<MINER_IP>/api/v1/<endpoint> \
-H "Accept: application/json" \
-H "Authorization: Bearer <token>" \
-H "x-api-key: <key>" \
-H "Content-Type: application/json" \
-d '<request_body>'
Authorization is one of two options:
Authorization: Bearer <token>(obtained viaPOST /unlock) orx-api-key: <key>(created viaPOST /apikeys). Thex-api-keyheader is specified separately, not withinAuthorization. Main flags:
-X— request method:GET,PUT,POST,DELETE-H— request header, e.g., content type or authorization token-d— request body in JSON format (for PUT and POST) If you need additional features, the full list of flags can be found in the official curl documentation:man curlor at curl.se/docs.
6.4.4 Quick Start
Example: obtain a bearer token and immediately use it in the next request.
Step 1. Get the token
curl -X POST http://<MINER_IP>/api/v1/unlock -H"Content-Type: application/json" -d'{"pw": "device_password"}'
⚠️ This is an example (Linux/macOS syntax). For Windows CMD, you need to replace single quotes with escaped double quotes:
-d "{\"pw\": \"device_password\"}"Server response 200 (OK):
{"token":"eyJhbGciOiJIUzI1NiIs..."}
Step 2. Use the token in the request
Copy the token value from the response and insert it into the Authorization header of the next request:
curl -X GET https://<MINER_IP>/api/v1/status -H "Accept: application/json" -H "Authorization: Bearer eyJhbGciOiJIUzI1NiIs..."