Skip to content

Code Examples

The following code serves as an example.
Please adapt and customize it to suit your requirements.

Example

import requests
import json

data = {
"servers": [
    "192.168.0.1:27015",
    "192.168.0.1:29015"
]
}
url = 'https://gamequery.dev/post/fetch'
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'
}
response = requests.post(url, json=data, headers=headers)
print(response.text)
const axios = require('axios');

const data = {
servers: [
    "192.168.0.1:27015",
    "192.168.0.1:29015"
]
};
const url = 'https://gamequery.dev/post/fetch';
const 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'
};
axios.post(url, data, { headers })
    .then(response => console.log(response.data))
    .catch(error => console.error('Error:', error));
import java.net.*;
import java.io.*;
import com.google.gson.Gson;

public class Main {
    public static void main(String[] args) throws Exception {
        URL url = new URL("https://gamequery.dev/post/fetch");
        HttpURLConnection con = (HttpURLConnection) url.openConnection();
        con.setRequestMethod("POST");
        con.setRequestProperty("Content-Type", "application/json");
        con.setRequestProperty("Cache-Control", "no-cache");
        con.setRequestProperty("Accept", "*/*");
        con.setRequestProperty("Accept-Encoding", "gzip,deflate");
        con.setRequestProperty("Connection", "keep-alive");
        con.setRequestProperty("x-api-token", "TOKEN");
        con.setRequestProperty("x-api-token-type", "FREE OR PRO");
        con.setRequestProperty("x-api-token-email", "YOUR ACCOUNT EMAIL");
        con.setRequestProperty("User-Agent", "Mozilla/5.0 (compatible; GApiPlugin/1.0; +https://gamequery.dev)");
        con.setRequestProperty("Authorization", "Bearer apitestoken");
        con.setDoOutput(true);

        String jsonInputString = new Gson().toJson(new Object() {
            String[] servers = { "192.168.0.1:27015", "192.168.0.1:29015" };
        });

        try (OutputStream os = con.getOutputStream()) {
            byte[] input = jsonInputString.getBytes("utf-8");
            os.write(input, 0, input.length);
        }

        try (BufferedReader br = new BufferedReader(
                new InputStreamReader(con.getInputStream(), "utf-8"))) {
            StringBuilder response = new StringBuilder();
            String responseLine = null;
            while ((responseLine = br.readLine()) != null) {
                response.append(responseLine.trim());
            }
            System.out.println(response.toString());
        }
    }
}
require 'net/http'
require 'json'

url = URI('https://gamequery.dev/post/fetch')
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request['Content-Type'] = 'application/json'
request['Cache-Control'] = 'no-cache'
request['Accept'] = '*/*'
request['Accept-Encoding'] = 'gzip,deflate'
request['Connection'] = 'keep-alive'
request['x-api-token'] = 'TOKEN'
request['x-api-token-type'] = 'FREE OR PRO'
request['x-api-token-email'] = 'YOUR ACCOUNT EMAIL'
request['User-Agent'] = 'Mozilla/5.0 (compatible; GApiPlugin/1.0; +https://gamequery.dev)'
request['Authorization'] = 'Bearer apitestoken'

data = { "servers" => ["192.168.0.1:27015", "192.168.0.1:29015"] }

request.body = data.to_json

response = http.request(request)
puts response.read_body
using System;
using System.Net.Http;
using System.Text.Json;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        var data = new
        {
            servers = new string[]
            {
                "192.168.0.1:27015",
                "192.168.0.1:29015"
            }
        };

        var httpClient = new HttpClient();
        var url = "https://gamequery.dev/post/fetch";
        var json = JsonSerializer.Serialize(data);
        var content = new StringContent(json, System.Text.Encoding.UTF8, "application/json");
        content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
        content.Headers.Add("Cache-Control", "no-cache");
        content.Headers.Add("Accept", "*/*");
        content.Headers.Add("Accept-Encoding", "gzip,deflate");
        content.Headers.Add("Connection", "keep-alive");
        content.Headers.Add("x-api-token", "TOKEN");
        content.Headers.Add("x-api-token-type", "FREE OR PRO");
        content.Headers.Add("x-api-token-email", "YOUR ACCOUNT EMAIL");
        content.Headers.Add("User-Agent", "Mozilla/5.0 (compatible; GApiPlugin/1.0; +https://gamequery.dev)");
        content.Headers.Add("Authorization", "Bearer apitestoken");

        var response = await httpClient.PostAsync(url, content);
        var responseContent = await response.Content.ReadAsStringAsync();
        Console.WriteLine(responseContent);
    }
}
#include <iostream>
#include <cpprest/http_client.h>
#include <cpprest/json.h>

using namespace web;
using namespace web::http;
using namespace web::http::client;

int main() {
    json::value data;
    data["servers"] = json::value::array({ json::value::string(U("192.168.0.1:27015")), json::value::string(U("192.168.0.1:29015")) });

    http_client client(U("https://gamequery.dev/post/fetch"));

    http_request request(methods::POST);
    request.headers().set_content_type(U("application/json"));
    request.headers().set_cache_control(U("no-cache"));
    request.headers().set_accept(U("*/*"));
    request.headers().set_accept_encoding(U("gzip,deflate"));
    request.headers().set_connection(U("keep-alive"));
    request.headers().add(U("x-api-token"), U("TOKEN"));
    request.headers().add(U("x-api-token-type"), U("FREE OR PRO"));
    request.headers().add(U("x-api-token-email"), U("YOUR ACCOUNT EMAIL"));
    request.headers().add(U("User-Agent"), U("Mozilla/5.0 (compatible; GApiPlugin/1.0; +https://gamequery.dev)"));
    request.headers().add(U("Authorization"), U("Bearer apitestoken"));

    request.set_body(data);

    client.request(request).then([](http_response response) {
        return response.extract_json();
    }).then([](json::value responseBody) {
        std::wcout << responseBody.serialize() << std::endl;
    }).wait();

    return 0;
}
<?php
$curl = curl_init();
$data = array(
"servers" => array(
    "192.168.0.1:27015",
    "192.168.0.1:29015"
)
);
$json_data = json_encode($data);
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://gamequery.dev/post/fetch',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => $json_data,
CURLOPT_HTTPHEADER => array(
    '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'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;

You can do anything; you can retrieve server information from any type of database and send those server details to our API.
Upon sending the data to the API endpoint, you will receive back comprehensive details about the servers you've specified.
This flexibility allows you to seamlessly integrate our API into your existing systems, enabling efficient retrieval of server information regardless of the database type or structure you utilize.

Note

Replace 192.168.0.1:XXXXX with the actual IP addresses and Ports of your servers.
Generate your API token at https://gamequery.dev/api/generate and replace TOKEN with it.