Coder Social home page Coder Social logo

dimfu / mtasa-api Goto Github PK

View Code? Open in Web Editor NEW

This project forked from brenodanyel/mtasa-api

0.0 0.0 0.0 282 KB

Unofficial API to fetch statistics from MTA servers

Home Page: https://mtasa-api.com

License: MIT License

Shell 0.06% JavaScript 4.19% TypeScript 95.75%

mtasa-api's Introduction

MTA:SA API

Read the Swagger Docs

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?

    • 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/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 equal the 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?

  • 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:
      1. npm install
      2. 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.

Special Thanks:

  • The MTA Team for maintaining this great game.
  • Tederis for the ase2json repository.

mtasa-api's People

Contributors

brenodanyel avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.