Skip to content

Madtrent/CrypticProxyAPI-Docs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 

Repository files navigation

CrypticProxyAPI Documentation v1.0.0-beta2

Overview

The CrypticProxyAPI is a RESTful API designed to manage and retrieve player data in a Minecraft server environment. It provides various endpoints for accessing and manipulating player data, as well as server information. Key features include player data management, server requests, rate limiting, and access key security.

Key Features

  • Player Data Management: Retrieve and update player data such as last logout time, the server from which the player logged out, and other player-specific information.
  • Server Requests: Access information about proxy servers, specific server players, and player data by UUID or username.
  • Rate Limiting: Prevent abuse or overuse of the API with a request limiter.
  • Access Key Checking: Ensure secure access by validating an access key in request headers.

Endpoints

Root Endpoint

GET <domain>/

  • Description: Returns a body message indicating if the server is running.
  • Response:
{
  "status": "CrypticProxyDataAPI is running!"
  "version": "<Api version> (String)"
}

Player Data Endpoint

GET <domain>/player/<player_name> GET <domain>/uuid/<player_uuid>

  • Description: Retrieves player data if available.
  • Parameters:
    • player/player_name (string): The player's username.
    • uuid/player_name (string): The player's uuid.
  • Responses:
    • If the player has a data file:
    {
      "DiscordId": "String",
      "DiscordLinked": boolean,
      "LastLogout": long,
      "Uuid": "String",
      "JoinedServers": {
        "Server1": {
          "LastLogout": long,
          "Amount": int
        },
        "Server2": {
          "LastLogout": long,
          "Amount": int
        }
      },
      "Server": "String/null",
      "Username": "madtrent",
      "PastUsernames": [
        "Name 1"
      ],
      "Connected": boolean,
      "LastLogoutServer": "String",
      "JoinedBefore": boolean,
      "FavoriteServer": "String"
    }
    • If the player doesn't have a data file:
    {
      "Uuid": "String",
      "Username": "String",
      "JoinedBefore": boolean,
    }

Proxy Servers Endpoint

GET <domain>/proxy

  • Description: Retrieves the status of all proxy servers.
  • Response:
{
  "server1": {
    "playerCount": int,
    "online": boolean
  },
  "server2": {
    "playerCount": int,
    "online": boolean
  }
}

Specific Proxy Server Endpoint

GET <domain>/proxy/<server>

  • Description: Retrieves the list of players and the server name for a specific proxy server.
  • Parameters:
    • server (string): The name of the proxy server.
  • Response:
{
  "players": ["player1", "player2"],
  "serverName": "String"
}

Specific Player Data in Proxy Server Endpoint (Removed)

GET <domain>/proxy/<server>/<uuidofplayer>

  • Description: Retrieves specific player data from a given proxy server.
  • Parameters:
    • server (string): The name of the proxy server.
    • uuidofplayer (string): The UUID of the player.
  • Response:
{
  "Uuid": "String",
  "Username": "String",
  "ServerName": "String",
  "JoinAmount": int,
  "LastSeen": long
}

Discord link Endpoints

GET <domain>/discordlink/uuid/<uuidofplayer>

GET <domain>/discordlink/linkcode/<playersLinkCode>

POST <domain>/discordlink/uuid/<uuidofplayer>

  • Description: Retrieves the player's discord info
  • Requirements: Discord Access Key
  • Parameters:
    • uuidofplayer (string): The UUID of the player.
    • playersLinkCode (string): The link code of the player
  • Response:
{
  "discord_linked": "Boolean",
  "discord_link_code": "String",
  "discord_id": "String",
}

GET <domain>/discordlink/linkcodes

  • Description: Retrieves all link codes.
  • Requirements: Discord Access Key
  • Response:
[
  {
    "discordLinkCode": "String",
    "uuid": "String"
  },
  {
    "discordLinkCode": "String",
    "uuid": "String"
  }
]

Errors

Error Responses

  • General Error:
{
  "error": "description"
}

Errors are returned with an appropriate HTTP status code and a description of the error encountered.

Common Errors

  • 400 Bad Request: The server could not understand the request due to invalid syntax or missing required parameters.
  • 404 Not Found: The requested resource could not be found.
  • 401 Unauthorized: Access key is missing or invalid.
  • 500 Internal Server Error: An unexpected error occurred on the server.

Configuration

Configuration options for the CrypticProxyAPI are specified in the config file:

port: <port you want the server to run on>
domain: <The domain you want the server to run on>
limit: <The rate limiter>
FloodgatePrefix: <If your using floodGate your bedrock player prefix>
AccessKey:
  enabled: <If you want it to require an access key>
  key: <The required access key if enabled>
DiscordAccessKey:
  key: <The required access key for the discord enpoint>

Commands Overview

Console Commands

capi

  • Description: Opens a help page with a list of available commands.
  • Usage: capi

capi reload

  • Description: Reloads the configuration file.
  • Usage: capi reload

capi keygen

  • Description: Generates a new access key for the API.
  • Usage: capi keygen

capi discordkeygen

  • Description: Generates a new discord access key for the API.
  • Usage: capi discordkeygen

capi version

  • Description: Checks the version of the plugin and if there are any updates.
  • Usage: capi version

Player Commands

lastseen <player>

  • Description: Checks when a specified player was last seen on the proxy and which server they were on.
  • Permission: CrypticProxyAPI.lastseen.use
  • Usage: /lastseen <player>

discordlink

  • Aliases: dlink
  • Description: generates a discord link code
  • Permission: CrypticProxyAPI.discordlink
  • Usage: /discordlink

Header Usage / Access key

General Access Key

  • Header = Access-Key
  • Value = Config Value

Discord Access key

  • Header = Discord-Access-Key
  • Value = Config Value

Example Usage in Different Languages

Java

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import org.json.JSONObject;

public class Main {
    private static final String ACCESS_KEY = "2910294e-eee7-490e-9264-eb07fbd78519";
    private static final String BASE_URL = "http://localhost:7000/";
    private static final HttpClient CLIENT = HttpClient.newHttpClient();

    public static void main(String[] args) {
        sendRequest("", "status");
    }

    public static void sendRequest(String value, String json) {

        try {
            HttpRequest request = HttpRequest.newBuilder()
                    .uri(new URI(BASE_URL + value))
                    .header("Access-Key", ACCESS_KEY)
                    .GET()
                    .build();

            HttpResponse<String> response = CLIENT.send(request, HttpResponse.BodyHandlers.ofString());

            JSONObject jsonObject = new JSONObject(response.body());

            System.out.println(jsonObject.get(json));

        } catch (URISyntaxException | IOException | InterruptedException e) {
            e.printStackTrace();
        }
    }
}

Python

import requests
import json

ACCESS_KEY = '2910294e-eee7-490e-9264-eb07fbd78519'
BASE_URL = "http://localhost:7000/";

def send_request(value, json_key):
    headers = {'Access-Key': ACCESS_KEY}
    response = requests.get(BASE_URL + value, headers=headers)

    if response.status_code == 200:
        json_object = json.loads(response.text)
        print(json_object.get(json_key))
    else:
        print(f'Request failed with status code {response.status_code}')

def main():
    send_request('', 'status')

if __name__ == '__main__':
    main()

JavaScript (Node.js)

const axios = require('axios');

const ACCESS_KEY = "2910294e-eee7-490e-9264-eb07fbd78519";
const BASE_URL = "http://localhost:7000/";

async function sendRequest(value, jsonKey) {
    try {
        const response = await axios.get(`${BASE_URL}/${value}`, {
            headers: {
                'Access-Key': ACCESS_KEY
            }
        });

        console.log(response.data[jsonKey]);
    } catch (error) {
        console.error(`Request failed with status code ${error.response.status}`);
    }
}

sendRequest('', 'status');

How to Install/Setup

https://github.com/Madtrent/CrypticProxyAPI-Docs/blob/main/Install.md

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published