Skip to content

Details

Post

This endpoint enables the sending of a POST request.
It serves the purpose of adding information about servers to the API database.

Endpoint

/post/add
The endpoint serves as an API function designed to handle POST requests for adding server details to the database. Upon sending a POST request, the server processes the provided information and adds it to the database.


Data

The format of the body needs to be set as JSON 'Content-Type': 'application/json' only this is accepted

{
  "servers": [
    # VALID EXAMPLE for Minecraft
    {
      "game_id": "minecraft",
      "servers": [
        "192.168.0.1:25568",
        "192.168.0.1:25569"
      ]
    },
    # VALID EXAMPLE for Counter-Strike 1.6
    {
      "game_id": "counterstrike16",
      "servers": [
        "192.168.0.1:27015",
        "192.168.0.1:27016"
      ]
    },
    # INVALID EXAMPLE
    {
      "game_id": "counterstrike167",
      "servers": [
        "192.168.0.1:88015",
        "192.168.0.1:88016"
      ]
    }
  ]
}
This block initializes a data structure containing the necessary data to be sent in the request. The servers field contains a list of server's addresses with their corresponding ports to be added to the database.

Url

https://gamequery.dev/post/add
This line assigns a string representing the URL of the API endpoint where the request will be sent. It specifies the location where the POST request containing the server data will be directed for processing.


Headers

Remember x-api-token, x-api-token-type, x-api-token-email are generated on the panel

headers = {
  'Content-Type': 'application/json',
  'Cache-Control': 'no-cache',
  'Accept': '*/*',
  'Accept-Encoding': 'gzip,deflate',
  'Connection': 'keep-alive',
  'x-api-token': 'TOKEN',
  'x-api-token-type': 'FREE OR PRO',
  'x-api-token-email': 'YOUR ACCOUNT EMAIL',
  'User-Agent': 'Mozilla/5.0 (compatible; GApiPlugin/1.0; +https://gamequery.dev)',
  'Authorization': 'Bearer apitestoken'
}
This block initializes a data structure, typically a dictionary or object, containing HTTP headers.
These headers provide additional information about the request, such as the content type, cache control, and authentication tokens.
They play a crucial role in communicating various aspects of the request to the server, ensuring proper processing and handling of the data being sent.


Response

response = requests.post(url, json=data, headers=headers)
This line sends a POST request to the specified URL with the provided data and headers.
It utilizes the requests.post() function to initiate the request, passing the URL, JSON (data), and headers (headers) as parameters.
Upon execution, this line captures the response returned by the server, which typically includes status information (e.g., success or failure) and possibly additional data relevant to the request.


Example

Example

{
  "servers": [
    # VALID EXAMPLE for Minecraft Single Server
    {
      "game_id": "minecraft",
      "servers": [
        "192.168.0.1:25568"
      ]
    },
    # VALID EXAMPLE for Counter-Strike 1.6 Multiple servers
    {
      "game_id": "counterstrike16",
      "servers": [
        "192.168.0.1:27015",
        "192.168.0.1:27016"
      ]
    },
    # INVALID EXAMPLE Wrong Game ID
    {
      "game_id": "counterstrike167",
      "servers": [
        "192.168.0.1:88015",
        "192.168.0.1:88016"
      ]
    }
  ]
}
{
  "success": true,
  "message": "Servers added successfully",
  "invalid_servers": [
    {
      "game_id": "counterstrike167",
      "servers": [
        "192.168.0.1:88015",
        "192.168.0.1:88016"
      ]
    }
  ],
  "already_existing": [],
  "inserted_servers": [
    {
      "server": "192.168.0.1:25568",
      "game_id": "minecraft"
    }
    {
      "server": "192.168.0.1:27015",
      "game_id": "counterstrike16"
    },
    {
      "server": "192.168.0.1:27016",
      "game_id": "counterstrike16"
    }
  ]
}

As you can see the response will also include some details like invalid_servers, already_existing, inserted_servers

Note

You can see the examples on Code Examples page,
Keep in mind those are just examples you need to generate your own key on https://gamequery.dev/api/generate