Do Snapmaker 2.0 Devices Have a Webpage?

There’s not been any updates to this thread for some time.

A read only API or some way of having multiple connections (or both!) would be awesome if at all possible!

Multiple connections is possible, actually. It just requires copying your token to other connecting machines.

@fillibar
@parachvte
@bastiaanslee

is there somewhere a more exhausive guide how to connect? Every try results in ERR_CONNECTION_REFUSED

I have an Artisan, is it there different?

I had a job running tried javascript (with xxx replaced by device ip):
var request = require(‘request’);
var options = {
url: ‘http://xxx:8080/api/v1/connect’,
method: ‘POST’,
form: ‘’
};
request(options, function(error, response, body) {
if (error) log(error, ‘error’);
});

returned: {‘errno’:-111,‘code’:‘ECONNREFUSED’,‘syscall’:‘connect’,‘address’:‘xxx’,‘port’:8080}

I connected via Luban and tried in browser (chrome):
http://xxx:8080/api/v1/status?token=eyJhbGciOiJIUzI1NiIsInR5cXXXXXXXJpZCI6IiIsIm5hbWUiOiIiLCJpYXQiOjE2OTUyMTkyOTAsImV4cCI6MTY5NzgxMTI5MH0XXXXXXgju25zWl5TLoXXXXXXXXpH_L7p581o-Y6A
where I took the token out of C:\Users\User\AppData\Roaming\snapmaker-luban\machine.json
Also same error.
Someone able to help?

Checkout sm2uploader here on forum or in the GitHub - shurushetr/awesome-snapmaker: Curated list of things that help you make something awesome with Snapmaker machines.

It’s an open source tool that communicates with snapmaker machines. Maybe you can get some inspiration.

Nice collection. Thxs for the link. Couldn‘t find thou adhoc a fitting information. Perhaps those who managed getting it work could tell me how to succeed :slight_smile:

@Skreelink
@fillibar
@bastiaanslee
@parachvte
some hints for me, please?

What exactly are you trying to do? A good first step is to make sure Luban can connect to make sure your token is current.

Thxs for your resprone. At start I try to get the status of the machine over the API - as said I have an Artisan. Luban is able to connect to the machine. Everytime I am doing this with Luban the token entry in C:\Users\User\AppData\Roaming\snapmaker-luban\machine.json gets updated. But I am not able to do a connect with POST or get a status with GET using this token while Luban is still connected.
Tried now with Insomania:



image

You will need the token for connect as well, and status there’s usually some form of timestamp at the end as well (or random string of numbers, I really don’t know). You could try some of my batch files found here;

Try the “SendCode” from post 4, replace your IP/Token, run the .bat, and try sending G28 to home the machine.

so glad for your support - thxs.
Just for understanding. I thought with the connect I get the token for further communication. If not where do I get it? I used this one out of the above mentioned machine.json. But I do not think this is the right one, as it changes everytime Luban starts.

the SECOND ONE…

You should be getting the token from the machine json file, yes. I don’t know if they changed anything for the Artisan or newer versions of Luban. I never use Luban anymore, except maybe checking status. However, I’ve never had the token change unless I used a different machine.

the first one is right at start of the file:
{
“version”: “4.8.2”,
“state”: {
“session”: {
“enabled”: false,
“token”: “eyJhbGciOiJIUzIXXXXXXXXXXXXXXkpXVCJ9.eyJpZCI6IiIsIm5hbWUiOiIiLCJpYXQiOjE2OTUzODk5MzUsImV4cCI6MTY5Nzk4MTkzNX0.BEfK4SidNH4AUJhzHO-FBRuCtBGzv9w6A_YaWIi0ekM”,
“name”: “”
},

the second one is empty:
“server”: {
“address”: “192.168.1.186”,
“isAuto”: false,
“name”: “Olaf”,
“token”: “”
},

there is no third :frowning:

It should be the second one in the server block. Connect with Luban, and while Luban is still open, try looking at the machine.json.

I did - Luban is open and connected. No change to the file. The only change of the file happens at Lubans start. But only the first token is updated

The only other way I can think of to get the token is using a network scanner like Wireshark to sniff the URL that Luban is sending. There MIGHT be a way to get it via the developer console in Luban. I’m not at home currently to really check.

ok - thxs - developer console would be great - I am searching currently all files containing “token”

not sure if they changed it or I am doing wrong. Tried to sniffer:


The UDP I hit the refresh button in Luban at the connection section. If not connecting the UDP request shows up approx. every second. Then I did a connect. Only TCP traffic on port 8888 - no http. Perhaps there is not API on Artisan?

Sniffered as well Cura with Snapmaker snap-in while transfering GCODE for print to the printer:

What’s in the packet data? Noticed it looks like it’s using port 8888 instead of 8080.

yes, I noticed the port. From which number and what section to show?