API: Difference between revisions
No edit summary |
No edit summary |
||
(23 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
[[File:Screenshot 2022-01-13 165059.png|alt=|frame]] | |||
New Api will use: | |||
api.s200.etm.dev for API calls | |||
s200.etm.dev is for the default website (Angular/Typescript) | |||
login url https://api.s200.etm.dev/users/login | |||
New auth desing: | |||
*You need to login to the api by using name/password (basic auth) | |||
**(or the ingame one-time-token instead of the password) | |||
*You will get back a x-auth-token | |||
*Every subsequent request should be done with the x-auth-token (as a header) | |||
*Connecting to the websocket is done with x-auth-token as well but IN THE QUERY URL | |||
**wss://api.s200.etm.dev/websocket?x-auth-token=xxxxxxxxx | |||
BELOW HERE IS NO LONGER WORKING | |||
---- | |||
<br /> | |||
==Api Urls== | ==Api Urls== | ||
<syntaxhighlight lang="java"> | <syntaxhighlight lang="java"> | ||
https://s200.etm.dev/auth <- Test the credentials | |||
https://s200.etm.dev/transaction/[UserName]/latest | https://s200.etm.dev/transaction/[UserName]/latest | ||
https://s200.etm.dev/shop/[UserName]/[world] | https://s200.etm.dev/shop/[UserName]/[world] | ||
https://s200.etm.dev/userstats/[UserName]/[datetime] (2020-05-24T14:00) partial allowed! | |||
https://s200.etm.dev/user/[UserName] | |||
https://s200.etm.dev/server/playerlocations/[world] <-- Needs /user ksonpubliclocation ON ! | |||
https://s200.etm.dev/land/[UserName]/[world] | |||
Transactions for the whole day: | |||
https://s200.etm.dev/transaction/Kademlia/day/2020-05-31T00:00 // Hit the day you want with the datetime | |||
https://s200.etm.dev/transaction/Kademlia/month/2020-05-01 // Hit the month you want with the date | |||
Transactions after a previous transaction id: | |||
https://s200.etm.dev/transaction/Kademlia/after/0Y1QW1N2 | |||
UUID Lookups: | |||
https://s200.etm.dev/mojang/name/{uuid} | |||
https://s200.etm.dev/mojang/names POST with a list of UUID[] | |||
Pods: | |||
https://s200.etm.dev/pod/{username:.+}/{podName:.+} | |||
Currently only one working: https://s200.etm.dev/pod/NAME/Technology | |||
These calls need authentication. To auth you need to: | |||
1. Go on the server and enable the api calls for your account with: /user api on | |||
2. Copy your secret with: /user secret | |||
3. Call the URL with HEADER-Parameter "Auth" and value: {"userName":"USERNAME","secret":"YOURSECRET"} | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Line 10: | Line 71: | ||
curl -H "Auth:{\"userName\":\"tigerjunge15\",\"secret\":\"F4kWNs7UKfUss7XKdJE8P9DOwFrQB2RvTYx+hPFWGoGZaC/NrSIyEg==\"}" https://s200.etm.dev/transaction/tigerjunge15/latest | curl -H "Auth:{\"userName\":\"tigerjunge15\",\"secret\":\"F4kWNs7UKfUss7XKdJE8P9DOwFrQB2RvTYx+hPFWGoGZaC/NrSIyEg==\"}" https://s200.etm.dev/transaction/tigerjunge15/latest | ||
<syntaxhighlight lang="java"> | |||
https://s200.etm.dev/userstats/tigerjunge15/2020 | |||
https://s200.etm.dev/userstats/tigerjunge15/2020-05 | |||
https://s200.etm.dev/userstats/tigerjunge15/05-24 | |||
https://s200.etm.dev/userstats/tigerjunge15/2020-05-24 | |||
</syntaxhighlight> | |||
==Latest transactions example== | ==Latest transactions example== | ||
Line 18: | Line 86: | ||
{"userName":"Lasergott","secret":"fe6FeQsgDDWybNAZsXEHsdgQ7nIXprUd/feIBRMD4ifqdvWnV98bnA=="}" | {"userName":"Lasergott","secret":"fe6FeQsgDDWybNAZsXEHsdgQ7nIXprUd/feIBRMD4ifqdvWnV98bnA=="}" | ||
==Desktop interaction== | |||
<br /> | |||
<syntaxhighlight lang="javascript"> | |||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> | |||
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script> | |||
<style> | |||
.pixelated { | |||
-ms-interpolation-mode: nearest-neighbor; | |||
image-rendering: -webkit-optimize-contrast; | |||
image-rendering: -moz-crisp-edges; | |||
image-rendering: pixelated; | |||
} | |||
</style> | |||
<script> | |||
const zoom = 2; | |||
const size = 640 * zoom; | |||
const userName = "Kademlia" | |||
const secret = "dy0GmZ0rckUfkjjx/WKUnnhnsIGbseQCGtDRbGH+6LVYelfvljRJJg=="; | |||
const auth = { 'Auth': `{"userName":"${userName}","secret":"${secret}"}` } | |||
$(document).ready(function() { | |||
$('img').attr('src', `https://s200.etm.dev/desktop/screenshot/${userName}/`); | |||
$('img').attr('width', `${size}px`); | |||
$("img").on("click", function(event) { | |||
var x = event.pageX - this.offsetLeft; | |||
var y = event.pageY - this.offsetTop; | |||
onClick(x / zoom,y / zoom); | |||
}); | |||
function onClick(x, y) { | |||
axios.post(`https://s200.etm.dev/desktop/screenshot/${userName}`, { x, y }, | |||
{ responseType: 'arraybuffer', headers: auth} | |||
) | |||
.then(( response ) => { | |||
var b64 = btoa(String.fromCharCode.apply(null, new Uint8Array( response.data))); | |||
$('img').attr('src', 'data:image/png;base64,'+b64) | |||
}) | |||
.catch((e) => { | |||
// handle error | |||
console.log(e) | |||
}) | |||
} | |||
}); | |||
</script> | |||
<img class="pixelated" src="" alt="You are not online"> | |||
</syntaxhighlight> |
Latest revision as of 16:01, 13 January 2022
New Api will use:
api.s200.etm.dev for API calls
s200.etm.dev is for the default website (Angular/Typescript)
login url https://api.s200.etm.dev/users/login
New auth desing:
- You need to login to the api by using name/password (basic auth)
- (or the ingame one-time-token instead of the password)
- You will get back a x-auth-token
- Every subsequent request should be done with the x-auth-token (as a header)
- Connecting to the websocket is done with x-auth-token as well but IN THE QUERY URL
- wss://api.s200.etm.dev/websocket?x-auth-token=xxxxxxxxx
BELOW HERE IS NO LONGER WORKING
Api Urls
https://s200.etm.dev/auth <- Test the credentials
https://s200.etm.dev/transaction/[UserName]/latest
https://s200.etm.dev/shop/[UserName]/[world]
https://s200.etm.dev/userstats/[UserName]/[datetime] (2020-05-24T14:00) partial allowed!
https://s200.etm.dev/user/[UserName]
https://s200.etm.dev/server/playerlocations/[world] <-- Needs /user ksonpubliclocation ON !
https://s200.etm.dev/land/[UserName]/[world]
Transactions for the whole day:
https://s200.etm.dev/transaction/Kademlia/day/2020-05-31T00:00 // Hit the day you want with the datetime
https://s200.etm.dev/transaction/Kademlia/month/2020-05-01 // Hit the month you want with the date
Transactions after a previous transaction id:
https://s200.etm.dev/transaction/Kademlia/after/0Y1QW1N2
UUID Lookups:
https://s200.etm.dev/mojang/name/{uuid}
https://s200.etm.dev/mojang/names POST with a list of UUID[]
Pods:
https://s200.etm.dev/pod/{username:.+}/{podName:.+}
Currently only one working: https://s200.etm.dev/pod/NAME/Technology
These calls need authentication. To auth you need to:
1. Go on the server and enable the api calls for your account with: /user api on
2. Copy your secret with: /user secret
3. Call the URL with HEADER-Parameter "Auth" and value: {"userName":"USERNAME","secret":"YOURSECRET"}
curl -H "Auth:{\"userName\":\"Kademlia\",\"secret\":\"xxxxxxxxxxxxxx\"}" https://s200.etm.dev/transaction/Kademlia/latest
curl -H "Auth:{\"userName\":\"tigerjunge15\",\"secret\":\"F4kWNs7UKfUss7XKdJE8P9DOwFrQB2RvTYx+hPFWGoGZaC/NrSIyEg==\"}" https://s200.etm.dev/transaction/tigerjunge15/latest
https://s200.etm.dev/userstats/tigerjunge15/2020
https://s200.etm.dev/userstats/tigerjunge15/2020-05
https://s200.etm.dev/userstats/tigerjunge15/05-24
https://s200.etm.dev/userstats/tigerjunge15/2020-05-24
Latest transactions example
Http-Header "Auth" with value: {"userName":"tigerjunge15","secret":"F4kWNs7UKfUss7XKdJE8P9DOwFrQB2RvTYx+hPFWGoGZaC/NrSIyEg=="}"
Url: https://s200.etm.dev/transaction/tigerjunge15/latest
{"userName":"Lasergott","secret":"fe6FeQsgDDWybNAZsXEHsdgQ7nIXprUd/feIBRMD4ifqdvWnV98bnA=="}"
Desktop interaction
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
<style>
.pixelated {
-ms-interpolation-mode: nearest-neighbor;
image-rendering: -webkit-optimize-contrast;
image-rendering: -moz-crisp-edges;
image-rendering: pixelated;
}
</style>
<script>
const zoom = 2;
const size = 640 * zoom;
const userName = "Kademlia"
const secret = "dy0GmZ0rckUfkjjx/WKUnnhnsIGbseQCGtDRbGH+6LVYelfvljRJJg==";
const auth = { 'Auth': `{"userName":"${userName}","secret":"${secret}"}` }
$(document).ready(function() {
$('img').attr('src', `https://s200.etm.dev/desktop/screenshot/${userName}/`);
$('img').attr('width', `${size}px`);
$("img").on("click", function(event) {
var x = event.pageX - this.offsetLeft;
var y = event.pageY - this.offsetTop;
onClick(x / zoom,y / zoom);
});
function onClick(x, y) {
axios.post(`https://s200.etm.dev/desktop/screenshot/${userName}`, { x, y },
{ responseType: 'arraybuffer', headers: auth}
)
.then(( response ) => {
var b64 = btoa(String.fromCharCode.apply(null, new Uint8Array( response.data)));
$('img').attr('src', 'data:image/png;base64,'+b64)
})
.catch((e) => {
// handle error
console.log(e)
})
}
});
</script>
<img class="pixelated" src="" alt="You are not online">