mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-18 07:18:38 +02:00
DOC: Move all docs into en/ subdirectory (#1505)
* DOC: Move all docs into en/ subdirectory PR #1502 is working on adding a Chinese translation to the docs. In general, I encouraged this (in #1452) as a path towards getting useful translated content in the game without requiring a massive refactor/rearchitecting of everything. To support this, this takes the first step of moving our docs into an en/ subdirectory, so that other languages can live alongside. No effort is made at this time to support or select between alternate languages; this is a pure-rename refactor.
This commit is contained in:
174
src/Documentation/doc/en/programming/remote_api.md
Normal file
174
src/Documentation/doc/en/programming/remote_api.md
Normal file
@@ -0,0 +1,174 @@
|
||||
# Remote API
|
||||
|
||||
All versions of Bitburner can use websockets to connect to a server.
|
||||
That server can then perform a number of actions.
|
||||
Most commonly this is used in conjunction with an external text editor or API
|
||||
in order to make writing scripts easier, or even use typescript.
|
||||
|
||||
To make use of this Remote API through the official server, look [here](https://github.com/bitburner-official/typescript-template).
|
||||
If you want to make your own server, see below for API details.
|
||||
|
||||
This API uses the JSON RPC 2.0 protocol. Inputs are in the following form:
|
||||
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": number,
|
||||
"method": string,
|
||||
"params": any
|
||||
}
|
||||
|
||||
Outputs:
|
||||
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": number,
|
||||
"result": any,
|
||||
"error": any
|
||||
}
|
||||
|
||||
## Methods
|
||||
|
||||
## `pushFile`
|
||||
|
||||
Create or update a file.
|
||||
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": number,
|
||||
"method": "pushFile",
|
||||
"params": {
|
||||
filename: string;
|
||||
content: string;
|
||||
server: string;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": number,
|
||||
"result": "OK"
|
||||
}
|
||||
|
||||
## `getFile`
|
||||
|
||||
Read a file and its content.
|
||||
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": number,
|
||||
"method": "getFile",
|
||||
"params": {
|
||||
filename: string;
|
||||
server: string;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": number,
|
||||
"result": string
|
||||
}
|
||||
|
||||
## `deleteFile`
|
||||
|
||||
Delete a file.
|
||||
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": number,
|
||||
"method": "deleteFile",
|
||||
"params": {
|
||||
filename: string;
|
||||
server: string;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": number,
|
||||
"result": "OK"
|
||||
}
|
||||
|
||||
## `getFileNames`
|
||||
|
||||
List all file names on a server.
|
||||
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": number,
|
||||
"method": "getFileNames",
|
||||
"params": {
|
||||
server: string;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": number,
|
||||
"result": string[]
|
||||
}
|
||||
|
||||
## `getAllFiles`
|
||||
|
||||
Get the content of all files on a server.
|
||||
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": number,
|
||||
"method": "getAllFiles",
|
||||
"params": {
|
||||
server: string;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": number,
|
||||
"result": {
|
||||
filename: string,
|
||||
content: string
|
||||
}[]
|
||||
}
|
||||
|
||||
## `calculateRam`
|
||||
|
||||
Calculate the in-game ram cost of a script.
|
||||
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": number,
|
||||
"method": "calculateRam",
|
||||
"params": {
|
||||
filename: string;
|
||||
server: string;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": number,
|
||||
"result": number
|
||||
}
|
||||
|
||||
## `getDefinitionFile`
|
||||
|
||||
Get the definition file of the API.
|
||||
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": number,
|
||||
"method": "getDefinitionFile"
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
"jsonrpc": "2.0",
|
||||
"id": number,
|
||||
"result": string
|
||||
}
|
||||
Reference in New Issue
Block a user