How to fetch server info

Hello if i would like to ex. create a discord bot with the status being players online on the server. I would also like this to be on my website but i don’t know how to fetch it… Does anyone know how to do this?

Your server has couple of http endpoints like /info.json and /players.json

1 Like

Where do i find these?

or how do i use these?

http:/yourserverip:yourserverport/players.json
http:/yourserverip:yourserverport/info.json

So i can do like let http:/yourserverip:yourserverport/players.json = players
then make my statis online players/64

It provides server data in json format. Visit the URL and view source to see what you have to work with.

1 Like

Ok ty

Ehm when i acces the http://136.243.15.250:30009/players.json i just see []?

Likely because there’s no players in the server at the moment.

but there is 0 on there rn but should i do let http://136.243.15.250:30009/players.json = players and then set status to online players/64 im on mac so i can’t do the right things but you know what i mean.

Just parse players.json and check the length

1 player online = length 1 = 1/64 online

1 Like

I don’t understand that

I just do that like under each other like 2 player online = length 1 = 1/64 online

2 instead of 1 im sleeping lol

I know how to parse but i don’t see how to do the 1 player online = length 1 = 1/64 online

And what should it parse there is no how many players online thing. It looks like this when a player is connected: [{“endpoint”:“127.0.0.1”,“id”:1,“identifiers”:[“steam:11000010a9fe71f”,“license:12e73cfd7286174cad5244dab894befd0f97244d”,“discord:248838178339815425”,“fivem:92314”],“name”:“bo”,“ping”:42}]

What should i parse from this?

Count the # of objects in the array

Im lost how do i do that in js?

console.log(yourArray.length);
1 Like

But i don’t need it in my console?