A comprehensive Lua client library for the Krawlet API, designed for CC: Tweaked (Minecraft 1.20.1+)
Run this command on any CC: Tweaked computer:
wget https://krawlet.cc/krawlet.lua /krawlet.lua
Or use wget run for a one-liner install script.
After installing the library, you can use it in any Lua program:
local krawlet = require("krawlet")
-- Check API health
local healthy, status = krawlet.healthCheck()
print("API Status:", status)
-- Get all shops
local shops = krawlet.getShops()
for _, shop in ipairs(shops or {}) do
print(shop.name)
end
-- Find a player by name
local player = krawlet.getPlayerByName("Twijn")
if player then
print("Address:", player.kromerAddress)
end
https://api.krawlet.cc).local krawlet = require("krawlet")
-- Look up a player by name
local player, err = krawlet.getPlayerByName("Twijn")
if player then
print("Player: " .. player.minecraftName)
print("Address: " .. player.kromerAddress)
print("Online: " .. tostring(player.online))
else
print("Error: " .. (err or "Player not found"))
end
local krawlet = require("krawlet")
-- Find the best prices for diamonds
local deals = krawlet.findBestPrices("diamond", "KRO", 5)
if deals then
print("Best diamond prices:")
for i, deal in ipairs(deals) do
local shopName = deal.shop and deal.shop.name or "Unknown Shop"
print(string.format("%d. %s - %s KRO (stock: %d)",
i, shopName, krawlet.formatKromer(deal.price), deal.stock or 0))
end
end
-- Find where to sell iron ingots
local sellDeals = krawlet.findBestSellPrices("iron_ingot")
if sellDeals and #sellDeals > 0 then
local best = sellDeals[1]
print("Best place to sell iron: " .. (best.shop and best.shop.name or "Unknown"))
print("Price: " .. krawlet.formatKromer(best.price))
end
local krawlet = require("krawlet")
-- Redeem a quick code from \krawlet api chat command
local result, err = krawlet.redeemQuickCode("123456")
if result then
print("API Key received!")
print("Tier: " .. result.tier)
print("Rate Limit: " .. result.rateLimit .. " requests/hour")
-- The API key is automatically set on success
-- Save it to a file for future use:
local f = fs.open("/.krawlet_key", "w")
f.write(result.apiKey)
f.close()
else
print("Error: " .. (err or "Failed to redeem code"))
end
-- shop_finder.lua
-- A program to find the best prices for items
local krawlet = require("krawlet")
-- Load saved API key if exists
if fs.exists("/.krawlet_key") then
local f = fs.open("/.krawlet_key", "r")
krawlet.setApiKey(f.readAll())
f.close()
end
-- Main program
print("=== Krawlet Shop Finder ===")
print()
while true do
write("Search for item (or 'quit'): ")
local query = read()
if query == "quit" or query == "exit" then
break
end
print("Searching...")
local deals = krawlet.findBestPrices(query, "KRO", 5)
if not deals or #deals == 0 then
print("No results found for '" .. query .. "'")
else
print()
print("Top 5 deals for '" .. query .. "':")
print(string.rep("-", 50))
for i, deal in ipairs(deals) do
local name = deal.item.itemDisplayName or deal.item.itemName
local shopName = deal.shop and deal.shop.name or "Unknown"
local location = deal.shop and deal.shop.locationDescription or "Unknown location"
print(string.format("%d. %s", i, name))
print(string.format(" Shop: %s", shopName))
print(string.format(" Price: %s", krawlet.formatKromer(deal.price)))
print(string.format(" Stock: %d", deal.stock or 0))
print(string.format(" Location: %s", location))
print()
end
end
-- Show rate limit info
local rl = krawlet.getRateLimit()
if rl then
print(string.format("Rate limit: %d/%d remaining", rl.remaining, rl.limit))
end
print()
end
print("Goodbye!")