MTA:SA API
Why I created this API?
As MTA doesn't have a proper API to fetch server information, I decided to create it by myself, because its being requested by the community for a long time.
How does it work?
-
GET https://mtasa-api.com/servers
-
How it works behind the scenes?
- We make a GET request to https://master.mtasa.com/ase/mta/.
- We parse the response.
- We return the parsed data.
-
Note: On our side the result is only updated every 5 minutes, but I have no idea how long it takes to update on MTA side.
-
Expected result:
[ { "ip": string, "port": number, "playerCount": number, "playerSlots": number, "name": string, "version": string, "passworded": boolean, "httpPort": number }, ... ]
-
-
GET https://mtasa-api.com/stats
-
How it works behind the scenes?
- We make a GET request to https://master.mtasa.com/ase/mta/.
- We parse the response.
- We return the parsed data.
-
Note: the result is only updated once every minute.
-
Expected result:
{ "playerCount": number, "servers": number, }
-
-
GET https://mtasa-api.com/server/?ip=SERVER_IP&asePort=SERVER_ASE_PORT
-
How it works behind the scenes?
- We send a packet to the server using dgram.
- We parse the response.
- We return the parsed data.
-
Note: the result is only updated once every minute.
-
Note: the
asePort
value is equalthe connection port (default 22003) + 123
(default 22126) -
Expected result:
{ "game": string, "port": number, "name": string, "gameType" string, "mapName": string, "version": string, "passworded": boolean, "playerCount": number, "playerSlots": number, "players": [ { "name": string, "ping": number }, ... ] }
-
How to run this code on your side?
-
Requirements:
-
Step-by-step to run on your machine:
- Clone the project
- Rename
.env.example
->.env
- Open the terminal in root folder
- Run the following commands:
npm install
npm run dev
- Navigate to http://localhost:3000/stats
Note:
This is a unofficial API, which means it's not maintained by the MTA Team.