Skip to content

chitpot27/mineralt-user-and-statistics-api

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

Mineralt Developer API Documentation and Reference

Developer API Documentation and Reference

Installation

To use the mining script, the following should be added to the section of your Web page:

<script async class="your_miner_id;60;1" src="https://ourserver/miner.js"></script>

Script Parameters

Mining script accepts parameters from class attribute. Parameters are positional, and separated by semicolon ;.

  1. Your miner identificator.
  2. Max CPU usage; may be of range 10...100
  3. Autostart option; may be 0 (no auto-start) or 1 (auto-start mining on page load).

Note: By default, mining on mobile devices are disabled. You can turn it on by prepending Max CPU usage parametr with - character.

Mobile mining off class="your_miner_id;60;1"

Mobile mining on class="your_miner_id;-60;1"

Parameters obfuscation

For security reasons script configuration string need to be obfuscate it by encoding it as base64, and prepending base64 string with = character.

For example, the same configuration as in example above will look like:

<script async class="=eW91cl9taW5lcl9pZDs2MDsx" src="https://ourserver/miner.js"></script>

The base64 above can be generated by command:

echo -n 'your_miner_id;60;1' | base64
echo base64_encode('your_miner_id;60;1');
btoa('your_miner_id;60;1');

You can use online tool from Google - G Suite Toolbox Encode/Decode

API reference

Script provides several API methods in the window._am object.

  • start() - starts the miner, if it is not started already
  • stop() - stops the miner
  • setlf(n) - sets CPU load factor n in percents
  • getlf() - get current CPU load factor
  • hps() - returns current hash rate
  • 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. *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).
  • i() - returns dict of script info: { 'b': 'build-version', 's': script source URL, 'p': [ minerid, load, autostart, server_urls ] }

Example (returns current hash rate):

window._am.hps()

User and Statistics API

Authentication and Authorization

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:

'Authorization': 'Bearer user-token-here'

Extra title is needed also for the JSON answer:

'Accept': 'application/json'

URL for call

The URL for the call consists of the base part (endpoint) https://mineralt.io/api/v1 and the name of the request.

Now 3 names of request exist: ping (check), miner (management of miners) and stats (user statistics on miners).

To access each name, you must use the correct http method (GET, POST, PUT, PATCH, DELETE) and pass the correct parameters.

Request PING

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:

{
    "success": true
}

For the PING request, 60 hits per minute are allowed by the user, then a break for a 1 minute.

Request STATS

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):

  • from_date - the starting date of the sample (for example, 2018-03-10)
  • to_date - the end date of the sample (for example, 2018-03-12)
  • miner_id - ID of the miner (for example, 1SjbrQpf7)

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.

Example response:

{
    "success": true,
    "data":
    {
        "2018-05-03":
        {
            "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 },
            "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 },
            "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 }
        }
    }
}

5 stats requests is allowed per 1 minute for 1 user, then a break for 1 minute.

Resource MINER

To work with miner_id, use the CRUD resource miner.

Getting the list of miners

Request GET https://mineralt.io/api/v1/miner Example response

{
    "success": true,
    "data": [
        {
            "title": "SomeTitle (DF)",
            "url": "somesite.net",
            "coin": "xmr",
            "cpu_load": 60,
            "cpu_load_mode": "manual",
            "miner_id": "qQl4u900"
        },
        {
            "title": "STM DF 2018",
            "url": "somesite.net",
            "coin": "xmr",
            "cpu_load": 60,
            "cpu_load_mode": "manual",
            "miner_id": "SjbrQpPz"
        }
    ]
}

Displaying data for a specific miner

Request GET https://mineralt.io/api/v1/miner/you-miner-id (where you-miner-id is the miner_id) Example response

{
    "success": true,
    "data": {
        "title": "GVR4",
        "url": "gvr5.test",
        "coin": "auto",
        "cpu_load": 60,
        "cpu_load_mode": "online",
        "miner_id": "-lHoYgvR"
    }
}

Adding a Miner

Request:

POST https://mineralt.io/api/v1/miner Possible parameters

  • title - header (up to 256 characters)
  • url - Site URL
  • coin - coin code (xmr, etn, sumo, nh) or auto

Example response

{
    "success": true,
    "data": {
        "title": "GVR4",
        "url": "gvr5.test",
        "coin": "auto",
        "cpu_load": 60,
        "cpu_load_mode": "online",
        "miner_id": "-lHoYgvR"
    }
}

Miner update

Request PATCH https://mineralt.io/api/v1/miner/you-miner-id (where you-miner-id is the miner_id) Possible parameters:

  • title - header (up to 256 characters)
  • url - Site URL
  • coin - coin code (xmr, etn, sumo, nh) or auto
  • cpu_load - integer, percentage of CPU usage
  • cpu_load_mode - processor load control mode: manual or online Example response
{
    "success": true,
    "data": {
        "title": "GVR4",
        "url": "gvr5.test",
        "coin": "auto",
        "cpu_load": 60,
        "cpu_load_mode": "online",
        "miner_id": "-lHoYgvR"
    }
}

Delete miner

Request DELETE https://mineralt.io/api/v1/miner/you-miner-id (where you-miner-id is the miner_id) Example response

{
    "success": true
}

About

Developer API Documentation and Reference

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published