API Usage: Difference between revisions

From Crafters Wiki
Jump to navigation Jump to search
(Created page with "= 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 obtain...")
 
 
(16 intermediate revisions by one other user not shown)
Line 1: Line 1:
= CraftersAPI Documentation =
= 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.
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.
Line 11: Line 9:
1. '''In-Game Command''': Use the command <code>/craftersapi new <NameOfAPIKey></code> in-game to generate a new API key.
1. '''In-Game Command''': Use the command <code>/craftersapi new <NameOfAPIKey></code> in-game to generate a new API key.


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


3. '''Cancelling a Key''': Use the command <code>/craftersapi cancel <NameOfAPIKey></code> to cancel an existing API key.
3. '''Cancelling a Key''': Use the command <code>/craftersapi cancel <NameOfAPIKey></code> to cancel an existing API key.
You will be able to view all keys generated by your account, cancelled or active, via the <code>/craftersapi keys</code> command.


== Making Requests ==
== Making Requests ==
Line 27: Line 23:
=== Authentication ===
=== Authentication ===


All requests to the API must include a valid API key. The API key should be included as a query parameter.
All requests to the API must include a valid API key. The API key should be included in the request headers with the key x-api-key.


=== Rate Limiting ===
=== Rate Limiting ===


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


== Endpoints ==
== Endpoints ==


=== Get Player Stats ===
== Get Player Stats ==


==== Endpoint ====
==== Endpoint ====


<code>GET /stats</code>
<code>GET /stats/players</code>
 
==== Headers ====
 
* <code>x-api-key</code> (required): Your API key.


==== Parameters ====
==== Parameters ====


* <code>apikey</code> (required): Your API key.
* <code>player</code> (required): The UUID of the player whose stats you want to retrieve.
* <code>player</code> (required): The UUID of the player whose stats you want to retrieve.


==== Example Request ====
==== Example Request ====


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


==== Response ====
==== Response ====
Line 54: Line 53:
A successful request returns a JSON object containing the player's statistics. Example response:
A successful request returns a JSON object containing the player's statistics. Example response:


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


=== Error Responses ===
==== Additional Information ====
 
If there is an error with your request, you will receive a JSON response with an <code>error</code> field. Example error response:
 
    "error": "Invalid API key"
 
=== Additional Information ===


* '''animals_bred''': The number of animals bred by the player.
* '''animals_bred''': The number of animals bred by the player.
Line 91: Line 89:
* '''deaths''': The number of times the player has died.
* '''deaths''': The number of times the player has died.
* '''fish_caught''': The number of fish caught by the player.
* '''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.
* '''join_date''': The timestamp of when the player first joined the server.
* '''jumps''': The number of jumps made by the player.
* '''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.
* '''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.
* '''play_time''': The total playtime in seconds.
* '''player_kills''': The number of other players the player has killed.
* '''player_kills''': The number of other players the player has killed.
Line 99: Line 100:
* '''time_since_death''': The time in seconds since the player last died.
* '''time_since_death''': The time in seconds since the player last died.
* '''time_since_rest''': The time in seconds since the player last rested.
* '''time_since_rest''': The time in seconds since the player last rested.
* '''username''': The player's username.
* '''uuid''': The player's unique identifier.
For a statistic such as '''join_date''' and '''last_seen''' you can use a tool such as [https://www.epochconverter.com/ Unix Time Converter] to get a date and time out of it.
== Get World Stats ==
==== Endpoint ====
<code>GET /stats/world</code>
==== Headers ====
* <code>x-api-key</code> (required): Your API key.
==== Example Request ====
<code>GET https://crafters.one/api/v1/stats/world</code>
==== 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 ====
<code>GET /stats/top_players</code>
==== Headers ====
* <code>x-api-key</code> (required): Your API key.
==== Parameters ====
* <code>stat</code> (required): The [https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Statistic.html#enum-constant-summary bukkit statistic] you want to retrieve.
* <code>type</code> (optional): The Block, Item, or Entity when using DROP, PICKUP, MINE_BLOCK, USE_ITEM, BREAK_ITEM, CRAFT_ITEM, KILL_ENTITY, ENTITY_KILLED_BY, or TARGET_HIT.
* <code>limit</code> (optional): The number of top players requested to return in the list. This can be left off to only retrieve the number one player.
==== Example Request ====
<code>GET https://crafters.one/api/v1/stats/top_players?stat=STAT_HERE&type=TYPE_HERE&limit=10</code>
==== 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
        }
    ]
== Using Postman with CraftersAPI ==
=== Step-by-Step Guide ===
1. '''Install Postman''': If you haven’t already, download and install Postman from [https://www.postman.com/downloads/ Postman’s official website].
2. '''Open Postman'''
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. '''Headers''':
  - Click on the “Headers” tab below the URL field.
  - Add the required query parameters:
    - '''x-api-key''': Your API key.
6. '''Query Parameters''':
  - Click on the “Params” tab below the URL field.
  - Add the required query parameters:
    - '''player''': The UUID of the player whose stats you want to retrieve.
7. '''Send the Request'''
8. '''View the Response'''


== Conclusion ==


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.
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.
__NOTOC__

Latest revision as of 02:08, 18 June 2024

CraftersAPI Documentation

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 API keys.

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

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 in the request headers with the key x-api-key.

Rate Limiting

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

Endpoints

Get Player Stats

Endpoint

GET /stats/players

Headers

  • x-api-key (required): Your API key.

Parameters

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

Example Request

GET https://crafters.one/api/v1/stats/players?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.

For a statistic such as join_date and last_seen you can use a tool such as Unix Time Converter to get a date and time out of it.

Get World Stats

Endpoint

GET /stats/world

Headers

  • x-api-key (required): Your API key.

Example Request

GET https://crafters.one/api/v1/stats/world

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

Headers

  • x-api-key (required): Your API key.

Parameters

  • stat (required): The bukkit statistic you want to retrieve.
  • type (optional): The Block, Item, or Entity when using DROP, PICKUP, MINE_BLOCK, USE_ITEM, BREAK_ITEM, CRAFT_ITEM, KILL_ENTITY, ENTITY_KILLED_BY, or TARGET_HIT.
  • limit (optional): The number of top players requested to return in the list. This can be left off to only retrieve the number one player.

Example Request

GET https://crafters.one/api/v1/stats/top_players?stat=STAT_HERE&type=TYPE_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
       }
   ]

Using Postman with CraftersAPI

Step-by-Step Guide

1. Install Postman: If you haven’t already, download and install Postman from Postman’s official website.

2. Open Postman

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. Headers:

  - Click on the “Headers” tab below the URL field.
  - Add the required query parameters:
    - x-api-key: Your API key.

6. Query Parameters:

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

7. Send the Request

8. View the Response


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.