Skip to content

Instantly share code, notes, and snippets.

Last active November 22, 2023 21:17
  • Star 14 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="" integrity="sha512-MoRNloxbStBcD8z3M/2BmnT+rg4IsMxPkXaGh2zD6LGNNFE80W3onsAhRcMAMrSoyWL9xD7Ert0men7vR8LUZg==" crossorigin="anonymous" />
<title>XMRig API test</title>
<div class="container">
<form style="margin-top: 12px">
<div class="form-group">
<label for="address">API address and endpoint</label>
<input type="text" class="form-control" id="address" required placeholder="<port>/2/summary">
<div class="form-group">
<label for="token">Access Token</label>
<input type="password" class="form-control" id="token" placeholder="Optional">
<button id="submit" type="submit" class="btn btn-primary">Get API data</button>
<pre id="result" style="margin-top: 12px; border: 1px solid rgba(0,0,0,.15); padding: 12px"></pre>
<script src="" integrity="sha512-bLT0Qm9VnAYZDflyKcBaQ2gg0hSYNQrJ8RilYldYQ1FxQYoCLtUjuuRuZo+fjqhx/qtq/1itJ0C2ejDxltZVFg==" crossorigin="anonymous"></script>
$(function() {
$('#submit').on('click', function(event) {
var address = $('#address').val();
if (!address) {
getData(address, $('#token').val());
function getData(address, token) {
var headers = {};
if (token) {
headers.Authorization = 'Bearer ' + token
method: 'get',
url: address,
headers: headers
.done(function(data, textStatus, jqXHR) {
localStorage.setItem('address', address);
localStorage.setItem('token', token);
.fail(function(jqXHR, textStatus) {
$('#result').text('Failed to get data (' + jqXHR.status + ')');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment