tltneon / lgsl

LGSL v6.2.1/v7.0.0 for PHP 5.4-8.3+ (Live Game Server List): online status for CS2 (Source Query), Discord, FiveM, Rust, SA:MP, GMOD, Minecraft, Teamspeak and 200+ more games!
GNU General Public License v3.0
151 stars 47 forks source link

Somekind of API? #188

Open MnkyArts opened 7 months ago

MnkyArts commented 7 months ago

Would love to see some kind of api to easily integrate lgsl into websites. Maybe something like a masterlist json where everything is listed? For example like alt:V does it for their serverlist: https://altv.mp/api/servers

tltneon commented 7 months ago

Hi @MnkyArts LGSL now have an api-like feeding page that allow you to get one server's data. Example: https://www.fungameraltersheim.de/lgsl-master/lgsl_files/lgsl_feed.php?type=ts3&ip=213.239.213.230&c_port=9987&q_port=10011&request=s Or you want to get all the servers in a row?

MnkyArts commented 7 months ago

Hey @tltneon,

yes i was talking about all servers in the system.

i played a bit with the system and build something like this: { "name": "A Minecraft Server", "ip": "127.0.0.1", "port": "25565", "game": "minecraft", "map": "world", "players": "0", "maxplayers": "20", "comment": "", "status": "1" }, { "name": "A Minecraft Server 2", "ip": "127.0.0.1", "port": "25566", "game": "minecraft", "map": "world", "players": "0", "maxplayers": "20", "comment": "", "status": "1" },

but would be cool to have this as a feature in the future :)

tltneon commented 7 months ago

Hey, I added little api to lgsl7 branch https://github.com/tltneon/lgsl/tree/lgsl7 To get data from api you need:

  1. Add to lgsl_config.php $lgsl_config['api'] = true;
  2. Open http://lgsl7.test/src/lgsl_feed.php
  3. Get what you need. e.g.
    [{"name":"[Kgr.GD]-alte-Hasen !!! all Server Bans removed !!!","ip":"104.238.159.193","port":"7757","game":"redorchestra","map":"RO-Bondarevo-remastered-v3","players":0,"maxplayers":26,"online":true},{"name":"Pecypc-CEPBEP (Resource-SERVER)+3 perks","ip":"185.97.254.214","port":"7907","game":"killingfloor","map":"KF-Farm","players":0,"maxplayers":20,"online":true},{"name":"Punaportti","ip":"5.9.50.39","port":"34297","game":"rfactor","map":"Pello20212","players":0,"maxplayers":10,"online":true},{"name":"~[FGS]Wunderland~ ALTFIRE 2014","ip":"207.180.246.62","port":"7790","game":"deusex","map":"DXMP_Frequency","players":0,"maxplayers":20,"online":true},{"name":"","ip":"141.95.54.12","port":"7777","game":"ut3","map":"--","players":0,"maxplayers":0,"online":false},{"name":"[www.utbr.cf] The Brazilian UT3 Server","ip":"168.138.135.61","port":"7777","game":"ut3","map":"DM-ShangriLa","players":0,"maxplayers":10,"online":true}]
MnkyArts commented 7 months ago

This is perfect! Amazing how fast you implemented it, thank you!