├── .gitattributes ├── .github └── dependabot.yml ├── .gitignore ├── LICENSE ├── README.md ├── package-lock.json ├── package.json └── src ├── API ├── getAuctionByID.js ├── getAuctionPriceHistory.js ├── getAuctionsByPlayer.js ├── getAuctionsByProfile.js ├── getBazaarHistory.js ├── getCountsHistory.js ├── getCurrentAuctionPrice.js ├── getDaily.js ├── getDailySkyblock.js ├── getDistribution.js ├── getGuild.js ├── getGuildLeaderboard.js ├── getGuildMember.js ├── getGuildPositions.js ├── getHistoricalAll.js ├── getHistoricalAllSkyblock.js ├── getHistoricalDate.js ├── getHistoricalDateSkyblock.js ├── getItemHistory.js ├── getKeyInfo.js ├── getLeaderboard.js ├── getMonthly.js ├── getMonthlySkyblock.js ├── getPositions.js ├── getSkyblockLeaderboard.js ├── getSkyblockPositions.js ├── getStatHistory.js ├── getStats.js ├── getStatus.js ├── getWeekly.js ├── getWeeklySkyblock.js ├── getYearly.js ├── index.js ├── register.js ├── registerGuild.js └── registerSkyblock.js ├── client.js ├── errors.js ├── updater.js └── utils.js /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # To get started with Dependabot version updates, you'll need to specify which 2 | # package ecosystems to update and where the package manifests are located. 3 | # Please see the documentation for all configuration options: 4 | # https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates 5 | 6 | version: 2 7 | updates: 8 | - package-ecosystem: "npm" # See documentation for possible values 9 | directory: "/" # Location of package manifests 10 | schedule: 11 | interval: "daily" 12 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Pixelic 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. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DEPRECATED 2 | 3 | ### Links 4 | 5 | [Discord Support](https://discord.gg/ZpuscgCayg) | [NPM](https://www.npmjs.com/package/pixelic-api-wrapper) | [GitHub](https://github.com/Pixelicc/Pixelic-API-Wrapper) 6 | 7 | ### Install 8 | 9 | ```shell 10 | npm i pixelic-api-wrapper 11 | ``` 12 | 13 | ```js 14 | const PixelicAPI = require("pixelic-api-wrapper"); 15 | ``` 16 | 17 | ### Quick Start 18 | 19 | To be able to use the Pixelic-API via the Pixelic-API-Wrapper you still need to generate an API-Key. 20 | Instructions on how to generate an API-Key can be found here : https://docs.pixelic.de 21 | 22 | #### Step 1 of 2 23 | 24 | ```js 25 | const pixelicAPI = new PixelicAPI("HERE-YOUR-KEY-GOES"); 26 | ``` 27 | 28 | #### Step 2 of 2 29 | 30 | #### ➤ Using promises? 31 | 32 | ```js 33 | pixelicAPI 34 | .getDaily("Pixelic") 35 | .then((dailyData) => { 36 | /* process data */ 37 | }) 38 | .catch((error) => { 39 | /* handle error */ 40 | }); 41 | ``` 42 | 43 | #### ➤ Using async/await? 44 | 45 | ```js 46 | try { 47 | const dailyData = await pixelicAPI.getDaily("Pixelic"); 48 | /* process data */ 49 | } catch (error) { 50 | /* handle error */ 51 | } 52 | ``` 53 | 54 | ### Docs 55 | 56 | #### Constructor 57 | 58 | ```js 59 | const pixelicAPI = new PixelicAPI("API-KEY", { 60 | /* options */ 61 | }); 62 | ``` 63 | 64 | Basic options: 65 | 66 | | Option | Default | Description | 67 | | :------------------: | ------- | -------------------------------------------------------------- | 68 | | ratelimit | 60 | Set how many "normal" Requests you want to send per Minute. | 69 | | leaderboardRatelimit | 10 | Set how many Leaderboard Requests you want to send per Minute. | 70 | | registerRatelimit | 5 | Set how many Register Requests you want to send per 5-Minutes. | 71 | | checkForUpdates | true | Set whether to check for Updates on start. | 72 | | redis.host | null | Redis-Host (Used for Clustered-Ratelimiting) | 73 | | redis.port | null | Redis-Port (Used for Clustered-Ratelimiting) | 74 | | redis.username | null | Redis-Username (Used for Clustered-Ratelimting) | 75 | | redis.password | null | Redis-Password (Used for Clustered-Ratelimiting) | 76 | 77 | #### Clustered-Ratelimiting with Redis 78 | 79 | ```js 80 | const pixelicAPI = new PixelicAPI("API-KEY", { 81 | redis: { 82 | host: "10.0.0.10", 83 | port: 6379, 84 | username: "default", 85 | password: "", 86 | }, 87 | }); 88 | ``` 89 | -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pixelic-api-wrapper", 3 | "version": "1.0.17", 4 | "lockfileVersion": 2, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "pixelic-api-wrapper", 9 | "version": "1.0.17", 10 | "license": "MIT", 11 | "dependencies": { 12 | "bottleneck": "^2.19.5", 13 | "ioredis": "^5.3.1", 14 | "node-fetch": "^3.3.1" 15 | } 16 | }, 17 | "node_modules/@ioredis/commands": { 18 | "version": "1.2.0", 19 | "resolved": "https://registry.npmjs.org/@ioredis/commands/-/commands-1.2.0.tgz", 20 | "integrity": "sha512-Sx1pU8EM64o2BrqNpEO1CNLtKQwyhuXuqyfH7oGKCk+1a33d2r5saW8zNwm3j6BTExtjrv2BxTgzzkMwts6vGg==" 21 | }, 22 | "node_modules/bottleneck": { 23 | "version": "2.19.5", 24 | "resolved": "https://registry.npmjs.org/bottleneck/-/bottleneck-2.19.5.tgz", 25 | "integrity": "sha512-VHiNCbI1lKdl44tGrhNfU3lup0Tj/ZBMJB5/2ZbNXRCPuRCO7ed2mgcK4r17y+KB2EfuYuRaVlwNbAeaWGSpbw==" 26 | }, 27 | "node_modules/cluster-key-slot": { 28 | "version": "1.1.2", 29 | "resolved": "https://registry.npmjs.org/cluster-key-slot/-/cluster-key-slot-1.1.2.tgz", 30 | "integrity": "sha512-RMr0FhtfXemyinomL4hrWcYJxmX6deFdCxpJzhDttxgO1+bcCnkk+9drydLVDmAMG7NE6aN/fl4F7ucU/90gAA==", 31 | "engines": { 32 | "node": ">=0.10.0" 33 | } 34 | }, 35 | "node_modules/data-uri-to-buffer": { 36 | "version": "4.0.1", 37 | "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", 38 | "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==", 39 | "engines": { 40 | "node": ">= 12" 41 | } 42 | }, 43 | "node_modules/debug": { 44 | "version": "4.3.4", 45 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", 46 | "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", 47 | "dependencies": { 48 | "ms": "2.1.2" 49 | }, 50 | "engines": { 51 | "node": ">=6.0" 52 | }, 53 | "peerDependenciesMeta": { 54 | "supports-color": { 55 | "optional": true 56 | } 57 | } 58 | }, 59 | "node_modules/denque": { 60 | "version": "2.1.0", 61 | "resolved": "https://registry.npmjs.org/denque/-/denque-2.1.0.tgz", 62 | "integrity": "sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw==", 63 | "engines": { 64 | "node": ">=0.10" 65 | } 66 | }, 67 | "node_modules/fetch-blob": { 68 | "version": "3.2.0", 69 | "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", 70 | "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", 71 | "funding": [ 72 | { 73 | "type": "github", 74 | "url": "https://github.com/sponsors/jimmywarting" 75 | }, 76 | { 77 | "type": "paypal", 78 | "url": "https://paypal.me/jimmywarting" 79 | } 80 | ], 81 | "dependencies": { 82 | "node-domexception": "^1.0.0", 83 | "web-streams-polyfill": "^3.0.3" 84 | }, 85 | "engines": { 86 | "node": "^12.20 || >= 14.13" 87 | } 88 | }, 89 | "node_modules/formdata-polyfill": { 90 | "version": "4.0.10", 91 | "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", 92 | "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", 93 | "dependencies": { 94 | "fetch-blob": "^3.1.2" 95 | }, 96 | "engines": { 97 | "node": ">=12.20.0" 98 | } 99 | }, 100 | "node_modules/ioredis": { 101 | "version": "5.3.2", 102 | "resolved": "https://registry.npmjs.org/ioredis/-/ioredis-5.3.2.tgz", 103 | "integrity": "sha512-1DKMMzlIHM02eBBVOFQ1+AolGjs6+xEcM4PDL7NqOS6szq7H9jSaEkIUH6/a5Hl241LzW6JLSiAbNvTQjUupUA==", 104 | "dependencies": { 105 | "@ioredis/commands": "^1.1.1", 106 | "cluster-key-slot": "^1.1.0", 107 | "debug": "^4.3.4", 108 | "denque": "^2.1.0", 109 | "lodash.defaults": "^4.2.0", 110 | "lodash.isarguments": "^3.1.0", 111 | "redis-errors": "^1.2.0", 112 | "redis-parser": "^3.0.0", 113 | "standard-as-callback": "^2.1.0" 114 | }, 115 | "engines": { 116 | "node": ">=12.22.0" 117 | }, 118 | "funding": { 119 | "type": "opencollective", 120 | "url": "https://opencollective.com/ioredis" 121 | } 122 | }, 123 | "node_modules/lodash.defaults": { 124 | "version": "4.2.0", 125 | "resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-4.2.0.tgz", 126 | "integrity": "sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ==" 127 | }, 128 | "node_modules/lodash.isarguments": { 129 | "version": "3.1.0", 130 | "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", 131 | "integrity": "sha512-chi4NHZlZqZD18a0imDHnZPrDeBbTtVN7GXMwuGdRH9qotxAjYs3aVLKc7zNOG9eddR5Ksd8rvFEBc9SsggPpg==" 132 | }, 133 | "node_modules/ms": { 134 | "version": "2.1.2", 135 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", 136 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" 137 | }, 138 | "node_modules/node-domexception": { 139 | "version": "1.0.0", 140 | "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", 141 | "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", 142 | "funding": [ 143 | { 144 | "type": "github", 145 | "url": "https://github.com/sponsors/jimmywarting" 146 | }, 147 | { 148 | "type": "github", 149 | "url": "https://paypal.me/jimmywarting" 150 | } 151 | ], 152 | "engines": { 153 | "node": ">=10.5.0" 154 | } 155 | }, 156 | "node_modules/node-fetch": { 157 | "version": "3.3.2", 158 | "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", 159 | "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", 160 | "dependencies": { 161 | "data-uri-to-buffer": "^4.0.0", 162 | "fetch-blob": "^3.1.4", 163 | "formdata-polyfill": "^4.0.10" 164 | }, 165 | "engines": { 166 | "node": "^12.20.0 || ^14.13.1 || >=16.0.0" 167 | }, 168 | "funding": { 169 | "type": "opencollective", 170 | "url": "https://opencollective.com/node-fetch" 171 | } 172 | }, 173 | "node_modules/redis-errors": { 174 | "version": "1.2.0", 175 | "resolved": "https://registry.npmjs.org/redis-errors/-/redis-errors-1.2.0.tgz", 176 | "integrity": "sha512-1qny3OExCf0UvUV/5wpYKf2YwPcOqXzkwKKSmKHiE6ZMQs5heeE/c8eXK+PNllPvmjgAbfnsbpkGZWy8cBpn9w==", 177 | "engines": { 178 | "node": ">=4" 179 | } 180 | }, 181 | "node_modules/redis-parser": { 182 | "version": "3.0.0", 183 | "resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-3.0.0.tgz", 184 | "integrity": "sha512-DJnGAeenTdpMEH6uAJRK/uiyEIH9WVsUmoLwzudwGJUwZPp80PDBWPHXSAGNPwNvIXAbe7MSUB1zQFugFml66A==", 185 | "dependencies": { 186 | "redis-errors": "^1.0.0" 187 | }, 188 | "engines": { 189 | "node": ">=4" 190 | } 191 | }, 192 | "node_modules/standard-as-callback": { 193 | "version": "2.1.0", 194 | "resolved": "https://registry.npmjs.org/standard-as-callback/-/standard-as-callback-2.1.0.tgz", 195 | "integrity": "sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A==" 196 | }, 197 | "node_modules/web-streams-polyfill": { 198 | "version": "3.2.1", 199 | "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz", 200 | "integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==", 201 | "engines": { 202 | "node": ">= 8" 203 | } 204 | } 205 | }, 206 | "dependencies": { 207 | "@ioredis/commands": { 208 | "version": "1.2.0", 209 | "resolved": "https://registry.npmjs.org/@ioredis/commands/-/commands-1.2.0.tgz", 210 | "integrity": "sha512-Sx1pU8EM64o2BrqNpEO1CNLtKQwyhuXuqyfH7oGKCk+1a33d2r5saW8zNwm3j6BTExtjrv2BxTgzzkMwts6vGg==" 211 | }, 212 | "bottleneck": { 213 | "version": "2.19.5", 214 | "resolved": "https://registry.npmjs.org/bottleneck/-/bottleneck-2.19.5.tgz", 215 | "integrity": "sha512-VHiNCbI1lKdl44tGrhNfU3lup0Tj/ZBMJB5/2ZbNXRCPuRCO7ed2mgcK4r17y+KB2EfuYuRaVlwNbAeaWGSpbw==" 216 | }, 217 | "cluster-key-slot": { 218 | "version": "1.1.2", 219 | "resolved": "https://registry.npmjs.org/cluster-key-slot/-/cluster-key-slot-1.1.2.tgz", 220 | "integrity": "sha512-RMr0FhtfXemyinomL4hrWcYJxmX6deFdCxpJzhDttxgO1+bcCnkk+9drydLVDmAMG7NE6aN/fl4F7ucU/90gAA==" 221 | }, 222 | "data-uri-to-buffer": { 223 | "version": "4.0.1", 224 | "resolved": "https://registry.npmjs.org/data-uri-to-buffer/-/data-uri-to-buffer-4.0.1.tgz", 225 | "integrity": "sha512-0R9ikRb668HB7QDxT1vkpuUBtqc53YyAwMwGeUFKRojY/NWKvdZ+9UYtRfGmhqNbRkTSVpMbmyhXipFFv2cb/A==" 226 | }, 227 | "debug": { 228 | "version": "4.3.4", 229 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", 230 | "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", 231 | "requires": { 232 | "ms": "2.1.2" 233 | } 234 | }, 235 | "denque": { 236 | "version": "2.1.0", 237 | "resolved": "https://registry.npmjs.org/denque/-/denque-2.1.0.tgz", 238 | "integrity": "sha512-HVQE3AAb/pxF8fQAoiqpvg9i3evqug3hoiwakOyZAwJm+6vZehbkYXZ0l4JxS+I3QxM97v5aaRNhj8v5oBhekw==" 239 | }, 240 | "fetch-blob": { 241 | "version": "3.2.0", 242 | "resolved": "https://registry.npmjs.org/fetch-blob/-/fetch-blob-3.2.0.tgz", 243 | "integrity": "sha512-7yAQpD2UMJzLi1Dqv7qFYnPbaPx7ZfFK6PiIxQ4PfkGPyNyl2Ugx+a/umUonmKqjhM4DnfbMvdX6otXq83soQQ==", 244 | "requires": { 245 | "node-domexception": "^1.0.0", 246 | "web-streams-polyfill": "^3.0.3" 247 | } 248 | }, 249 | "formdata-polyfill": { 250 | "version": "4.0.10", 251 | "resolved": "https://registry.npmjs.org/formdata-polyfill/-/formdata-polyfill-4.0.10.tgz", 252 | "integrity": "sha512-buewHzMvYL29jdeQTVILecSaZKnt/RJWjoZCF5OW60Z67/GmSLBkOFM7qh1PI3zFNtJbaZL5eQu1vLfazOwj4g==", 253 | "requires": { 254 | "fetch-blob": "^3.1.2" 255 | } 256 | }, 257 | "ioredis": { 258 | "version": "5.3.2", 259 | "resolved": "https://registry.npmjs.org/ioredis/-/ioredis-5.3.2.tgz", 260 | "integrity": "sha512-1DKMMzlIHM02eBBVOFQ1+AolGjs6+xEcM4PDL7NqOS6szq7H9jSaEkIUH6/a5Hl241LzW6JLSiAbNvTQjUupUA==", 261 | "requires": { 262 | "@ioredis/commands": "^1.1.1", 263 | "cluster-key-slot": "^1.1.0", 264 | "debug": "^4.3.4", 265 | "denque": "^2.1.0", 266 | "lodash.defaults": "^4.2.0", 267 | "lodash.isarguments": "^3.1.0", 268 | "redis-errors": "^1.2.0", 269 | "redis-parser": "^3.0.0", 270 | "standard-as-callback": "^2.1.0" 271 | } 272 | }, 273 | "lodash.defaults": { 274 | "version": "4.2.0", 275 | "resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-4.2.0.tgz", 276 | "integrity": "sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ==" 277 | }, 278 | "lodash.isarguments": { 279 | "version": "3.1.0", 280 | "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", 281 | "integrity": "sha512-chi4NHZlZqZD18a0imDHnZPrDeBbTtVN7GXMwuGdRH9qotxAjYs3aVLKc7zNOG9eddR5Ksd8rvFEBc9SsggPpg==" 282 | }, 283 | "ms": { 284 | "version": "2.1.2", 285 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", 286 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" 287 | }, 288 | "node-domexception": { 289 | "version": "1.0.0", 290 | "resolved": "https://registry.npmjs.org/node-domexception/-/node-domexception-1.0.0.tgz", 291 | "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==" 292 | }, 293 | "node-fetch": { 294 | "version": "3.3.2", 295 | "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-3.3.2.tgz", 296 | "integrity": "sha512-dRB78srN/l6gqWulah9SrxeYnxeddIG30+GOqK/9OlLVyLg3HPnr6SqOWTWOXKRwC2eGYCkZ59NNuSgvSrpgOA==", 297 | "requires": { 298 | "data-uri-to-buffer": "^4.0.0", 299 | "fetch-blob": "^3.1.4", 300 | "formdata-polyfill": "^4.0.10" 301 | } 302 | }, 303 | "redis-errors": { 304 | "version": "1.2.0", 305 | "resolved": "https://registry.npmjs.org/redis-errors/-/redis-errors-1.2.0.tgz", 306 | "integrity": "sha512-1qny3OExCf0UvUV/5wpYKf2YwPcOqXzkwKKSmKHiE6ZMQs5heeE/c8eXK+PNllPvmjgAbfnsbpkGZWy8cBpn9w==" 307 | }, 308 | "redis-parser": { 309 | "version": "3.0.0", 310 | "resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-3.0.0.tgz", 311 | "integrity": "sha512-DJnGAeenTdpMEH6uAJRK/uiyEIH9WVsUmoLwzudwGJUwZPp80PDBWPHXSAGNPwNvIXAbe7MSUB1zQFugFml66A==", 312 | "requires": { 313 | "redis-errors": "^1.0.0" 314 | } 315 | }, 316 | "standard-as-callback": { 317 | "version": "2.1.0", 318 | "resolved": "https://registry.npmjs.org/standard-as-callback/-/standard-as-callback-2.1.0.tgz", 319 | "integrity": "sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A==" 320 | }, 321 | "web-streams-polyfill": { 322 | "version": "3.2.1", 323 | "resolved": "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.2.1.tgz", 324 | "integrity": "sha512-e0MO3wdXWKrLbL0DgGnUV7WHVuw9OUvL4hjgnPkIeEvESk74gAITi5G606JtZPp39cd8HA9VQzCIvA49LpPN5Q==" 325 | } 326 | } 327 | } 328 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "pixelic-api-wrapper", 3 | "version": "1.0.17", 4 | "description": "A Wrapper for the Pixelic-API.", 5 | "main": "./src/client", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "https://github.com/Pixelicc/Pixelic-API-Wrapper" 12 | }, 13 | "keywords": [ 14 | "pixelic-api", 15 | "hypixel", 16 | "hypixel-api" 17 | ], 18 | "author": "Pixelic", 19 | "license": "MIT", 20 | "dependencies": { 21 | "bottleneck": "^2.19.5", 22 | "ioredis": "^5.3.1", 23 | "node-fetch": "^3.3.1" 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/API/getAuctionByID.js: -------------------------------------------------------------------------------- 1 | const errors = require("../errors"); 2 | const utils = require("../utils"); 3 | 4 | /** 5 | * Query a specific past auction. 6 | * @constructor 7 | * @param {string} UUID - The UUID associated with that specific auction. 8 | */ 9 | module.exports = async function (UUID) { 10 | if (!utils.validateUUID(UUID)) return new Error(errors.INVALID_AUCTION_UUID); 11 | 12 | const res = await this.makeRequest(`https://api.pixelic.de/auctionhouse/auctionbyid/${UUID}`); 13 | const parsedRes = await res.json(); 14 | 15 | if (res.status === 200 || res.status === 304) return parsedRes; 16 | if (res.status === 422) return new Error(errors.INVALID_AUCTION_UUID); 17 | if (res.status === 429) return new Error(errors.RATELIMIT); 18 | 19 | return new Error(errors.UNEXPECTED_ERROR); 20 | }; 21 | -------------------------------------------------------------------------------- /src/API/getAuctionPriceHistory.js: -------------------------------------------------------------------------------- 1 | const errors = require("../errors"); 2 | const utils = require("../utils"); 3 | 4 | /** 5 | * Retrieve the price history of a specific auctionhouse item. 6 | * @constructor 7 | * @param {string} timeframe - The timeframe you want information about. 8 | * @param {string} item - The skyblock item's ID you want to look up. 9 | */ 10 | module.exports = async function (timeframe, item) { 11 | if (!["day", "week", "month", "year", "alltime"].includes(timeframe)) return new Error(errors.INVALID_AH_HISTORY_TIMEFRAME); 12 | if (!utils.validateSkyblockID(item)) return new Error(errors.INVALID_SKYBLOCK_ITEM); 13 | 14 | const res = await this.makeRequest(`https://api.pixelic.de/auctionhouse/history/${timeframe}/${item}`); 15 | const parsedRes = await res.json(); 16 | 17 | if (res.status === 200 || res.status === 304) return parsedRes; 18 | if (res.status === 404) return new Error(errors.INVALID_AH_ITEM); 19 | if (res.status === 429) return new Error(errors.RATELIMIT); 20 | 21 | return new Error(errors.UNEXPECTED_ERROR); 22 | }; 23 | -------------------------------------------------------------------------------- /src/API/getAuctionsByPlayer.js: -------------------------------------------------------------------------------- 1 | const errors = require("../errors"); 2 | const utils = require("../utils"); 3 | 4 | /** 5 | * Retrieve the most recent auctions by a player (up to 100). 6 | * @constructor 7 | * @param {string} player - IGN or UUID of the player you want to lookup. 8 | */ 9 | module.exports = async function (player) { 10 | if (!utils.validateUUID(player) && !utils.validateUsername(player)) return new Error(errors.INVALID_UUID_OR_USERNAME); 11 | 12 | const res = await this.makeRequest(`https://api.pixelic.de/auctionhouse/auctionsbyplayer/${player}`); 13 | const parsedRes = await res.json(); 14 | 15 | if (res.status === 200 || res.status === 304) return parsedRes; 16 | if (res.status === 422) return new Error(errors.INVALID_UUID_OR_USERNAME); 17 | if (res.status === 429) return new Error(errors.RATELIMIT); 18 | 19 | return new Error(errors.UNEXPECTED_ERROR); 20 | }; 21 | -------------------------------------------------------------------------------- /src/API/getAuctionsByProfile.js: -------------------------------------------------------------------------------- 1 | const errors = require("../errors"); 2 | const utils = require("../utils"); 3 | 4 | /** 5 | * Retrieve the most recent auctions by a skyblock profile (up to 100 **AND ONLY SELL DATA**). 6 | * @constructor 7 | * @param {string} profile - UUID of the profile you want to lookup. 8 | */ 9 | module.exports = async function (profile) { 10 | if (!utils.validateUUID(profile)) return new Error(errors.INVALID_PROFILE_UUID); 11 | 12 | const res = await this.makeRequest(`https://api.pixelic.de/auctionhouse/auctionsbyprofile/${profile}`); 13 | const parsedRes = await res.json(); 14 | 15 | if (res.status === 200 || res.status === 304) return parsedRes; 16 | if (res.status === 422) return new Error(errors.INVALID_PROFILE_UUID); 17 | if (res.status === 429) return new Error(errors.RATELIMIT); 18 | 19 | return new Error(errors.UNEXPECTED_ERROR); 20 | }; 21 | -------------------------------------------------------------------------------- /src/API/getBazaarHistory.js: -------------------------------------------------------------------------------- 1 | const errors = require("../errors"); 2 | const utils = require("../utils"); 3 | 4 | /** 5 | * Retrieve the price history of a specific bazaar item. 6 | * @constructor 7 | * @param {string} timeframe - The timeframe you want information about. 8 | * @param {string} product - The skyblock item's ID you want to look up. 9 | */ 10 | module.exports = async function (timeframe, product) { 11 | if (!["hour", "day", "week", "month", "year", "alltime"].includes(timeframe)) return new Error(errors.INVALID_HISTORY_TIMEFRAME); 12 | if (!utils.validateSkyblockID(product)) return new Error(errors.INVALID_SKYBLOCK_ITEM); 13 | 14 | const res = await this.makeRequest(`https://api.pixelic.de/bazaar/history/${timeframe}/${product}`); 15 | const parsedRes = await res.json(); 16 | 17 | if (res.status === 200 || res.status === 304) return parsedRes; 18 | if (res.status === 404) return new Error(errors.INVALID_BAZAAR_PRODUCT); 19 | if (res.status === 429) return new Error(errors.RATELIMIT); 20 | 21 | return new Error(errors.UNEXPECTED_ERROR); 22 | }; 23 | -------------------------------------------------------------------------------- /src/API/getCountsHistory.js: -------------------------------------------------------------------------------- 1 | const errors = require("../errors"); 2 | 3 | /** 4 | * Retrieve Hypixel's playercount history. 5 | * @constructor 6 | * @param {string} timeframe - The timeframe you want information about. 7 | */ 8 | module.exports = async function (timeframe) { 9 | if (!["hour", "day", "week", "month", "year", "alltime"].includes(timeframe)) return new Error(errors.INVALID_HISTORY_TIMEFRAME); 10 | 11 | const res = await this.makeRequest(`https://api.pixelic.de/counts/history/${timeframe}`); 12 | const parsedRes = await res.json(); 13 | 14 | if (res.status === 200 || res.status === 304) return parsedRes; 15 | if (res.status === 429) return new Error(errors.RATELIMIT); 16 | 17 | return new Error(errors.UNEXPECTED_ERROR); 18 | }; 19 | -------------------------------------------------------------------------------- /src/API/getCurrentAuctionPrice.js: -------------------------------------------------------------------------------- 1 | const errors = require("../errors"); 2 | const utils = require("../utils"); 3 | 4 | /** 5 | * Retrieve the current price of an auctionhouse item. 6 | * @constructor 7 | * @param {string} item - The skyblock item's ID you want to look up. 8 | */ 9 | module.exports = async function (item) { 10 | if (!utils.validateSkyblockID(item)) return new Error(errors.INVALID_SKYBLOCK_ITEM); 11 | 12 | const res = await this.makeRequest(`https://api.pixelic.de/auctionhouse/current/${item}`); 13 | const parsedRes = await res.json(); 14 | 15 | if (res.status === 200 || res.status === 304) return parsedRes; 16 | if (res.status === 404) return new Error(errors.INVALID_AH_ITEM); 17 | if (res.status === 429) return new Error(errors.RATELIMIT); 18 | 19 | return new Error(errors.UNEXPECTED_ERROR); 20 | }; 21 | -------------------------------------------------------------------------------- /src/API/getDaily.js: -------------------------------------------------------------------------------- 1 | const utils = require("../utils"); 2 | const errors = require("../errors"); 3 | 4 | /** 5 | * Retrieve the daily stats of a specific player (Returns the total stats from the last check). 6 | * @constructor 7 | * @param {string} player - IGN or UUID of the player you want to lookup. 8 | */ 9 | module.exports = async function (player) { 10 | if (!utils.validateUUID(player) && !utils.validateUsername(player)) return new Error(errors.INVALID_UUID_OR_USERNAME); 11 | 12 | const res = await this.makeRequest(`https://api.pixelic.de/player/${player}/daily`); 13 | const parsedRes = await res.json(); 14 | 15 | if (res.status === 200 || res.status === 304) return parsedRes; 16 | 17 | if (res.status === 404) return new Error(errors.NOT_IN_DATABASE); 18 | if (res.status == 422) { 19 | return new Error(errors.INVALID_UUID_OR_USERNAME); 20 | } 21 | if (res.status === 429) return new Error(errors.RATELIMIT); 22 | 23 | return new Error(errors.UNEXPECTED_ERROR); 24 | }; 25 | -------------------------------------------------------------------------------- /src/API/getDailySkyblock.js: -------------------------------------------------------------------------------- 1 | const utils = require("../utils"); 2 | const errors = require("../errors"); 3 | 4 | /** 5 | * Retrieve the daily skyblock stats of a specific player (Returns the total stats from the last check). 6 | * @constructor 7 | * @param {string} player - IGN or UUID of the player you want to lookup. 8 | */ 9 | module.exports = async function (player) { 10 | if (!utils.validateUUID(player) && !utils.validateUsername(player)) return new Error(errors.INVALID_UUID_OR_USERNAME); 11 | 12 | const res = await this.makeRequest(`https://api.pixelic.de/player/skyblock/${player}/daily`); 13 | const parsedRes = await res.json(); 14 | 15 | if (res.status === 200 || res.status === 304) return parsedRes; 16 | 17 | if (res.status === 404) return new Error(errors.NOT_IN_DATABASE); 18 | if (res.status == 422) { 19 | return new Error(errors.INVALID_UUID_OR_USERNAME); 20 | } 21 | if (res.status === 429) return new Error(errors.RATELIMIT); 22 | 23 | return new Error(errors.UNEXPECTED_ERROR); 24 | }; 25 | -------------------------------------------------------------------------------- /src/API/getDistribution.js: -------------------------------------------------------------------------------- 1 | const errors = require("../errors"); 2 | 3 | /** 4 | * Retrieve distribution counts of ranks, plusColors, plusPlusColors, languages or chatChannels. 5 | * @constructor 6 | * @param {string} distribution - The distribution you want to look up (supported are ranks, plusColor, plusPlusColor, language or chatChannel) 7 | */ 8 | module.exports = async function (distribution) { 9 | if (!["ranks", "plusColor", "plusPlusColor", "language", "chatChannel"].includes(distribution)) return new Error(errors.INVALID_DISTRIBUTION); 10 | 11 | const res = await this.makeRequest(`https://api.pixelic.de/distribution/${distribution}`, "GET", "NON-LIMITED"); 12 | const parsedRes = await res.json(); 13 | 14 | if (res.status === 200 || res.status === 304) return parsedRes; 15 | 16 | return new Error(errors.UNEXPECTED_ERROR); 17 | }; 18 | -------------------------------------------------------------------------------- /src/API/getGuild.js: -------------------------------------------------------------------------------- 1 | const utils = require("../utils"); 2 | const errors = require("../errors"); 3 | 4 | /** 5 | * Retrieve stats about a tracked guild including EXP, level, guildMaster, members, EXPHistory, scaledEXPHistory, monthlyRawEXP, monthlyScaledEXP and lifetime EXPPerGame. 6 | * 7 | * To get the current Monthly Raw GEXP take the monthlyRawEXP key and add the current Day's raw value to it. To get the current Monthly scaled GEXP take the monthlyScaledEXP key and add the current Day's raw value to it. You can retrieve the current Day's value by calling the Hypixel API. Daily and Weekly raw and scaled GEXP should be calculated directly with the Hypixel API Data. 8 | * @constructor 9 | * @param {string} guild - ID of the guild you want to lookup. 10 | */ 11 | module.exports = async function (guild) { 12 | if (!utils.validateGuildID(guild)) return new Error(errors.INVALID_GUILDID); 13 | 14 | const res = await this.makeRequest(`https://api.pixelic.de/guild/${guild}`); 15 | const parsedRes = await res.json(); 16 | 17 | if (res.status === 200 || res.status === 304) return parsedRes; 18 | 19 | if (res.status === 404) return new Error(errors.GUILD_NOT_IN_DATABASE); 20 | if (res.status === 422) return new Error(errors.INVALID_GUILDID); 21 | if (res.status === 429) return new Error(errors.RATELIMIT); 22 | 23 | return new Error(errors.UNEXPECTED_ERROR); 24 | }; 25 | -------------------------------------------------------------------------------- /src/API/getGuildLeaderboard.js: -------------------------------------------------------------------------------- 1 | const errors = require("../errors"); 2 | 3 | /** 4 | * Retrieve all guild leaderboards for the specified timeframe. 5 | * @constructor 6 | * @param {string} timeframe - The timeframe you want information about (allowed are "lifetime", "monthly", "weekly" and "daily"). 7 | * @param {number} limit - Choose how many players you want per leaderboard (allowed are 10, 100 and 1000). 8 | */ 9 | module.exports = async function (timeframe, limit) { 10 | if (!["lifetime", "monthly", "weekly", "daily"].includes(timeframe)) return new Error(errors.INVALID_LEADERBOARD_TIMEFRAME); 11 | if (![1000, 100, 10].includes(limit)) return new Error(errors.INVALID_LEADERBOARD_LIMIT); 12 | 13 | const res = await this.makeRequest(`https://api.pixelic.de/guild-leaderboard/${timeframe.toLowerCase()}/${limit}`, "GET", "NON-LIMITED"); 14 | const parsedRes = await res.json(); 15 | 16 | if (res.status === 200 || res.status === 304) return parsedRes; 17 | 18 | return new Error(errors.UNEXPECTED_ERROR); 19 | }; 20 | -------------------------------------------------------------------------------- /src/API/getGuildMember.js: -------------------------------------------------------------------------------- 1 | const utils = require("../utils"); 2 | const errors = require("../errors"); 3 | 4 | /** 5 | * Retrieve stats about a guild member tracked including the corresponding guildID, alltimeQuestParticipation, EXPHistory and monthlyEXP. 6 | * 7 | * To get the current Monthly GEXP take the monthlyEXP key and add the current Day's value to it. You can retrieve the current Day's value by calling the Hypixel API. Daily and Weekly GEXP should be calculated directly with the Hypixel API Data. 8 | * @constructor 9 | * @param {string} player - IGN or UUID of the player you want to lookup. 10 | */ 11 | module.exports = async function (player) { 12 | if (!utils.validateUUID(player) && !utils.validateUsername(player)) return new Error(errors.INVALID_UUID_OR_USERNAME); 13 | 14 | const res = await this.makeRequest(`https://api.pixelic.de/guild/member/${player}`); 15 | const parsedRes = await res.json(); 16 | 17 | if (res.status === 200 || res.status === 304) return parsedRes; 18 | 19 | if (res.status === 404) return new Error(errors.GUILD_MEMBER_NOT_IN_DATABASE); 20 | if (res.status === 422) return new Error(errors.INVALID_GUILDID); 21 | if (res.status === 429) return new Error(errors.RATELIMIT); 22 | 23 | return new Error(errors.UNEXPECTED_ERROR); 24 | }; 25 | -------------------------------------------------------------------------------- /src/API/getGuildPositions.js: -------------------------------------------------------------------------------- 1 | const errors = require("../errors"); 2 | const utils = require("../utils"); 3 | 4 | /** 5 | * Returns all positions of a guild on leaderboards in the specified timeframe. 6 | * @constructor 7 | * @param {string} timeframe - The timeframe you want information about (allowed are "lifetime", "monthly", "weekly" and "daily"). 8 | * @param {string} guild - ID of the guild you want to lookup. 9 | */ 10 | module.exports = async function (timeframe, guild) { 11 | if (!utils.validateGuildID(guild)) return new Error(errors.INVALID_GUILDID); 12 | if (!["lifetime", "monthly", "weekly", "daily"].includes(timeframe.toLowerCase())) return new Error(errors.INVALID_LEADERBOARD_TIMEFRAME); 13 | 14 | const res = await this.makeRequest(`https://api.pixelic.de/guild-leaderboard/getpositions/${timeframe.toLowerCase()}/${guild}`, "GET", "LEADERBOARD"); 15 | const parsedRes = await res.json(); 16 | 17 | if (res.status === 200 || res.status === 304) return parsedRes; 18 | if (res.status === 429) return new Error(errors.RATELIMIT); 19 | 20 | return new Error(errors.UNEXPECTED_ERROR); 21 | }; 22 | -------------------------------------------------------------------------------- /src/API/getHistoricalAll.js: -------------------------------------------------------------------------------- 1 | const utils = require("../utils"); 2 | const errors = require("../errors"); 3 | 4 | /** 5 | * Returns all collected datapoints about a specific player. 6 | * @constructor 7 | * @param {string} player - IGN or UUID of the player you want to lookup. 8 | */ 9 | module.exports = async function (player) { 10 | if (!utils.validateUUID(player) && !utils.validateUsername(player)) return new Error(errors.INVALID_UUID_OR_USERNAME); 11 | 12 | const res = await this.makeRequest(`https://api.pixelic.de/player/${player}/all`); 13 | const parsedRes = await res.json(); 14 | 15 | if (res.status === 200 || res.status === 304) return parsedRes; 16 | 17 | if (res.status === 404) return new Error(errors.NOT_IN_DATABASE); 18 | if (res.status == 422) { 19 | return new Error(errors.INVALID_UUID_OR_USERNAME); 20 | } 21 | if (res.status === 429) return new Error(errors.RATELIMIT); 22 | 23 | return new Error(errors.UNEXPECTED_ERROR); 24 | }; 25 | -------------------------------------------------------------------------------- /src/API/getHistoricalAllSkyblock.js: -------------------------------------------------------------------------------- 1 | const utils = require("../utils"); 2 | const errors = require("../errors"); 3 | 4 | /** 5 | * Returns all collected datapoints about a specific skyblock player. 6 | * @constructor 7 | * @param {string} player - IGN or UUID of the player you want to lookup. 8 | */ 9 | module.exports = async function (player) { 10 | if (!utils.validateUUID(player) && !utils.validateUsername(player)) return new Error(errors.INVALID_UUID_OR_USERNAME); 11 | 12 | const res = await this.makeRequest(`https://api.pixelic.de/player/skyblock/${player}/all`); 13 | const parsedRes = await res.json(); 14 | 15 | if (res.status === 200 || res.status === 304) return parsedRes; 16 | 17 | if (res.status === 404) return new Error(errors.NOT_IN_DATABASE); 18 | if (res.status == 422) { 19 | return new Error(errors.INVALID_UUID_OR_USERNAME); 20 | } 21 | if (res.status === 429) return new Error(errors.RATELIMIT); 22 | 23 | return new Error(errors.UNEXPECTED_ERROR); 24 | }; 25 | -------------------------------------------------------------------------------- /src/API/getHistoricalDate.js: -------------------------------------------------------------------------------- 1 | const utils = require("../utils"); 2 | const errors = require("../errors"); 3 | 4 | /** 5 | * Retrieve the stats of a specific player on the specified date (Returns the total stats from the last check). 6 | * @constructor 7 | * @param {string} date - Date you want to lookup (ISO-String formatted like "2023-01-01"). 8 | * @param {string} player - IGN or UUID of the player you want to lookup. 9 | */ 10 | module.exports = async function (date, player) { 11 | if (!utils.validateUUID(player) && !utils.validateUsername(player)) return new Error(errors.INVALID_UUID_OR_USERNAME); 12 | if (!utils.validateISOString(timeframe.slice(timeframe.indexOf("/") + 1))) return new Error(errors.INVALID_ISOSTRING); 13 | 14 | const res = await this.makeRequest(`https://api.pixelic.de/player/${player}/${date}`); 15 | const parsedRes = await res.json(); 16 | 17 | if (res.status === 200 || res.status === 304) return parsedRes; 18 | 19 | if (res.status === 404) return new Error(errors.NOT_IN_DATABASE); 20 | if (res.status == 422) { 21 | if (parsedRes.cause == "Invalid UUID or Username") return new Error(errors.INVALID_UUID_OR_USERNAME); 22 | if (parsedRes.cause == "No Stats were found for the specified date") return new Error(errors.EMPTY_DATE); 23 | if (parsedRes.cause == "Arguments invalid") return new Error(errors.UNEXPECTED_ERROR); 24 | } 25 | if (res.status === 429) return new Error(errors.RATELIMIT); 26 | 27 | return new Error(errors.UNEXPECTED_ERROR); 28 | }; 29 | -------------------------------------------------------------------------------- /src/API/getHistoricalDateSkyblock.js: -------------------------------------------------------------------------------- 1 | const utils = require("../utils"); 2 | const errors = require("../errors"); 3 | 4 | /** 5 | * Retrieve the stats of a specific skyblock player on the specified date (Returns the total stats from the last check). 6 | * @constructor 7 | * @param {string} date - Date you want to lookup (ISO-String formatted like "2023-01-01"). 8 | * @param {string} player - IGN or UUID of the player you want to lookup. 9 | */ 10 | module.exports = async function (date, player) { 11 | if (!utils.validateUUID(player) && !utils.validateUsername(player)) return new Error(errors.INVALID_UUID_OR_USERNAME); 12 | if (!utils.validateISOString(timeframe.slice(timeframe.indexOf("/") + 1))) return new Error(errors.INVALID_ISOSTRING); 13 | 14 | const res = await this.makeRequest(`https://api.pixelic.de/player/skyblock/${player}/${date}`); 15 | const parsedRes = await res.json(); 16 | 17 | if (res.status === 200 || res.status === 304) return parsedRes; 18 | 19 | if (res.status === 404) return new Error(errors.NOT_IN_DATABASE); 20 | if (res.status == 422) { 21 | if (parsedRes.cause == "Invalid UUID or Username") return new Error(errors.INVALID_UUID_OR_USERNAME); 22 | if (parsedRes.cause == "No Stats were found for the specified date") return new Error(errors.EMPTY_DATE); 23 | if (parsedRes.cause == "Arguments invalid") return new Error(errors.UNEXPECTED_ERROR); 24 | } 25 | if (res.status === 429) return new Error(errors.RATELIMIT); 26 | 27 | return new Error(errors.UNEXPECTED_ERROR); 28 | }; 29 | -------------------------------------------------------------------------------- /src/API/getItemHistory.js: -------------------------------------------------------------------------------- 1 | const errors = require("../errors"); 2 | const utils = require("../utils"); 3 | 4 | /** 5 | * Query a specific item's history. Returns all past auctions about the exact same item (with the same Item-UUID). 6 | * @constructor 7 | * @param {string} UUID - The UUID associated with that specific item. 8 | */ 9 | module.exports = async function (UUID) { 10 | if (!utils.validateUUID(UUID)) return new Error(errors.INVALID_UUID); 11 | 12 | const res = await this.makeRequest(`https://api.pixelic.de/auctionhouse/itemhistory/${UUID}`); 13 | const parsedRes = await res.json(); 14 | 15 | if (res.status === 200 || res.status === 304) return parsedRes; 16 | if (res.status === 422) return new Error(errors.INVALID_ITEM_UUID); 17 | if (res.status === 429) return new Error(errors.RATELIMIT); 18 | 19 | return new Error(errors.UNEXPECTED_ERROR); 20 | }; 21 | -------------------------------------------------------------------------------- /src/API/getKeyInfo.js: -------------------------------------------------------------------------------- 1 | const errors = require("../errors"); 2 | 3 | /** 4 | * Returns all relevant information about your Pixelic-API-Key. 5 | */ 6 | module.exports = async function () { 7 | const res = await this.makeRequest(`https://api.pixelic.de/key`); 8 | const parsedRes = await res.json(); 9 | 10 | if (res.status === 200 || res.status === 304) return parsedRes; 11 | if (res.status === 429) return new Error(errors.RATELIMIT); 12 | 13 | return new Error(errors.UNEXPECTED_ERROR); 14 | }; 15 | -------------------------------------------------------------------------------- /src/API/getLeaderboard.js: -------------------------------------------------------------------------------- 1 | const errors = require("../errors"); 2 | 3 | /** 4 | * Retrieve all leaderboards for the specified mode for the specified timeframe. 5 | * @constructor 6 | * @param {string} timeframe - The timeframe you want information about (allowed are "lifetime", "monthly", "weekly" and "daily"). 7 | * @param {string} mode - The mode you want information about (currently supported are General, Bedwars, Skywars and Duels). 8 | * @param {number} limit - Choose how many players you want per leaderboard (allowed are 10, 100 and 1000). 9 | */ 10 | module.exports = async function (timeframe, mode, limit) { 11 | if (!["lifetime", "monthly", "weekly", "daily"].includes(timeframe.toLowerCase())) return new Error(errors.INVALID_LEADERBOARD_TIMEFRAME); 12 | if (!["general", "bedwars", "skywars", "duels"].includes(mode.toLowerCase())) return new Error(errors.INVALID_LEADERBOARD); 13 | if (![1000, 100, 10].includes(limit)) return new Error(errors.INVALID_LEADERBOARD_LIMIT); 14 | 15 | const res = await this.makeRequest(`https://api.pixelic.de/leaderboard/${timeframe.toLowerCase()}/${mode.toLowerCase()}/${limit}`, "GET", "NON-LIMITED"); 16 | const parsedRes = await res.json(); 17 | 18 | if (res.status === 200 || res.status === 304) return parsedRes; 19 | 20 | return new Error(errors.UNEXPECTED_ERROR); 21 | }; 22 | -------------------------------------------------------------------------------- /src/API/getMonthly.js: -------------------------------------------------------------------------------- 1 | const utils = require("../utils"); 2 | const errors = require("../errors"); 3 | 4 | /** 5 | * Retrieve the monthly stats of a specific player (Returns the total stats from the last check). 6 | * @constructor 7 | * @param {string} player - IGN or UUID of the player you want to lookup. 8 | */ 9 | module.exports = async function (player) { 10 | if (!utils.validateUUID(player) && !utils.validateUsername(player)) return new Error(errors.INVALID_UUID_OR_USERNAME); 11 | 12 | const res = await this.makeRequest(`https://api.pixelic.de/player/${player}/monthly`); 13 | const parsedRes = await res.json(); 14 | 15 | if (res.status === 200 || res.status === 304) return parsedRes; 16 | 17 | if (res.status === 404) return new Error(errors.NOT_IN_DATABASE); 18 | if (res.status == 422) { 19 | return new Error(errors.INVALID_UUID_OR_USERNAME); 20 | } 21 | if (res.status === 429) return new Error(errors.RATELIMIT); 22 | 23 | return new Error(errors.UNEXPECTED_ERROR); 24 | }; 25 | -------------------------------------------------------------------------------- /src/API/getMonthlySkyblock.js: -------------------------------------------------------------------------------- 1 | const utils = require("../utils"); 2 | const errors = require("../errors"); 3 | 4 | /** 5 | * Retrieve the monthly skyblock stats of a specific player (Returns the total stats from the last check). 6 | * @constructor 7 | * @param {string} player - IGN or UUID of the player you want to lookup. 8 | */ 9 | module.exports = async function (player) { 10 | if (!utils.validateUUID(player) && !utils.validateUsername(player)) return new Error(errors.INVALID_UUID_OR_USERNAME); 11 | 12 | const res = await this.makeRequest(`https://api.pixelic.de/player/skyblock/${player}/monthly`); 13 | const parsedRes = await res.json(); 14 | 15 | if (res.status === 200 || res.status === 304) return parsedRes; 16 | 17 | if (res.status === 404) return new Error(errors.NOT_IN_DATABASE); 18 | if (res.status == 422) { 19 | return new Error(errors.INVALID_UUID_OR_USERNAME); 20 | } 21 | if (res.status === 429) return new Error(errors.RATELIMIT); 22 | 23 | return new Error(errors.UNEXPECTED_ERROR); 24 | }; 25 | -------------------------------------------------------------------------------- /src/API/getPositions.js: -------------------------------------------------------------------------------- 1 | const errors = require("../errors"); 2 | const utils = require("../utils"); 3 | 4 | /** 5 | * Returns all positions of a player in a mode for the specified timeframe. 6 | * @constructor 7 | * @param {string} timeframe - The timeframe you want information about (allowed are "lifetime", "monthly", "weekly" and "daily"). 8 | * @param {string} mode - The mode you want information about (currently supported are General, Bedwars, Skywars and Duels). 9 | * @param {string} guild - ID of the guild you want to lookup. 10 | */ 11 | module.exports = async function (timeframe, mode, player) { 12 | if (!utils.validateUUID(player) && !utils.validateUsername(player)) return new Error(errors.INVALID_UUID_OR_USERNAME); 13 | if (!["lifetime", "monthly", "weekly", "daily"].includes(timeframe.toLowerCase())) return new Error(errors.INVALID_LEADERBOARD_TIMEFRAME); 14 | if (!["general", "bedwars", "skywars", "duels"].includes(mode.toLowerCase())) return new Error(errors.INVALID_LEADERBOARD); 15 | 16 | const res = await this.makeRequest(`https://api.pixelic.de/leaderboard/getpositions/${timeframe.toLowerCase()}/${mode.toLowerCase()}/${player}`, "GET", "LEADERBOARD"); 17 | const parsedRes = await res.json(); 18 | 19 | if (res.status === 200 || res.status === 304) return parsedRes; 20 | if (res.status === 429) return new Error(errors.RATELIMIT); 21 | 22 | return new Error(errors.UNEXPECTED_ERROR); 23 | }; 24 | -------------------------------------------------------------------------------- /src/API/getSkyblockLeaderboard.js: -------------------------------------------------------------------------------- 1 | const errors = require("../errors"); 2 | 3 | /** 4 | * Retrieve all skyblock leaderboards (Skyblock only supports lifetime leaderboards). 5 | * @constructor 6 | * @param {number} limit - Choose how many players you want per leaderboard (allowed are 10, 100 and 1000). 7 | */ 8 | module.exports = async function (limit) { 9 | if (![1000, 100, 10].includes(limit)) return new Error(errors.INVALID_LEADERBOARD_LIMIT); 10 | 11 | const res = await this.makeRequest(`https://api.pixelic.de/leaderboard/skyblock/${limit}`, "GET", "NON-LIMITED"); 12 | const parsedRes = await res.json(); 13 | 14 | if (res.status === 200 || res.status === 304) return parsedRes; 15 | 16 | return new Error(errors.UNEXPECTED_ERROR); 17 | }; 18 | -------------------------------------------------------------------------------- /src/API/getSkyblockPositions.js: -------------------------------------------------------------------------------- 1 | const errors = require("../errors"); 2 | const utils = require("../utils"); 3 | 4 | /** 5 | * Returns all positions of a skyblock player on a specific profile. 6 | * @constructor 7 | * @param {string} player - IGN or UUID of the player you want to lookup. 8 | * @param {string} profile - UUID of the profile you want to lookup. 9 | */ 10 | module.exports = async function (player, profile) { 11 | if (!utils.validateUUID(player) && !utils.validateUsername(player)) return new Error(errors.INVALID_UUID_OR_USERNAME); 12 | if (!utils.validateUUID(profile)) return new Error(errors.INVALID_PROFILE_UUID); 13 | 14 | const res = await this.makeRequest(`https://api.pixelic.de/leaderboard/skyblock/getpositions/${player}/${profile}`, "GET", "LEADERBOARD"); 15 | const parsedRes = await res.json(); 16 | 17 | if (res.status === 200 || res.status === 304) return parsedRes; 18 | if (res.status === 429) return new Error(errors.RATELIMIT); 19 | 20 | return new Error(errors.UNEXPECTED_ERROR); 21 | }; 22 | -------------------------------------------------------------------------------- /src/API/getStatHistory.js: -------------------------------------------------------------------------------- 1 | const errors = require("../errors"); 2 | 3 | /** 4 | * Returns all collected datapoints in the specified timeframe for the specified stat. 5 | * @constructor 6 | * @param {string} timeframe - The timeframe you want information about. 7 | * @param {string} stat - The stat you want more information about (allowed are "playersTracked", "playersTrackedSkyblock", " guildsTracked" or "auctionsStored"). 8 | */ 9 | module.exports = async function (timeframe, stat) { 10 | if (!["hour", "day", "week", "month", "year", "alltime"].includes(timeframe)) return new Error(errors.INVALID_HISTORY_TIMEFRAME); 11 | if (!["playersTracked", "playersTrackedSkyblock", " guildsTracked", "auctionsStored"].includes(stat)) return new Error(errors.INVALID_HISTORY_STAT); 12 | 13 | const res = await this.makeRequest(`https://api.pixelic.de/stats/history/${timeframe}/${stat}`); 14 | const parsedRes = await res.json(); 15 | 16 | if (res.status === 200 || res.status === 304) return parsedRes; 17 | if (res.status === 429) return new Error(errors.RATELIMIT); 18 | 19 | return new Error(errors.UNEXPECTED_ERROR); 20 | }; 21 | -------------------------------------------------------------------------------- /src/API/getStats.js: -------------------------------------------------------------------------------- 1 | const errors = require("../errors"); 2 | 3 | /** 4 | * Returns all relevant statistics about the Pixelic-API. 5 | */ 6 | module.exports = async function () { 7 | const res = await this.makeRequest(`https://api.pixelic.de/stats`, "GET", "NON-LIMITED"); 8 | const parsedRes = await res.json(); 9 | 10 | if (res.status === 200 || res.status === 304) return parsedRes; 11 | 12 | return new Error(errors.UNEXPECTED_ERROR); 13 | }; 14 | -------------------------------------------------------------------------------- /src/API/getStatus.js: -------------------------------------------------------------------------------- 1 | const errors = require("../errors"); 2 | 3 | /** 4 | * Returns more in-depth stats about the Status of the Hypixel API. 5 | */ 6 | module.exports = async function () { 7 | const res = await this.makeRequest(`https://api.pixelic.de/status`, "GET", "NON-LIMITED"); 8 | const parsedRes = await res.json(); 9 | 10 | if (res.status === 200 || res.status === 304) return parsedRes; 11 | 12 | return new Error(errors.UNEXPECTED_ERROR); 13 | }; 14 | -------------------------------------------------------------------------------- /src/API/getWeekly.js: -------------------------------------------------------------------------------- 1 | const utils = require("../utils"); 2 | const errors = require("../errors"); 3 | 4 | /** 5 | * Retrieve the weekly stats of a specific player (Returns the total stats from the last check). 6 | * @constructor 7 | * @param {string} player - IGN or UUID of the player you want to lookup. 8 | */ 9 | module.exports = async function (player) { 10 | if (!utils.validateUUID(player) && !utils.validateUsername(player)) return new Error(errors.INVALID_UUID_OR_USERNAME); 11 | 12 | const res = await this.makeRequest(`https://api.pixelic.de/player/skyblock/${player}/weekly`); 13 | const parsedRes = await res.json(); 14 | 15 | if (res.status === 200 || res.status === 304) return parsedRes; 16 | 17 | if (res.status === 404) return new Error(errors.NOT_IN_DATABASE); 18 | if (res.status == 422) { 19 | return new Error(errors.INVALID_UUID_OR_USERNAME); 20 | } 21 | if (res.status === 429) return new Error(errors.RATELIMIT); 22 | 23 | return new Error(errors.UNEXPECTED_ERROR); 24 | }; 25 | -------------------------------------------------------------------------------- /src/API/getWeeklySkyblock.js: -------------------------------------------------------------------------------- 1 | const utils = require("../utils"); 2 | const errors = require("../errors"); 3 | 4 | /** 5 | * Retrieve the weekly skyblock stats of a specific player (Returns the total stats from the last check). 6 | * @constructor 7 | * @param {string} player - IGN or UUID of the player you want to lookup. 8 | */ 9 | module.exports = async function (player) { 10 | if (!utils.validateUUID(player) && !utils.validateUsername(player)) return new Error(errors.INVALID_UUID_OR_USERNAME); 11 | 12 | const res = await this.makeRequest(`https://api.pixelic.de/player/${player}/weekly`); 13 | const parsedRes = await res.json(); 14 | 15 | if (res.status === 200 || res.status === 304) return parsedRes; 16 | 17 | if (res.status === 404) return new Error(errors.NOT_IN_DATABASE); 18 | if (res.status == 422) { 19 | return new Error(errors.INVALID_UUID_OR_USERNAME); 20 | } 21 | if (res.status === 429) return new Error(errors.RATELIMIT); 22 | 23 | return new Error(errors.UNEXPECTED_ERROR); 24 | }; 25 | -------------------------------------------------------------------------------- /src/API/getYearly.js: -------------------------------------------------------------------------------- 1 | const utils = require("../utils"); 2 | const errors = require("../errors"); 3 | 4 | /** 5 | * Retrieve the yearly stats of a specific player (Returns the total stats of the first found datapoint of the current year). 6 | * @constructor 7 | * @param {string} player - IGN or UUID of the player you want to lookup. 8 | */ 9 | module.exports = async function (player) { 10 | if (!utils.validateUUID(player) && !utils.validateUsername(player)) return new Error(errors.INVALID_UUID_OR_USERNAME); 11 | 12 | const res = await this.makeRequest(`https://api.pixelic.de/player/${player}/yearly`); 13 | const parsedRes = await res.json(); 14 | 15 | if (res.status === 200 || res.status === 304) return parsedRes; 16 | 17 | if (res.status === 404) return new Error(errors.NOT_IN_DATABASE); 18 | if (res.status == 422) { 19 | return new Error(errors.INVALID_UUID_OR_USERNAME); 20 | } 21 | if (res.status === 429) return new Error(errors.RATELIMIT); 22 | 23 | return new Error(errors.UNEXPECTED_ERROR); 24 | }; 25 | -------------------------------------------------------------------------------- /src/API/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | getStats: require("./getStats"), 3 | getStatHistory: require("./getStatHistory"), 4 | getKeyInfo: require("./getKeyInfo"), 5 | register: require("./register"), 6 | getDaily: require("./getDaily"), 7 | getWeekly: require("./getWeekly"), 8 | getMonthly: require("./getMonthly"), 9 | getHistoricalDate: require("./getHistoricalDate"), 10 | getHistoricalAll: require("./getHistoricalAll"), 11 | registerSkyblock: require("./registerSkyblock"), 12 | getDailySkyblock: require("./getDailySkyblock"), 13 | getWeeklySkyblock: require("./getWeeklySkyblock"), 14 | getMonthlySkyblock: require("./getMonthlySkyblock"), 15 | getHistoricalDateSkyblock: require("./getHistoricalDateSkyblock"), 16 | getHistoricalAllSkyblock: require("./getHistoricalAllSkyblock"), 17 | registerGuild: require("./registerGuild"), 18 | getGuild: require("./getGuild"), 19 | getGuildMember: require("./getGuildMember"), 20 | getBazaarHistory: require("./getBazaarHistory"), 21 | getCurrentAuctionPrice: require("./getCurrentAuctionPrice"), 22 | getAuctionPriceHistory: require("./getAuctionPriceHistory"), 23 | getCountsHistory: require("./getCountsHistory"), 24 | getAuctionByID: require("./getAuctionByID"), 25 | getAuctionsByPlayer: require("./getAuctionsByPlayer"), 26 | getAuctionsByProfile: require("./getAuctionsByProfile"), 27 | getItemHistory: require("./getItemHistory"), 28 | getLeaderboard: require("./getLeaderboard"), 29 | getSkyblockLeaderboard: require("./getSkyblockLeaderboard"), 30 | getGuildLeaderboard: require("./getGuildLeaderboard"), 31 | getPositions: require("./getPositions"), 32 | getSkyblockPositions: require("./getSkyblockPositions"), 33 | getGuildPositions: require("./getGuildPositions"), 34 | getDistribution: require("./getDistribution"), 35 | getStatus: require("./getStatus"), 36 | getYearly: require("./getYearly"), 37 | }; 38 | -------------------------------------------------------------------------------- /src/API/register.js: -------------------------------------------------------------------------------- 1 | const utils = require("../utils"); 2 | const errors = require("../errors"); 3 | 4 | /** 5 | * Register a player to the Pixelic-API's tracking. 6 | * @constructor 7 | * @param {string} player - IGN or UUID of the player you want to register. 8 | */ 9 | module.exports = async function (player) { 10 | if (!utils.validateUUID(player) && !utils.validateUsername(player)) return new Error(errors.INVALID_UUID_OR_USERNAME); 11 | 12 | const res = await this.makeRequest(`https://api.pixelic.de/player/${player}/register`, "POST", "REGISTER"); 13 | const parsedRes = await res.json(); 14 | 15 | if (res.status === 201) return parsedRes; 16 | 17 | if (res.status === 400) return new Error(errors.ALREADY_IN_DATABASE); 18 | if (res.status === 422) return new Error(errors.INVALID_UUID_OR_USERNAME); 19 | if (res.status === 429) return new Error(errors.RATELIMIT); 20 | 21 | return new Error(errors.UNEXPECTED_ERROR); 22 | }; 23 | -------------------------------------------------------------------------------- /src/API/registerGuild.js: -------------------------------------------------------------------------------- 1 | const utils = require("../utils"); 2 | const errors = require("../errors"); 3 | 4 | /** 5 | * Register a guild to the Pixelic-API's tracking. 6 | * @constructor 7 | * @param {string} guild - ID of the guild you want to register. 8 | */ 9 | module.exports = async function (guild) { 10 | if (!utils.validateGuildID(guild)) return new Error(errors.INVALID_GUILDID); 11 | 12 | const res = await this.makeRequest(`https://api.pixelic.de/guild/register/${guild}`, "POST", "REGISTER"); 13 | const parsedRes = await res.json(); 14 | 15 | if (res.status === 201) return parsedRes; 16 | 17 | if (res.status === 400) return new Error(errors.ALREADY_IN_DATABASE); 18 | if (res.status === 422) return new Error(errors.INVALID_GUILDID); 19 | if (res.status === 429) return new Error(errors.RATELIMIT); 20 | 21 | return new Error(errors.UNEXPECTED_ERROR); 22 | }; 23 | -------------------------------------------------------------------------------- /src/API/registerSkyblock.js: -------------------------------------------------------------------------------- 1 | const utils = require("../utils"); 2 | const errors = require("../errors"); 3 | 4 | /** 5 | * Register a skyblock player to the Pixelic-API's tracking. 6 | * @constructor 7 | * @param {string} player - IGN or UUID of the player you want to register. 8 | */ 9 | module.exports = async function (player) { 10 | if (!utils.validateUUID(player) && !utils.validateUsername(player)) return new Error(errors.INVALID_UUID_OR_USERNAME); 11 | 12 | const res = await this.makeRequest(`https://api.pixelic.de/player/skyblock/${player}/register`, "POST", "REGISTER"); 13 | const parsedRes = await res.json(); 14 | 15 | if (res.status === 201) return parsedRes; 16 | 17 | if (res.status === 400) return new Error(errors.ALREADY_IN_DATABASE); 18 | if (res.status === 422) return new Error(errors.INVALID_UUID_OR_USERNAME); 19 | if (res.status === 429) return new Error(errors.RATELIMIT); 20 | 21 | return new Error(errors.UNEXPECTED_ERROR); 22 | }; 23 | -------------------------------------------------------------------------------- /src/client.js: -------------------------------------------------------------------------------- 1 | const fetch = (...args) => import("node-fetch").then(({ default: fetch }) => fetch(...args)); 2 | const Bottleneck = require("bottleneck"); 3 | const API = require("./API/index"); 4 | const updater = new (require("./updater"))(); 5 | const utils = require("./utils"); 6 | const errors = require("./errors"); 7 | /** 8 | * Client class 9 | */ 10 | class Client { 11 | /** 12 | * @param {string} key API-Key [(?)](https://docs.pixelic.de) 13 | * @param {ClientOptions} [options={}] Client options 14 | */ 15 | constructor(key, options = {}) { 16 | this.key = utils.validateKey(key); 17 | this.options = utils.parseOptions(options); 18 | utils.validateOptions(this.options); 19 | 20 | this.limiter = new Bottleneck({ 21 | reservoir: this.options.ratelimit, 22 | reservoirRefreshAmount: this.options.ratelimit, 23 | reservoirRefreshInterval: 60 * 1000, 24 | id: "PIXELIC-API-LIMITER", 25 | 26 | datastore: this.options.redis.host === undefined ? "local" : "ioredis", 27 | clearDatastore: true, 28 | clientOptions: { 29 | host: this.options.redis.host, 30 | port: this.options.redis.port, 31 | username: this.options.redis.username, 32 | password: this.options.redis.password, 33 | }, 34 | }); 35 | 36 | this.leaderboardLimiter = new Bottleneck({ 37 | reservoir: this.options.leaderboardRateLimit, 38 | reservoirRefreshAmount: this.options.leaderboardRateLimit, 39 | reservoirRefreshInterval: 60 * 1000, 40 | id: "PIXELIC-API-LEADERBOARD-LIMITER", 41 | 42 | datastore: this.options.redis.host === undefined ? "local" : "ioredis", 43 | clearDatastore: true, 44 | clientOptions: { 45 | host: this.options.redis.host, 46 | port: this.options.redis.port, 47 | username: this.options.redis.username, 48 | password: this.options.redis.password, 49 | }, 50 | }); 51 | 52 | this.registerLimiter = new Bottleneck({ 53 | reservoir: this.options.registerRateLimit, 54 | reservoirRefreshAmount: this.options.registerRateLimit, 55 | reservoirRefreshInterval: 5 * 60 * 1000, 56 | id: "PIXELIC-API-REGISTER-LIMITER", 57 | 58 | datastore: this.options.redis.host === undefined ? "local" : "ioredis", 59 | clearDatastore: true, 60 | clientOptions: { 61 | host: this.options.redis.host, 62 | port: this.options.redis.port, 63 | username: this.options.redis.username, 64 | password: this.options.redis.password, 65 | }, 66 | }); 67 | 68 | for (const func in API) { 69 | Client.prototype[func] = function (...args) { 70 | return API[func].apply( 71 | { 72 | makeRequest: this.makeRequest.bind(this), 73 | }, 74 | args 75 | ); 76 | }; 77 | } 78 | 79 | if (this.options.checkForUpdates) { 80 | updater.checkForUpdates(); 81 | } 82 | } 83 | 84 | async makeRequest(url, method, type) { 85 | try { 86 | if (type === "LEADERBOARD") { 87 | return await this.leaderboardLimiter.schedule(async () => { 88 | return await fetch(`${url}?key=${this.key}`, { method: method === undefined ? "GET" : method }); 89 | }); 90 | } 91 | if (type === "REGISTER") { 92 | return await this.registerLimiter.schedule(async () => { 93 | return await fetch(`${url}?key=${this.key}`, { method: method === undefined ? "GET" : method }); 94 | }); 95 | } 96 | if (type === "NON-LIMITED") { 97 | return await fetch(url, { method: method === undefined ? "GET" : method }); 98 | } 99 | return await this.limiter.schedule(async () => { 100 | return await fetch(`${url}?key=${this.key}`, { method: method === undefined ? "GET" : method }); 101 | }); 102 | } catch (error) { 103 | console.error(error); 104 | return new Error(errors.UNEXPECTED_ERROR); 105 | } 106 | } 107 | } 108 | 109 | module.exports = Client; 110 | -------------------------------------------------------------------------------- /src/errors.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | UNEXPECTED_ERROR: "[pixelic-api] Unexpected error!", 3 | INVALID_PIXELIC_API_KEY: "[pixelic-api] Unexpected error!", 4 | OPTIONS_MUST_BE_AN_OBJECT: "[pixelic-api] Client Options must be an Object!", 5 | RATELIMIT_MUST_BE_A_NUMBER: "[pixelic-api] Ratelimit Options must be Numbers!", 6 | CHECK_FOR_UPDATES_MUST_BE_A_BOOLEAN: "[pixelic-api] CheckForUpdates Option must be a Boolean!", 7 | INVALID_UUID_OR_USERNAME: "[pixelic-api] Invalid UUID or Username!", 8 | INVALID_UUID: "[pixelic-api] Invalid UUID!", 9 | INVALID_ISOSTRING: "[pixelic-api] Invalid ISO-String!", 10 | NOT_IN_DATABASE: "[pixelic-api] Player not found in the database!", 11 | GUILD_NOT_IN_DATABASE: "[pixelic-api] Guild not found in the database!", 12 | GUILD_MEMBER_NOT_IN_DATABASE: "[pixelic-api] Guild-Member not found in the database!", 13 | INVALID_GUILDID: "[pixelic-api] Invalid GuildID!", 14 | ALREADY_IN_DATABASE: "[pixelic-api] Player already in the database!", 15 | EMPTY_DATE: "[pixelic-api] No data was found for the specified date!", 16 | RATELIMIT: "[pixelic-api] Ratelimit has been exceeded", 17 | REDIS_HOST_MUST_BE_A_STRING: "[pixelic-api] Redis-Host must be a String!", 18 | REDIS_PORT_MUST_BE_A_NUMBER: "[pixelic-api] Redis-Port must be a Number!", 19 | REDIS_USERNAME_MUST_A_BE_STRING: "[pixelic-api] Redis-Username must be a String!", 20 | REDIS_PASSWORD_MUST_A_BE_STRING: "[pixelic-api] Redis-Password must be a String!", 21 | INVALID_HISTORY_TIMEFRAME: "[pixelic-api] Valid timeframes are : hour, day, week, month, year or alltime!", 22 | INVALID_HISTORY_STAT: "[pixelic-api] Valid Stats are : playersTracked, playersTrackedSkyblock, guildsTracked or auctionsStored!", 23 | INVALID_AH_HISTORY_TIMEFRAME: "[pixelic-api] Valid timeframes are : day, week, month, year or alltime!", 24 | INVALID_SKYBLOCK_ITEM: "[pixelic-api] Invalid Skyblock-Item ID!", 25 | INVALID_BAZAAR_PRODUCT: "[pixelic-api] This Skyblock-Item does not get sold on the Bazaar!", 26 | INVALID_AH_ITEM: "[pixelic-api] This Skyblock-Item is not getting sold on the Auctionhouse currently!", 27 | INVALID_LEADERBOARD_TIMEFRAME: "[pixelic-api] Invalid Leaderboard timeframe!", 28 | INVALID_LEADERBOARD: "[pixelic-api] Invalid Leaderboard!", 29 | INVALID_LEADERBOARD_LIMIT: "[pixelic-api] Invalid Leaderboard limit!", 30 | INVALID_PROFILE_UUID: "[pixelic-api] Invalid Profile UUID!", 31 | INVALID_ITEM_UUID: "[pixelic-api] Invalid Item UUID!", 32 | INVALID_AUCTION_UUID: "[pixelic-api] Invalid Auction UUID!", 33 | INVALID_DISTRIBUTION: "[pixelic-api] Valid distributions are : ranks, plusColor, plusPlusColor, language or chatChannel!", 34 | }; 35 | -------------------------------------------------------------------------------- /src/updater.js: -------------------------------------------------------------------------------- 1 | const fetch = (...args) => import("node-fetch").then(({ default: fetch }) => fetch(...args)); 2 | 3 | class Updater { 4 | checkForUpdates() { 5 | try { 6 | fetch("https://registry.npmjs.org/pixelic-api-wrapper").then(async (packageInfo) => { 7 | const parsedPackageInfo = await packageInfo.json(); 8 | const latestVersion = parsedPackageInfo["dist-tags"].latest; 9 | const currentVersion = require("../package.json").version; 10 | 11 | if (latestVersion !== currentVersion) { 12 | console.log(`[Pixelic-API-Wrapper] An update is available! Current version: ${currentVersion}, Latest version: ${latestVersion}`); 13 | } 14 | }); 15 | } catch (error) {} 16 | } 17 | } 18 | 19 | module.exports = Updater; 20 | -------------------------------------------------------------------------------- /src/utils.js: -------------------------------------------------------------------------------- 1 | const errors = require("./errors"); 2 | 3 | module.exports = { 4 | validateKey: (key) => { 5 | key = key.replace(/-/g, ""); 6 | if (key.length !== 32) return new Error(errors.INVALID_PIXELIC_API_KEY); 7 | if (/[0-9a-f]{12}4[0-9a-f]{19}/.test(key)) return key; 8 | return new Error(errors.INVALID_PIXELIC_API_KEY); 9 | }, 10 | validateUUID: (UUID) => { 11 | UUID = UUID.replace(/-/g, ""); 12 | if (UUID.length !== 32) return false; 13 | if (/[0-9a-f]{12}4[0-9a-f]{19}/.test(UUID)) return true; 14 | return false; 15 | }, 16 | validateUsername: (Username) => /^[a-zA-Z0-9_]{2,16}$/.test(Username), 17 | validateISOString: (DATE) => /^\d{4}\-(0[1-9]|1[012])\-(0[1-9]|[12][0-9]|3[01])$/.test(DATE), 18 | validateGuildID: (guildID) => /^[0-9a-fA-F]{24}$/.test(guildID), 19 | validateSkyblockID: (SKYBLOCK_ID) => /^[A-Z\d\_:]+$/.test(SKYBLOCK_ID), 20 | parseOptions: (options) => { 21 | if (typeof options !== "object" || options === null) throw new Error(errors.OPTIONS_MUST_BE_AN_OBJECT); 22 | return { 23 | ratelimit: options?.ratelimit || 60, 24 | leaderboardRateLimit: options?.leaderboardRateLimit || 10, 25 | registerRateLimit: options?.registerRateLimit || 5, 26 | checkForUpdates: options?.checkForUpdates || true, 27 | redis: { 28 | host: options?.redis?.host, 29 | port: options?.redis?.port, 30 | username: options?.redis?.username, 31 | password: options?.redis?.password, 32 | }, 33 | }; 34 | }, 35 | validateOptions: (options) => { 36 | if (typeof options.ratelimit !== "number") throw new Error(errors.RATELIMIT_MUST_BE_A_NUMBER); 37 | if (typeof options.leaderboardRateLimit !== "number") throw new Error(errors.RATELIMIT_MUST_BE_A_NUMBER); 38 | if (typeof options.registerRateLimit !== "number") throw new Error(errors.RATELIMIT_MUST_BE_A_NUMBER); 39 | if (typeof options.checkForUpdates !== "boolean") throw new Error(errors.CHECK_FOR_UPDATES_MUST_BE_A_BOOLEAN); 40 | if (options.redis.host !== undefined) { 41 | if (typeof options.redis.host !== "string") throw new Error(errors.REDIS_HOST_MUST_BE_A_STRING); 42 | if (typeof options.redis.port !== "number") throw new Error(errors.REDIS_PORT_MUST_BE_A_NUMBER); 43 | if (typeof options.redis.username !== "string") throw new Error(errors.REDIS_USERNAME_MUST_A_BE_STRING); 44 | if (typeof options.redis.password !== "string") throw new Error(errors.REDIS_PASSWORD_MUST_A_BE_STRING); 45 | } 46 | }, 47 | }; 48 | --------------------------------------------------------------------------------