API Usage

From Crafters Wiki
Revision as of 03:30, 9 June 2024 by Plexiate (talk | contribs)
Jump to navigation Jump to search

CraftersAPI Documentation

Introduction

Welcome to the CraftersAPI documentation. This API allows players to access various statistics from the Crafters.one server . To use the API, you need to obtain an API key, which is given on request via tickets, and make requests to the endpoints provided.

Obtaining an API Key

To interact with the CraftersAPI, you must have an API key. Open a ticket to request permission to use the API. Once permission is obtained; follow these steps to get your API key:

1. In-Game Command: Use the command /craftersapi new <NameOfAPIKey> in-game to generate a new API key.

2. Viewing Keys: Use the command /craftersapi keys to view your active API keys.

3. Cancelling a Key: Use the command /craftersapi cancel <NameOfAPIKey> to cancel an existing API key.

You will be able to view all keys generated by your account, cancelled or active, via the /craftersapi keys command.

Making Requests

Base URL

All API requests are made to the following base URL:

https://crafters.one/api/v1

Authentication

All requests to the API must include a valid API key. The API key should be included as a query parameter.

Rate Limiting

The API is rate-limited to 600 requests per 10 minutes per IP address.

Endpoints

Get Player Stats

Endpoint

GET /stats/players

Parameters

  • apikey (required): Your API key.
  • player (required): The UUID of the player whose stats you want to retrieve.

Example Request

GET https://crafters.one/api/v1/stats/players?apikey=YOUR_API_KEY&player=PLAYER_UUID

Response

A successful request returns a JSON object containing the player's statistics. Example response:

   "animals_bred": 172,
   "cake_slices_eaten": 52,
   "damage_absorbed": 649,
   "damage_dealt": 1296101,
   "damage_dealt_absorbed": 1061,
   "damage_dealt_resisted": 0,
   "damage_resisted": 17131,
   "damage_taken": 241982,
   "deaths": 44,
   "fish_caught": 715,
   "is_online": false,
   "join_date": 1611876703869,
   "jumps": 514088,
   "last_seen": 1717894499615,
   "mob_kills": 83480,
   "netherite_hoes_crafted": 1,
   "play_time": 9566304,
   "player_kills": 291,
   "score": 100,
   "time_since_death": 8611,
   "time_since_rest": 8631,
   "username": "Plexiate",
   "uuid": "34e9f59b-854d-4889-9b06-a862933c3c94"

Additional Information

  • animals_bred: The number of animals bred by the player.
  • cake_slices_eaten: The number of cake slices eaten by the player.
  • damage_absorbed: The total damage absorbed by the player.
  • damage_dealt: The total damage dealt by the player.
  • damage_dealt_absorbed: The total damage dealt by the player that was absorbed.
  • damage_dealt_resisted: The total damage dealt by the player that was resisted.
  • damage_resisted: The total damage resisted by the player.
  • damage_taken: The total damage taken by the player.
  • deaths: The number of times the player has died.
  • fish_caught: The number of fish caught by the player.
  • is_online: A boolean indicating if the player is currently online.
  • join_date: The timestamp of when the player first joined the server.
  • jumps: The number of jumps made by the player.
  • last_seen: The timestamp of when the player was last seen online.
  • mob_kills: The number of mobs killed by the player.
  • netherite_hoes_crafted: The number of netherite hoes crafted by the player.
  • play_time: The total playtime in seconds.
  • player_kills: The number of other players the player has killed.
  • score: The player's current score.
  • time_since_death: The time in seconds since the player last died.
  • time_since_rest: The time in seconds since the player last rested.
  • username: The player's username.
  • uuid: The player's unique identifier.

Get World Stats

Endpoint

GET /stats/world

Parameters

  • apikey (required): Your API key.

Example Request

GET https://crafters.one/api/v1/stats/world?apikey=YOUR_API_KEY

Response

A successful request returns a JSON object containing the player's statistics. Example response:

   "day_count_end": 84978,
   "day_count_nether": 84977,
   "day_count_overworld": 16,
   "online_players": [
       "Plexiate"
   ],
   "time_of_day": "day",
   "total_players": 865,
   "weather_overworld": "clear"

Additional Information

  • day_count_end: The number of days that have passed in the End dimension.
  • day_count_nether: The number of days that have passed in the Nether dimension.
  • day_count_overworld: The number of days that have passed in the Overworld dimension.
  • online_players: A list of players currently online.
  • time_of_day: The current time of day in the game (e.g., "night").
  • total_players: The total number of players who have joined the server.
  • weather_overworld: The current weather in the Overworld (e.g., "clear").

Get Top Players

Endpoint

GET /stats/top_players

Parameters

  • apikey (required): Your API key.

Example Request

GET https://crafters.one/api/v1/stats/top_players?apikey=YOUR_API_KEY&stat=STAT_HERE&limit=10

Response

A successful request returns a JSON object containing the player's statistics. Example response:

   "statistic": "CAKE_SLICES_EATEN",
   "top_players": [
       {
           "username": "ShimmyMySherbet",
           "uuid": "892725c0-8f95-4561-bdf2-2d0ba15a4539",
           "value": 373
       },
       {
           "username": "legowarrior779",
           "uuid": "3da89c7a-fe24-49e6-aacc-728e38fbcdaa",
           "value": 266
       },
       {
           "username": "MommyTayy",
           "uuid": "fac7a21c-caed-4434-8733-e8ea1fe4d729",
           "value": 234
       },
       {
           "username": "MerelyMiserable",
           "uuid": "3411710b-9cfc-4360-aa9a-db9137ea9a37",
           "value": 228
       },
       {
           "username": "Cameron_TNT",
           "uuid": "9c2427cf-9cb1-405c-9a85-8f468e687ff5",
           "value": 168
       }
   ]


Additional Information

  • limit=10: The number of top players requested to return in the list. This can be left off to only retrieve the number one player.


Using Postman to Return Stats with the CraftersAPI

Step-by-Step Guide

1. Install Postman: If you haven’t already, download and install Postman from [Postman’s official website](https://www.postman.com/downloads/).

2. Open Postman Launch the application.

3. Create a New Request:

  - Click on the “New” button in the top left corner of the Postman interface.
  - Select “HTTP” from the menu.

4. Set Up the Request:

  - In the new request window, select “GET” from the dropdown menu next to the URL field.
  - Enter the URL for the API endpoint you want to test. For example, to get player stats, enter:
    https://crafters.one/api/v1/stats/players

5. Query Parameters:

  - Click on the “Params” tab below the URL field.
  - Add the required query parameters:
    - apikey: Your API key.
    - player: The UUID of the player whose stats you want to retrieve.

6. Send the Request:

  - Click on the “Send” button to send the request to the API.

7. View the Response:

  - The response from the API will be displayed in the lower part of the Postman window. If the request is successful, you will see a JSON object containing the player’s statistics.


This documentation should help you get started with using the CraftersAPI. If you have any questions or encounter any issues please contact [email protected] or open a ticket for assistance.