node-screeps-api uses the debug package to expose diagnostic information. Debug output is divided into several namespaces:
screepsapi:config: ScreepsConfigManager operationsscreepsapi:http: HTTP requestsscreepsapi.ratelimit: HTTP API rate limit statescreepsapi.ratelimitexceeded: HTTP API endpoint rate limit exceeded eventsscreepsapi.socket: WebSocket API events/messagesMultiple namespaces can be specified by providing a comma-delimited list (ex: screepsapi:http,screepsapi:ratelimit). All namespaces can be specified by providing screepsapi:*.
To enable debug output in Node, set the DEBUG environment variable to the
namespace(s) you want to enable. Here is an example that uses the CLI in bash:
DEBUG=screepsapi.http,screepsapi.ratelimit screeps-api raw --server main auth.me
These environment variables work when invoking your own apps as well.
You can also enable/disable debug logs dynamically using ScreepsHttpClient.debug():
const api = ScreepsHttpClient.fromConfig('main', 'appName')
// Enable debug logging for HTTP requests and rate limits:
api.debug({ http: true, rateLimit: true })
// Diable all debug logging
api.debug()
Most errors thrown by the HTTP API should be instances of ScreepsApiError. These errors include HTTP request/response fields that may be helpful.