This is a re-release of v2.0.0 that fixes a packaging issue. Original release notes follow:
Please see the v2 Migration Guide for tips and examples for migrating from v1.x.
Breaking Changes
General:
- Bumped minimum supported Node.js version to v22 (target version is v24)
- Earlier versions may still work, but they are not explicitly supported
- Updated package to ESM format, which breaks compatibility with CJS projects
HTTP API:
- Renamed
ScreepsAPIclass toScreepsHttpClient ScreepsHttpClient.fromConfig()parameters have been changed- Server name is now required; it no longer defaults to
'main'to prevent accidental usage of the'main'server - See docblock for other changes
- Server name is now required; it no longer defaults to
- Flattened the endpoint method structure on
ScreepsHttpClient:- Almost every endpoint method has been renamed; see v2 Migration Guide for details
- Added
name: stringparameter toScreepsHttpClient.changeFlagColor() - Added
_id: stringparameter toScreepsHttpClient.gameAddObjectIntent() - Removed
encodedparameter fromScreepsHttpClient.gameRoomTerrain()- To get unencoded results, use
ScreepsHttpClient.gameRoomTerrainUnencoded()
- To get unencoded results, use
- Refactored
ScreepsHttpClient.userCodeSet()request params into an object so they could share types withScreepsHttpClient.userCodeGet()responses - Endpoints that require a shard argument will now throw an error if the argument is not defined and if
ScreepsClientConfig.defaultShardis not defined'shard0'is no longer used as a default to prevent accidental operations on the wrong shard
ScreepsHttpClientnow only fires therateLimitevent when a rate limit is exceeded.experimentalRetry429option:- Renamed this option to
retry429Global - It is now specified as a
ScreepsClientConfigoption instead of being part of the server config - This option is now enabled by default
- Renamed this option to
WebSocket API:
connect()no longer acceptsScreepsSocketConfigoptions- These events are loaded/set in
appConfiglike they are for the HTTP client (see related change in "New Features")
- These events are loaded/set in
resubscribe()no longer subscribes to events that were fully unsubscribed before disconnectingsubscribe()no longer registers duplicate instances of the same callback to the same events- Legacy behavior can be triggered by passing
truefor newforceparam
- Legacy behavior can be triggered by passing
ScreepsHttpClient.setServer()now triggersdisconnect()authed,connected, andreconnectingproperties now have private setterswsandhttpproperties are now protected
CLI:
- Changed error-handling behavior:
- Help is now printed after usage errors (ex: invalid raw command)
- Non-zero exit status is now returned on all errors
- Changed
memoryoutput format:- Nothing is emitted if the Memory path does not exist
- JSON output is serialized before being emitted to stdout to allow the full contents to be inspected
New Features and Improvements
General:
- Added detailed type definitions for most of the API: https://screepers.github.io/node-screeps-api/modules.html
- Added support for
screeps.jsoncredential files: https://screepers.github.io/node-screeps-api/documents/Configuration_and_Credential_Files.html - Linux/*BSD only:
ScreepsConfigManagernow checks for config files in the default$XDG_CONFIG_HOMEdirectory if the env var is not defined - macOS only:
ScreepsConfigManagernow checks$HOME/Library/Application Supportfor config files. - Added
ScreepsClientConfig.defaultShardoption - Added
ScreepsHttpClient.debug()method to enable/disable debug logging: https://screepers.github.io/node-screeps-api/documents/Debugging.html#event-logging
HTTP API:
ScreepsHttpClientnow authenticates automatically as needed- Added
ScreepsHttpClient.userCpuShardsendpoint - Added
ScreepsHttpClient.seasonsCurrentendpoint - Added
ScreepsHttpClient.userActivatePtrendpoint - Added support for automatic retries on HTTP 429 errors due to endpoint-specific rate limits
- See
ScreepsClientConfigoptionsretry429InitDelay,retry429MaxDelay, andretry429MaxRetries
- See
WebSocket API:
ScreepsSocketClientnow authenticates automatically as needed- Added event-specific
subscribe___()/unsubscribe____()methods:- These new variants of
subscribe()/unsubscribe()automatically determine theeventSpecargument and enforce appropriate type constraints on callback arguments - These are equivalent to the endpoint methods on
ScreepsHttpClient
- These new variants of
ScreepsSocketClientoptions can now be loaded from config files
CLI:
- Added
memory --prettyoption to pretty-print output to files or stdout
Fixes
WebSocket API:
- Fixed
ScreepsSocketClientasync bug when trying to process gzipped data - Fixed bug that emitted queued messages as events instead of sending them
CLI:
- Fixed async bug when trying to write memory to disk via
memory -f <file> - Fixed ReferenceError when trying to write a single memory segment to disk via
segment -d <dir> <segmentNumber>
Full Changelog: 8b6ad48...v2.0
Please see the this package's npm versions page for releases between v1.0.0 and v2.0.0: https://www.npmjs.com/package/screeps-api?activeTab=versions