realmsplus-api 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 All Realms Are Safe
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,52 @@
1
+ # realmsplus-api
2
+
3
+ [![npm version](https://img.shields.io/npm/v/realmsplus-api.svg)](https://www.npmjs.com/package/realmsplus-api)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
5
+
6
+ Official SDK for the Realms+ API's public endpoints. This service maintains a database of harmful users in the Minecraft Bedrock Community.
7
+
8
+ ## Requirements
9
+
10
+ - Node.js 22.0.0 or higher
11
+ - A valid Realms+ API key
12
+
13
+ ## Get Started
14
+
15
+ To use this package, you need an API key.
16
+
17
+ 1. Join our [Discord server](https://discord.gg/KQtxZJVgnU)
18
+ 2. Open a ticket to contact support
19
+ 3. Request API access and provide your use case
20
+ 4. Once approved, you will receive your API key
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ npm install realmsplus-api
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ ```javascript
31
+ import { RealmsPlusAPI } from "realmsplus-api";
32
+
33
+ const client = new RealmsPlusAPI("your-api-key");
34
+
35
+ // Check service health
36
+ const health = await client.getHealth();
37
+ console.log(health);
38
+
39
+ // Query the hacker database
40
+ const result = await client.getHackerDB("all");
41
+ console.log(result);
42
+ ```
43
+
44
+ See more [examples](./examples)
45
+
46
+ ## Documentation
47
+
48
+ - [API Reference](./docs/API.md)
49
+
50
+ ## License
51
+
52
+ [MIT](./LICENSE)
package/index.d.ts ADDED
@@ -0,0 +1,50 @@
1
+ export interface ReportData {
2
+ username: string;
3
+ xuid?: string | null;
4
+ discordName?: string | null;
5
+ discordId?: string | null;
6
+ reason: string;
7
+ }
8
+
9
+ export interface APIResponse<T = unknown> {
10
+ ok: boolean;
11
+ data?: T;
12
+ error?: string;
13
+ }
14
+
15
+ export interface HealthResponse {
16
+ status: string;
17
+ services: {
18
+ database: string;
19
+ }
20
+ }
21
+
22
+ export type ReportCategory = 'discordDB' | 'hackerDB';
23
+
24
+ export class RealmsPlusAPI {
25
+ constructor(apiKey: string);
26
+
27
+ /**
28
+ * Gets the service health status
29
+ */
30
+ getHealth(): Promise<APIResponse<HealthResponse>>;
31
+
32
+ /**
33
+ * Searches the Discord database
34
+ * @param id - The unique ID to search for. Allowed types: `all`, `<discord-id>`, `<fingerprint-id>`
35
+ */
36
+ getDiscordDB(id: string): Promise<APIResponse>;
37
+
38
+ /**
39
+ * Searches the hacker database
40
+ * @param id - The unique ID to search for. Allowed types: `all`, `<xuid-id>`, `<discord-id>`, `<fingerprint-id>`
41
+ */
42
+ getHackerDB(id: string): Promise<APIResponse>;
43
+
44
+ /**
45
+ * Reports a user to the specified database
46
+ * @param category - The category of the report (`discordDB` or `hackerDB`)
47
+ * @param data - The report data. discordDB requires `discordId`, hackerDB requires `xuid`
48
+ */
49
+ reportUser(category: ReportCategory, data: ReportData): Promise<APIResponse>;
50
+ }
package/index.js ADDED
@@ -0,0 +1,2 @@
1
+ import { RealmsPlusAPI } from "./src/api.js";
2
+ export { RealmsPlusAPI };
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "realmsplus-api",
3
+ "version": "1.0.0",
4
+ "description": "Official SDK for the Realms+ API",
5
+ "main": "index.js",
6
+ "types": "index.d.ts",
7
+ "type": "module",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./index.d.ts",
11
+ "import": "./index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "index.js",
16
+ "index.d.ts",
17
+ "src/"
18
+ ],
19
+ "engines": {
20
+ "node": ">=22.0.0"
21
+ },
22
+ "scripts": {
23
+ "test": "echo \"Error: no test specified\" && exit 1"
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/All-Realms-Are-Safe/realmsplus-api.git"
28
+ },
29
+ "keywords": [
30
+ "realmsplus",
31
+ "realms",
32
+ "minecraft",
33
+ "bedrock",
34
+ "api",
35
+ "sdk"
36
+ ],
37
+ "author": "All Realms Are Safe",
38
+ "license": "MIT",
39
+ "bugs": {
40
+ "url": "https://github.com/All-Realms-Are-Safe/realmsplus-api/issues"
41
+ },
42
+ "homepage": "https://github.com/All-Realms-Are-Safe/realmsplus-api#readme"
43
+ }
package/src/api.js ADDED
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Represents the public routes of the Realms+ API
3
+ */
4
+ export class RealmsPlusAPI {
5
+ /**
6
+ *
7
+ * @param {string} apiKey - your private api key
8
+ */
9
+ constructor(apiKey) {
10
+ this.apiKey = apiKey;
11
+ this.baseUrl = "https://api.realmsplus.com/v1";
12
+ this.headers = {
13
+ "api-key": this.apiKey,
14
+ "Content-Type": "application/json"
15
+ };
16
+ };
17
+
18
+ async #request(method, url, body) {
19
+ try {
20
+ const data = {
21
+ method: method,
22
+ headers: this.headers
23
+ };
24
+
25
+ if (
26
+ method !== "GET" &&
27
+ method !== "DELETE" &&
28
+ body
29
+ ) {
30
+ data.body = JSON.stringify(body);
31
+ };
32
+
33
+ const res = await fetch(`${this.baseUrl}${url}`, data);
34
+ console.log(res.status);
35
+ const parsed = await res.json();
36
+ return parsed;
37
+ } catch (error) {
38
+ throw new Error(error);
39
+ };
40
+ };
41
+
42
+ /**
43
+ * Gets the service health
44
+ */
45
+ async getHealth() {
46
+ return await this.#request("GET", "/health");
47
+ };
48
+
49
+ /**
50
+ * Searches the discord database
51
+ * @param {string} id - the unique id to search for. Allowed types: `all`, `<discord-id>`, `<fingerprint-id>`
52
+ */
53
+ async getDiscordDB(id) {
54
+ return await this.#request("GET", `/database/discordDB/${id}`);
55
+ };
56
+
57
+ /**
58
+ * Searches the hacker database
59
+ * @param {string} id - the unique id to search for. Allowed types: `all`, `<xuid-id>`, `<discord-id>`, `<fingerprint-id>`
60
+ */
61
+ async getHackerDB(id) {
62
+ return await this.#request("GET", `/database/hackerDB/${id}`);
63
+ };
64
+
65
+ /**
66
+ *
67
+ * @param {string} category - the category of the report. Allowed types: `discordDB`, `hackerDB`
68
+ * @param {{
69
+ * username: string,
70
+ * xuid: string | null,
71
+ * discordName: string | null,
72
+ * discordId: string | null,
73
+ * reason: string
74
+ * }} data - the data for the report. discordDB must have the `discordId` field, hackerDB must have the `xuid` field
75
+ */
76
+ async reportUser(category, data) {
77
+ return await this.#request("POST", `/database/report/${category}`, data);
78
+ };
79
+ };