{"_id":"@admon-dev/screeps-api","name":"@admon-dev/screeps-api","dist-tags":{"latest":"1.16.2"},"versions":{"1.16.2":{"name":"@admon-dev/screeps-api","version":"1.16.2","description":"## This is a nodejs API for the game Screeps","repository":{"type":"git","url":"git+https://github.com/admon84/node-screeps-api.git"},"main":"dist/ScreepsAPI.js","module":"src/index.js","scripts":{"build":"rollup -c","prepublishOnly":"npm run build","lint":"standard src/**/*.js","lint-fix":"standard src/**/*.js --fix","test_":"mocha","test":"echo Tests disabled, TODO: FIX THIS!","2npm":"publish-if-not-published"},"author":{"name":"Adam Shumann"},"license":"ISC","bin":{"screeps-api":"bin/screeps-api.js"},"dependencies":{"axios":"^1.15.0","commander":"^7.2.0","debug":"^4.1.1","ws":"^8.20.0","yamljs":"^0.3.0"},"optionalDependencies":{"bufferutil":"^4.0.1","utf-8-validate":"^5.0.2"},"devDependencies":{"lodash":"^4.18.1","mocha":"^11.7.5","publish-if-not-published":"^2.0.0","rollup":"^4.60.1","rollup-plugin-typescript2":"^0.36.0","standard":"^17.1.2","tslib":"^2.2.0","typescript":"^4.2.4"},"browser":{"ws":"./src/ws-browser.js"},"overrides":{"diff":"^8.0.4","serialize-javascript":"^7.0.5"},"types":"dist/types/index.d.ts","_id":"@admon-dev/screeps-api@1.16.2","gitHead":"d8e55d3f4474c0b7a25ff40872d0c52a227520ed","bugs":{"url":"https://github.com/admon84/node-screeps-api/issues"},"homepage":"https://github.com/admon84/node-screeps-api#readme","_nodeVersion":"20.19.3","_npmVersion":"10.8.2","dist":{"integrity":"sha512-Fnpo4w53LN/oer5o3Fj3+BbKZxZ/nw0Q8m/vUaHZjRxBrwItNMsqCyPzRiM0HlvfyLwMwvTjQCb6pDLB3gFY1g==","shasum":"36eb0275ec78e07b65ea45cbe40c2ff239dd14b2","tarball":"https://registry.npmjs.org/@admon-dev/screeps-api/-/screeps-api-1.16.2.tgz","fileCount":26,"unpackedSize":115514,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCJcEHZ5mAxpZooq927ia/GgyKBhoh6yJy9ziAslhKWTAIhANzPJUxRej8UXclziIJ6bPfdtgGM8eMxrumILD8r2qf4"}]},"_npmUser":{"name":"admon84","email":"admonwest84@gmail.com"},"directories":{},"maintainers":[{"name":"admon84","email":"admonwest84@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/screeps-api_1.16.2_1776054465520_0.2886123987452043"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-13T04:27:45.401Z","1.16.2":"2026-04-13T04:27:45.652Z","modified":"2026-04-13T04:27:45.901Z"},"maintainers":[{"name":"admon84","email":"admonwest84@gmail.com"}],"description":"## This is a nodejs API for the game Screeps","homepage":"https://github.com/admon84/node-screeps-api#readme","repository":{"type":"git","url":"git+https://github.com/admon84/node-screeps-api.git"},"author":{"name":"Adam Shumann"},"bugs":{"url":"https://github.com/admon84/node-screeps-api/issues"},"license":"ISC","readme":"# Screeps API\n\n## This is a nodejs API for the game Screeps\n\n[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)\n[![License](https://img.shields.io/npm/l/screeps-api.svg)](https://npmjs.com/package/screeps-api)\n[![Version](https://img.shields.io/npm/v/screeps-api.svg)](https://npmjs.com/package/screeps-api)\n[![Downloads](https://img.shields.io/npm/dw/screeps-api.svg)](https://npmjs.com/package/screeps-api)\n[![CircleCI](https://circleci.com/gh/screepers/node-screeps-api/tree/master.svg?style=shield)](https://circleci.com/gh/screepers/node-screeps-api/tree/master)\n\n![npm](https://nodei.co/npm/screeps-api.png \"NPM\")\n\n## Notice on authentication\n\nAs of 12/29/2017 Screeps now uses auth tokens obtained via your screeps account settings. \nUser/pass auth will stop working February 1, 2018!\n[Screeps Announcement](http://blog.screeps.com/2017/12/auth-tokens/)\n\n## CLI Usage\n\nAs of 1.7.0, a small CLI program (`screeps-api`) is included. \n\nServer config is specified via a `.screeps.yml` file conforming to the [Unified Credentials File format](https://github.com/screepers/screepers-standards/blob/master/SS3-Unified_Credentials_File.md)\n\n```\nscreeps-api\n\n  Usage:  [options] [command]\n\n  Options:\n\n    -V, --version                output the version number\n    --server <server>            Server config to use (default: main)\n    -h, --help                   output usage information\n\n  Commands:\n\n    raw <cmd> [args...]          Execute raw API call\n    memory [options] [path]      Get Memory contents\n    segment [options] <segment>  Get segment contents. Use 'all' to get all)\n    download [options]           Download code\n    upload [options] <files...>  Upload code\n\n```\n\n\n## API Usage\n\nAs of 1.0, all functions return Promises\n\n```javascript\nconst { ScreepsAPI } = require('screeps-api');\nconst fs = require('fs');\n\n// Supports @tedivm's [Unified Credentials File format](https://github.com/screepers/screepers-standards/blob/34bd4e6e5c8250fa0794d915d9f78d3c45326076/SS3-Unified_Credentials_File.md) (Pending [screepers-standard PR #8](https://github.com/screepers/screepers-standards/pull/8))\nconst api = await ScreepsAPI.fromConfig('main', 'appName')\n// This loads the server config 'main' and the configs section 'appName' if it exists\n// config section can be accessed like this:\n// If making a CLI app, its suggested to have a `--server` argument for selection\nconsole.log(api.appConfig.myConfigVar)\n\n// All options are optional\nconst api = new ScreepsAPI({\n  token: 'Your Token from Account/Auth Tokens'\n  protocol: 'https',\n  hostname: 'screeps.com',\n  port: 443,\n  path: '/' // Do no include '/api', it will be added automatically\n});\n\n// You can overwrite parameters if needed\napi.auth('screeps@email.com','notMyPass',{\n  protocol: 'https',\n  hostname: 'screeps.com',\n  port: 443,\n  path: '/' // Do no include '/api', it will be added automatically\n})\n\n// If you want to point to the screeps PTR (Public Test Realm),\n// you can set the 'path' option to '/ptr' and it will work fine.\n\n// Dump Memory\napi.memory.get()\n  .then(memory => {\n    fs.writeFileSync('memory.json', JSON.stringify(memory))\n  })\n  .catch(err => console.error(err));\n\n\n// Dump Memory Path\napi.memory.get('rooms.W0N0')\n  .then(memory => {\n    fs.writeFileSync('memory.rooms.W0N0.json', JSON.stringify(memory))\n  })\n  .catch(err => console.error(err));\n\n// Get user info\napi.me().then((user)=>console.log(user))\n\n// Socket API\n\napi.socket.connect()\n// Events have the structure of:\n// {\n//   channel: 'room',\n//   id: 'E3N3', // Only on certain events\n//   data: { ... }\n// }\napi.socket.on('connected',()=>{\n\t// Do stuff after connected\n})\napi.socket.on('auth',(event)=>{\n\tevent.data.status contains either 'ok' or 'failed'\n\t// Do stuff after auth\n})\n\n// Events: (Not a complete list)\n// connected disconnected message auth time protocol package subscribe unsubscribe console\n\n// Subscribtions can be queued even before the socket connects or auths,\n// although you may want to subscribe from the connected or auth callback to better handle reconnects\n\napi.socket.subscribe('console')\napi.socket.on('console',(event)=>{\n\tevent.data.messages.log // List of console.log output for tick\n})\n\n\n// Starting in 1.0, you can also pass a handler straight to subscribe!\napi.socket.subscribe('console', (event)=>{\n\tevent.data.messages.log // List of console.log output for tick\n})\n\n// More common examples\napi.socket.subscribe('cpu',(event)=>console.log('cpu',event.data))\napi.code.get('default').then(data=>console.log('code',data))\napi.code.set('default',{\n\tmain: 'module.exports.loop = function(){ ... }'\n})\napi.socket.subscribe('memory/stats',(event)=>{\n\tconsole.log('stats',event.data)\n})\napi.socket.subscribe('memory/rooms.E0N0',(event)=>{\n\tconsole.log('E0N0 Memory',event.data)\n})\n```\n\n## Endpoint documentation\n\nServer endpoints are listed in the `docs` folder:\n * [Endpoints.md](/docs/Endpoints.md) for direct access\n * [Websocket_endpoints.md](/docs/Websocket_endpoints.md) for web socket endpoints\nThose lists are currently not exhaustive.\n","readmeFilename":"README.md","_rev":"1-6f77002d4111461778cc3e0b3e47ef3f"}