<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [NS](./bitburner.ns.md)

## NS interface

Collection of all functions passed to scripts

**Signature:**

```typescript
export interface NS 
```

## Remarks

<b>Basic usage example:</b>

```js
export async function main(ns) {
 // Basic ns functions can be accessed on the ns object
 ns.getHostname();
 // Some related functions are gathered under a sub-property of the ns object
 ns.stock.getPrice();
 // Most functions that return a promise need to be awaited.
 await ns.hack('n00dles');
}
```

## Properties

<table><thead><tr><th>

Property


</th><th>

Modifiers


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

[args](./bitburner.ns.args.md)


</td><td>

`readonly`


</td><td>

[ScriptArg](./bitburner.scriptarg.md)<!-- -->\[\]


</td><td>

Arguments passed into the script.

These arguments can be accessed as a normal array by using the `[]` operator (`args[0]`<!-- -->, `args[1]`<!-- -->, etc...). Arguments can be string, number, or boolean. Use `args.length` to get the number of arguments that were passed into a script.


</td></tr>
<tr><td>

[bladeburner](./bitburner.ns.bladeburner.md)


</td><td>

`readonly`


</td><td>

[Bladeburner](./bitburner.bladeburner.md)


</td><td>

Namespace for [Bladeburner](./bitburner.bladeburner.md) functions. Contains spoilers.


</td></tr>
<tr><td>

[cloud](./bitburner.ns.cloud.md)


</td><td>

`readonly`


</td><td>

[Cloud](./bitburner.cloud.md)


</td><td>

Namespace for [cloud](./bitburner.cloud.md) functions.


</td></tr>
<tr><td>

[codingcontract](./bitburner.ns.codingcontract.md)


</td><td>

`readonly`


</td><td>

[CodingContract](./bitburner.codingcontract.md)


</td><td>

Namespace for [coding contract](./bitburner.codingcontract.md) functions.


</td></tr>
<tr><td>

[corporation](./bitburner.ns.corporation.md)


</td><td>

`readonly`


</td><td>

[Corporation](./bitburner.corporation.md)


</td><td>

Namespace for [corporation](./bitburner.corporation.md) functions. Contains spoilers.


</td></tr>
<tr><td>

[dnet](./bitburner.ns.dnet.md)


</td><td>

`readonly`


</td><td>

[Darknet](./bitburner.darknet.md)


</td><td>

Namespace for darknet functions. Contains spoilers.


</td></tr>
<tr><td>

[enums](./bitburner.ns.enums.md)


</td><td>


</td><td>

[NSEnums](./bitburner.nsenums.md)


</td><td>


</td></tr>
<tr><td>

[format](./bitburner.ns.format.md)


</td><td>

`readonly`


</td><td>

[Format](./bitburner.format.md)


</td><td>

Namespace for [formatting](./bitburner.format.md) functions.


</td></tr>
<tr><td>

[formulas](./bitburner.ns.formulas.md)


</td><td>

`readonly`


</td><td>

[Formulas](./bitburner.formulas.md)


</td><td>

Namespace for [formulas](./bitburner.formulas.md) functions.


</td></tr>
<tr><td>

[gang](./bitburner.ns.gang.md)


</td><td>

`readonly`


</td><td>

[Gang](./bitburner.gang.md)


</td><td>

Namespace for [gang](./bitburner.gang.md) functions. Contains spoilers.


</td></tr>
<tr><td>

[go](./bitburner.ns.go.md)


</td><td>

`readonly`


</td><td>

[Go](./bitburner.go.md)


</td><td>

Namespace for [Go](./bitburner.go.md) functions.


</td></tr>
<tr><td>

[grafting](./bitburner.ns.grafting.md)


</td><td>

`readonly`


</td><td>

[Grafting](./bitburner.grafting.md)


</td><td>

Namespace for [grafting](./bitburner.grafting.md) functions. Contains spoilers.


</td></tr>
<tr><td>

[hacknet](./bitburner.ns.hacknet.md)


</td><td>

`readonly`


</td><td>

[Hacknet](./bitburner.hacknet.md)


</td><td>

Namespace for [hacknet](./bitburner.hacknet.md) functions. Some of this API contains spoilers.


</td></tr>
<tr><td>

[heart](./bitburner.ns.heart.md)


</td><td>

`readonly`


</td><td>

{ break(): number; }


</td><td>


</td></tr>
<tr><td>

[infiltration](./bitburner.ns.infiltration.md)


</td><td>

`readonly`


</td><td>

[Infiltration](./bitburner.infiltration.md)


</td><td>

Namespace for [infiltration](./bitburner.infiltration.md) functions.


</td></tr>
<tr><td>

[pid](./bitburner.ns.pid.md)


</td><td>

`readonly`


</td><td>

number


</td><td>

The current script's PID


</td></tr>
<tr><td>

[singularity](./bitburner.ns.singularity.md)


</td><td>

`readonly`


</td><td>

[Singularity](./bitburner.singularity.md)


</td><td>

Namespace for [singularity](./bitburner.singularity.md) functions. Contains spoilers.


</td></tr>
<tr><td>

[sleeve](./bitburner.ns.sleeve.md)


</td><td>

`readonly`


</td><td>

[Sleeve](./bitburner.sleeve.md)


</td><td>

Namespace for [sleeve](./bitburner.sleeve.md) functions. Contains spoilers.


</td></tr>
<tr><td>

[stanek](./bitburner.ns.stanek.md)


</td><td>

`readonly`


</td><td>

[Stanek](./bitburner.stanek.md)


</td><td>

Namespace for [Stanek](./bitburner.stanek.md) functions. Contains spoilers.


</td></tr>
<tr><td>

[stock](./bitburner.ns.stock.md)


</td><td>

`readonly`


</td><td>

[Stock](./bitburner.stock.md)


</td><td>

Namespace for [stock](./bitburner.stock.md) functions.


</td></tr>
<tr><td>

[ui](./bitburner.ns.ui.md)


</td><td>

`readonly`


</td><td>

[UserInterface](./bitburner.userinterface.md)


</td><td>

Namespace for [user interface](./bitburner.userinterface.md) functions.


</td></tr>
</tbody></table>

## Methods

<table><thead><tr><th>

Method


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

[alert(args)](./bitburner.ns.alert.md)


</td><td>

Open up a message box.


</td></tr>
<tr><td>

[asleep(millis)](./bitburner.ns.asleep.md)


</td><td>

Suspends the script for n milliseconds. Doesn't block with concurrent calls.


</td></tr>
<tr><td>

[atExit(f, id)](./bitburner.ns.atexit.md)


</td><td>

Add a callback to be executed when the script dies.


</td></tr>
<tr><td>

[brutessh(host)](./bitburner.ns.brutessh.md)


</td><td>

Runs BruteSSH.exe on a server.


</td></tr>
<tr><td>

[clear(handle)](./bitburner.ns.clear.md)


</td><td>

Clear data from a file.


</td></tr>
<tr><td>

[clearLog()](./bitburner.ns.clearlog.md)


</td><td>

Clears the script’s logs.


</td></tr>
<tr><td>

[clearPort(portNumber)](./bitburner.ns.clearport.md)


</td><td>

Clear data from a port.


</td></tr>
<tr><td>

[disableLog(fn)](./bitburner.ns.disablelog.md)


</td><td>

Disables logging for the given NS function.


</td></tr>
<tr><td>

[dnsLookup(host)](./bitburner.ns.dnslookup.md)


</td><td>

Given a hostname, returns its IP address; or given an IP address, returns its hostname.


</td></tr>
<tr><td>

[dynamicImport(path)](./bitburner.ns.dynamicimport.md)


</td><td>

Dynamically import a script. Only scripts located on the same server can be imported. A dynamic import will not adjust RAM usage. This must be done manually with [ramOverride](./bitburner.ns.ramoverride.md)<!-- -->.


</td></tr>
<tr><td>

[enableLog(fn)](./bitburner.ns.enablelog.md)


</td><td>

Enables logging for the given NS function.


</td></tr>
<tr><td>

[exec(script, host, threadOrOptions, args)](./bitburner.ns.exec.md)


</td><td>

Start another script on any server.


</td></tr>
<tr><td>

[exit()](./bitburner.ns.exit.md)


</td><td>

Terminates the current script immediately.


</td></tr>
<tr><td>

[fileExists(filename, host)](./bitburner.ns.fileexists.md)


</td><td>

Check if a file exists.


</td></tr>
<tr><td>

[flags(schema)](./bitburner.ns.flags.md)


</td><td>

Parse command line flags.


</td></tr>
<tr><td>

[ftpcrack(host)](./bitburner.ns.ftpcrack.md)


</td><td>

Runs FTPCrack.exe on a server.


</td></tr>
<tr><td>

[getBitNodeMultipliers(n, lvl)](./bitburner.ns.getbitnodemultipliers.md)


</td><td>

Get the current BitNode multipliers.


</td></tr>
<tr><td>

[getFavorToDonate()](./bitburner.ns.getfavortodonate.md)


</td><td>

Returns the amount of Faction favor required to be able to donate to a faction.


</td></tr>
<tr><td>

[getFileMetadata(filename)](./bitburner.ns.getfilemetadata.md)


</td><td>

Get the metadata of a file.


</td></tr>
<tr><td>

[getFunctionRamCost(name)](./bitburner.ns.getfunctionramcost.md)


</td><td>

Get the RAM cost of a netscript function.

The base RAM cost per script thread can also be retrieved by using `"baseCost"` as argument to this function.


</td></tr>
<tr><td>

[getGrowTime(host)](./bitburner.ns.getgrowtime.md)


</td><td>

Get the execution time of a grow() call.


</td></tr>
<tr><td>

[getHackingLevel()](./bitburner.ns.gethackinglevel.md)


</td><td>

Returns the player’s current hacking level.


</td></tr>
<tr><td>

[getHackingMultipliers()](./bitburner.ns.gethackingmultipliers.md)


</td><td>

Get hacking related multipliers.


</td></tr>
<tr><td>

[getHacknetMultipliers()](./bitburner.ns.gethacknetmultipliers.md)


</td><td>

Get hacknet related multipliers.


</td></tr>
<tr><td>

[getHackTime(host)](./bitburner.ns.gethacktime.md)


</td><td>

Get the execution time of a hack() call.


</td></tr>
<tr><td>

[getHostname()](./bitburner.ns.gethostname.md)


</td><td>

Returns a string with the hostname of the server that the script is running on.


</td></tr>
<tr><td>

[getIP()](./bitburner.ns.getip.md)


</td><td>

Returns a string with the IP address of the server that the script is running on.


</td></tr>
<tr><td>

[getMoneySources()](./bitburner.ns.getmoneysources.md)


</td><td>

Get information about the sources of income for this run.


</td></tr>
<tr><td>

[getPlayer()](./bitburner.ns.getplayer.md)


</td><td>

Get information about the player.


</td></tr>
<tr><td>

[getPortHandle(portNumber)](./bitburner.ns.getporthandle.md)


</td><td>

Get all data on a port.


</td></tr>
<tr><td>

[getRecentScripts()](./bitburner.ns.getrecentscripts.md)


</td><td>

Get an array of recently killed scripts across all servers.


</td></tr>
<tr><td>

[getResetInfo()](./bitburner.ns.getresetinfo.md)


</td><td>

Get information about resets.


</td></tr>
<tr><td>

[getRunningScript(filename, host, args)](./bitburner.ns.getrunningscript.md)


</td><td>

Get general info about a running script.


</td></tr>
<tr><td>

[getScriptExpGain(script, host, args)](./bitburner.ns.getscriptexpgain.md)


</td><td>

Get the exp gain of a script.


</td></tr>
<tr><td>

[getScriptIncome(script, host, args)](./bitburner.ns.getscriptincome.md)


</td><td>

Get the income of a script.


</td></tr>
<tr><td>

[getScriptLogs(fn, host, args)](./bitburner.ns.getscriptlogs.md)


</td><td>

Get all the logs of a script.


</td></tr>
<tr><td>

[getScriptName()](./bitburner.ns.getscriptname.md)


</td><td>

Returns the current script name.


</td></tr>
<tr><td>

[getScriptRam(script, host)](./bitburner.ns.getscriptram.md)


</td><td>

Get the ram cost of a script.


</td></tr>
<tr><td>

[getServer(host)](./bitburner.ns.getserver.md)


</td><td>

Returns data of a server.

If the server is a darknet server, it will also contain the "isOnline" field. If the darknet server has recently gone offline, the returned object will be a dummy server object with `isOnline: false`<!-- -->.


</td></tr>
<tr><td>

[getServerBaseSecurityLevel(host)](./bitburner.ns.getserverbasesecuritylevel.md)


</td><td>

Get the base security level of a server.


</td></tr>
<tr><td>

[getServerGrowth(host)](./bitburner.ns.getservergrowth.md)


</td><td>

Get a server growth parameter.


</td></tr>
<tr><td>

[getServerMaxMoney(host)](./bitburner.ns.getservermaxmoney.md)


</td><td>

Get the maximum money available on a server.


</td></tr>
<tr><td>

[getServerMaxRam(host)](./bitburner.ns.getservermaxram.md)


</td><td>

Get the maximum amount of RAM on a server.


</td></tr>
<tr><td>

[getServerMinSecurityLevel(host)](./bitburner.ns.getserverminsecuritylevel.md)


</td><td>

Returns the minimum security level of the target server.


</td></tr>
<tr><td>

[getServerMoneyAvailable(host)](./bitburner.ns.getservermoneyavailable.md)


</td><td>

Get money available on a server.


</td></tr>
<tr><td>

[getServerNumPortsRequired(host)](./bitburner.ns.getservernumportsrequired.md)


</td><td>

Returns the number of open ports required to successfully run NUKE.exe on the specified server.


</td></tr>
<tr><td>

[getServerRequiredHackingLevel(host)](./bitburner.ns.getserverrequiredhackinglevel.md)


</td><td>

Returns the required hacking level of the target server.


</td></tr>
<tr><td>

[getServerSecurityLevel(host)](./bitburner.ns.getserversecuritylevel.md)


</td><td>

Get server security level.


</td></tr>
<tr><td>

[getServerUsedRam(host)](./bitburner.ns.getserverusedram.md)


</td><td>

Get the used RAM on a server. This includes ram used by running scripts as well as blocked ram on darknet servers.


</td></tr>
<tr><td>

[getSharePower()](./bitburner.ns.getsharepower.md)


</td><td>

Share power has a multiplicative effect on rep/second while doing hacking work for a faction. If you do non-hacking work, share power still increases the reputation gain rate, but the effect is non-linear.

Share power increases incrementally for every thread of share running on your server network, but at a sharply decreasing rate.


</td></tr>
<tr><td>

[getTotalScriptExpGain()](./bitburner.ns.gettotalscriptexpgain.md)


</td><td>

Get the exp gain of all scripts.


</td></tr>
<tr><td>

[getTotalScriptIncome()](./bitburner.ns.gettotalscriptincome.md)


</td><td>

Get the income of all scripts.


</td></tr>
<tr><td>

[getWeakenTime(host)](./bitburner.ns.getweakentime.md)


</td><td>

Get the execution time of a weaken() call.


</td></tr>
<tr><td>

[grow(host, opts)](./bitburner.ns.grow.md)


</td><td>

Spoof money in a server's bank account, increasing the amount available.


</td></tr>
<tr><td>

[growthAnalyze(host, multiplier, cores)](./bitburner.ns.growthanalyze.md)


</td><td>

Calculate the number of grow threads needed for a given multiplicative growth factor.


</td></tr>
<tr><td>

[growthAnalyzeSecurity(threads, host, cores)](./bitburner.ns.growthanalyzesecurity.md)


</td><td>

Calculate the security increase for a number of grow threads.


</td></tr>
<tr><td>

[hack(host, opts)](./bitburner.ns.hack.md)


</td><td>

Steal a server's money.


</td></tr>
<tr><td>

[hackAnalyze(host)](./bitburner.ns.hackanalyze.md)


</td><td>

Get the part of money stolen with a single thread.


</td></tr>
<tr><td>

[hackAnalyzeChance(host)](./bitburner.ns.hackanalyzechance.md)


</td><td>

Get the chance of successfully hacking a server.


</td></tr>
<tr><td>

[hackAnalyzeSecurity(threads, host)](./bitburner.ns.hackanalyzesecurity.md)


</td><td>

Get the security increase for a number of threads.


</td></tr>
<tr><td>

[hackAnalyzeThreads(host, hackAmount)](./bitburner.ns.hackanalyzethreads.md)


</td><td>

Calculate the decimal number of threads needed to hack a specified amount of money from a target host.


</td></tr>
<tr><td>

[hasRootAccess(host)](./bitburner.ns.hasrootaccess.md)


</td><td>

Check if you have root access on a server.


</td></tr>
<tr><td>

[hasTorRouter()](./bitburner.ns.hastorrouter.md)


</td><td>

Returns whether the player has access to the darkweb.


</td></tr>
<tr><td>

[httpworm(host)](./bitburner.ns.httpworm.md)


</td><td>

Runs HTTPWorm.exe on a server.


</td></tr>
<tr><td>

[isLogEnabled(fn)](./bitburner.ns.islogenabled.md)


</td><td>

Checks the status of the logging for the given NS function.


</td></tr>
<tr><td>

[isRunning(script, host, args)](./bitburner.ns.isrunning.md)


</td><td>

Check if a script is running.


</td></tr>
<tr><td>

[kill(pid)](./bitburner.ns.kill.md)


</td><td>

Terminate the script with the provided PID.


</td></tr>
<tr><td>

[kill(filename, host, args)](./bitburner.ns.kill_1.md)


</td><td>

Terminate the script(s) with the provided filename, host, and script arguments.


</td></tr>
<tr><td>

[killall(host, safetyGuard)](./bitburner.ns.killall.md)


</td><td>

Terminate all scripts on a server.


</td></tr>
<tr><td>

[ls(host, substring)](./bitburner.ns.ls.md)


</td><td>

List files on a server.


</td></tr>
<tr><td>

[mv(host, source, destination)](./bitburner.ns.mv.md)


</td><td>

Move a file on the target server.


</td></tr>
<tr><td>

[nextPortWrite(port)](./bitburner.ns.nextportwrite.md)


</td><td>

Listen for a port write.


</td></tr>
<tr><td>

[nuke(host)](./bitburner.ns.nuke.md)


</td><td>

Runs NUKE.exe on a server.


</td></tr>
<tr><td>

[peek(portNumber)](./bitburner.ns.peek.md)


</td><td>

Get a copy of the data from a port without popping it.


</td></tr>
<tr><td>

[print(args)](./bitburner.ns.print.md)


</td><td>

Prints one or more values or variables to the script’s logs.


</td></tr>
<tr><td>

[printf(format, args)](./bitburner.ns.printf.md)


</td><td>

Prints a formatted string to the script’s logs.


</td></tr>
<tr><td>

[printRaw(node)](./bitburner.ns.printraw.md)


</td><td>

Prints a ReactNode to the script logs.


</td></tr>
<tr><td>

[prompt(txt, options)](./bitburner.ns.prompt.md)


</td><td>

Prompt the player with an input modal.


</td></tr>
<tr><td>

[ps(host)](./bitburner.ns.ps.md)


</td><td>

List running scripts on a server.


</td></tr>
<tr><td>

[ramOverride(ram)](./bitburner.ns.ramoverride.md)


</td><td>

Change the current static RAM allocation of the script.


</td></tr>
<tr><td>

[read(filename)](./bitburner.ns.read.md)


</td><td>

Read content of a file.


</td></tr>
<tr><td>

[readPort(portNumber)](./bitburner.ns.readport.md)


</td><td>

Read data from a port.


</td></tr>
<tr><td>

[relaysmtp(host)](./bitburner.ns.relaysmtp.md)


</td><td>

Runs relaySMTP.exe on a server.


</td></tr>
<tr><td>

[rm(name, host)](./bitburner.ns.rm.md)


</td><td>

Delete a file.


</td></tr>
<tr><td>

[run(script, threadOrOptions, args)](./bitburner.ns.run.md)


</td><td>

Start another script on the current server.


</td></tr>
<tr><td>

[scan(host, returnOpts)](./bitburner.ns.scan.md)


</td><td>

Get the list of hostnames or IP addresses connected to a server. This function does not return darknet servers (e.g., darkweb). Use [probe](./bitburner.darknet.probe.md) if you want to list darknet servers.


</td></tr>
<tr><td>

[scp(files, destination, source)](./bitburner.ns.scp.md)


</td><td>

Copy file between servers.


</td></tr>
<tr><td>

[scriptKill(script, host)](./bitburner.ns.scriptkill.md)


</td><td>

Kill all scripts with a filename.


</td></tr>
<tr><td>

[scriptRunning(script, host)](./bitburner.ns.scriptrunning.md)


</td><td>

Check if any script with a filename is running.


</td></tr>
<tr><td>

[self()](./bitburner.ns.self.md)


</td><td>

Returns the currently running script.


</td></tr>
<tr><td>

[serverExists(host)](./bitburner.ns.serverexists.md)


</td><td>

Returns a boolean denoting whether or not the specified server exists.


</td></tr>
<tr><td>

[share()](./bitburner.ns.share.md)


</td><td>

Share the server's ram with your factions to increase the reputation gain rate of faction work. This boost is applied to all faction work of all factions.


</td></tr>
<tr><td>

[sleep(millis)](./bitburner.ns.sleep.md)


</td><td>

Suspends the script for n milliseconds.


</td></tr>
<tr><td>

[spawn(script, threadOrOptions, args)](./bitburner.ns.spawn.md)


</td><td>

Terminate current script and start another in a defined number of milliseconds.


</td></tr>
<tr><td>

[sprintf(format, args)](./bitburner.ns.sprintf.md)


</td><td>

Format a string.


</td></tr>
<tr><td>

[sqlinject(host)](./bitburner.ns.sqlinject.md)


</td><td>

Runs SQLInject.exe on a server.


</td></tr>
<tr><td>

[toast(msg, variant, duration)](./bitburner.ns.toast.md)


</td><td>

Queue a toast (bottom-right notification).


</td></tr>
<tr><td>

[tprint(args)](./bitburner.ns.tprint.md)


</td><td>

Prints one or more values or variables to the Terminal.


</td></tr>
<tr><td>

[tprintf(format, values)](./bitburner.ns.tprintf.md)


</td><td>

Prints a raw value or a variable to the Terminal.


</td></tr>
<tr><td>

[tprintRaw(node)](./bitburner.ns.tprintraw.md)


</td><td>

Prints a ReactNode to the terminal.


</td></tr>
<tr><td>

[tryWritePort(portNumber, data)](./bitburner.ns.trywriteport.md)


</td><td>

Attempt to write to a port.


</td></tr>
<tr><td>

[vsprintf(format, args)](./bitburner.ns.vsprintf.md)


</td><td>

Format a string with an array of arguments.


</td></tr>
<tr><td>

[weaken(host, opts)](./bitburner.ns.weaken.md)


</td><td>

Reduce a server's security level.


</td></tr>
<tr><td>

[weakenAnalyze(threads, cores)](./bitburner.ns.weakenanalyze.md)


</td><td>

Predict the effect of weaken.


</td></tr>
<tr><td>

[wget(url, target, host)](./bitburner.ns.wget.md)


</td><td>

Download a file from the internet.


</td></tr>
<tr><td>

[write(filename, data, mode)](./bitburner.ns.write.md)


</td><td>

Write data to a file.


</td></tr>
<tr><td>

[writePort(portNumber, data)](./bitburner.ns.writeport.md)


</td><td>

Write data to a port.


</td></tr>
</tbody></table>

