API Usage: Difference between revisions

From Crafters Wiki
Jump to navigation Jump to search
No edit summary
Line 23: 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 600 requests per 10 minutes per IP address.
The API is rate-limited to 600 requests per 10 minutes per API Key.


== Endpoints ==
== Endpoints ==
Line 36: Line 36:


<code>GET /stats/players</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/players?apikey=YOUR_API_KEY&player=PLAYER_UUID</code>
<code>GET https://crafters.one/api/v1/stats/players&player=PLAYER_UUID</code>


==== Response ====
==== Response ====
Line 108: Line 111:
<code>GET /stats/world</code>
<code>GET /stats/world</code>


==== Parameters ====
==== Headers ====


* <code>apikey</code> (required): Your API key.
* <code>x-api-key</code> (required): Your API key.


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


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


==== Response ====
==== Response ====
Line 146: Line 149:
<code>GET /stats/top_players</code>
<code>GET /stats/top_players</code>


==== Parameters ====
==== Headers ====


* <code>apikey</code> (required): Your API key.
* <code>x-api-key</code> (required): Your API key.


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


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


==== Response ====
==== Response ====
Line 210: Line 213:
     https://crafters.one/api/v1/stats/players
     https://crafters.one/api/v1/stats/players


5. '''Query Parameters''':
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.
   - Click on the “Params” tab below the URL field.
   - Add the required query parameters:
   - Add the required query parameters:
    - '''apikey''': Your API key.
     - '''player''': The UUID of the player whose stats you want to retrieve.
     - '''player''': The UUID of the player whose stats you want to retrieve.


6. '''Send the Request'''
7. '''Send the Request'''


7. '''View the Response'''
8. '''View the Response'''





Revision as of 05:16, 10 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.

Example Request

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