[Home](./index.md) > [bitburner](./bitburner.md) > [NS](./bitburner.ns.md) ## NS interface Collection of all functions passed to scripts **Signature:** ```typescript export interface NS ``` ## Remarks Basic usage example: ```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
Property Modifiers Type Description
[args](./bitburner.ns.args.md) `readonly` [ScriptArg](./bitburner.scriptarg.md)\[\] 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.
[bladeburner](./bitburner.ns.bladeburner.md) `readonly` [Bladeburner](./bitburner.bladeburner.md) Namespace for [Bladeburner](./bitburner.bladeburner.md) functions. Contains spoilers.
[cloud](./bitburner.ns.cloud.md) `readonly` [Cloud](./bitburner.cloud.md) Namespace for [cloud](./bitburner.cloud.md) functions.
[codingcontract](./bitburner.ns.codingcontract.md) `readonly` [CodingContract](./bitburner.codingcontract.md) Namespace for [coding contract](./bitburner.codingcontract.md) functions.
[corporation](./bitburner.ns.corporation.md) `readonly` [Corporation](./bitburner.corporation.md) Namespace for [corporation](./bitburner.corporation.md) functions. Contains spoilers.
[dnet](./bitburner.ns.dnet.md) `readonly` [Darknet](./bitburner.darknet.md) Namespace for darknet functions. Contains spoilers.
[enums](./bitburner.ns.enums.md) [NSEnums](./bitburner.nsenums.md)
[format](./bitburner.ns.format.md) `readonly` [Format](./bitburner.format.md) Namespace for [formatting](./bitburner.format.md) functions.
[formulas](./bitburner.ns.formulas.md) `readonly` [Formulas](./bitburner.formulas.md) Namespace for [formulas](./bitburner.formulas.md) functions.
[gang](./bitburner.ns.gang.md) `readonly` [Gang](./bitburner.gang.md) Namespace for [gang](./bitburner.gang.md) functions. Contains spoilers.
[go](./bitburner.ns.go.md) `readonly` [Go](./bitburner.go.md) Namespace for [Go](./bitburner.go.md) functions.
[grafting](./bitburner.ns.grafting.md) `readonly` [Grafting](./bitburner.grafting.md) Namespace for [grafting](./bitburner.grafting.md) functions. Contains spoilers.
[hacknet](./bitburner.ns.hacknet.md) `readonly` [Hacknet](./bitburner.hacknet.md) Namespace for [hacknet](./bitburner.hacknet.md) functions. Some of this API contains spoilers.
[heart](./bitburner.ns.heart.md) `readonly` { break(): number; }
[infiltration](./bitburner.ns.infiltration.md) `readonly` [Infiltration](./bitburner.infiltration.md) Namespace for [infiltration](./bitburner.infiltration.md) functions.
[pid](./bitburner.ns.pid.md) `readonly` number The current script's PID
[singularity](./bitburner.ns.singularity.md) `readonly` [Singularity](./bitburner.singularity.md) Namespace for [singularity](./bitburner.singularity.md) functions. Contains spoilers.
[sleeve](./bitburner.ns.sleeve.md) `readonly` [Sleeve](./bitburner.sleeve.md) Namespace for [sleeve](./bitburner.sleeve.md) functions. Contains spoilers.
[stanek](./bitburner.ns.stanek.md) `readonly` [Stanek](./bitburner.stanek.md) Namespace for [Stanek](./bitburner.stanek.md) functions. Contains spoilers.
[stock](./bitburner.ns.stock.md) `readonly` [Stock](./bitburner.stock.md) Namespace for [stock](./bitburner.stock.md) functions.
[ui](./bitburner.ns.ui.md) `readonly` [UserInterface](./bitburner.userinterface.md) Namespace for [user interface](./bitburner.userinterface.md) functions.
## Methods
Method Description
[alert(args)](./bitburner.ns.alert.md) Open up a message box.
[asleep(millis)](./bitburner.ns.asleep.md) Suspends the script for n milliseconds. Doesn't block with concurrent calls.
[atExit(f, id)](./bitburner.ns.atexit.md) Add a callback to be executed when the script dies.
[brutessh(host)](./bitburner.ns.brutessh.md) Runs BruteSSH.exe on a server.
[clear(handle)](./bitburner.ns.clear.md) Clear data from a file.
[clearLog()](./bitburner.ns.clearlog.md) Clears the script’s logs.
[clearPort(portNumber)](./bitburner.ns.clearport.md) Clear data from a port.
[disableLog(fn)](./bitburner.ns.disablelog.md) Disables logging for the given NS function.
[dnsLookup(host)](./bitburner.ns.dnslookup.md) Given a hostname, returns its IP address; or given an IP address, returns its hostname.
[dynamicImport(path)](./bitburner.ns.dynamicimport.md) 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).
[enableLog(fn)](./bitburner.ns.enablelog.md) Enables logging for the given NS function.
[exec(script, host, threadOrOptions, args)](./bitburner.ns.exec.md) Start another script on any server.
[exit()](./bitburner.ns.exit.md) Terminates the current script immediately.
[fileExists(filename, host)](./bitburner.ns.fileexists.md) Check if a file exists.
[flags(schema)](./bitburner.ns.flags.md) Parse command line flags.
[ftpcrack(host)](./bitburner.ns.ftpcrack.md) Runs FTPCrack.exe on a server.
[getBitNodeMultipliers(n, lvl)](./bitburner.ns.getbitnodemultipliers.md) Get the current BitNode multipliers.
[getFavorToDonate()](./bitburner.ns.getfavortodonate.md) Returns the amount of Faction favor required to be able to donate to a faction.
[getFileMetadata(filename)](./bitburner.ns.getfilemetadata.md) Get the metadata of a file.
[getFunctionRamCost(name)](./bitburner.ns.getfunctionramcost.md) Get the ram cost of a netscript function.
[getGrowTime(host)](./bitburner.ns.getgrowtime.md) Get the execution time of a grow() call.
[getHackingLevel()](./bitburner.ns.gethackinglevel.md) Returns the player’s current hacking level.
[getHackingMultipliers()](./bitburner.ns.gethackingmultipliers.md) Get hacking related multipliers.
[getHacknetMultipliers()](./bitburner.ns.gethacknetmultipliers.md) Get hacknet related multipliers.
[getHackTime(host)](./bitburner.ns.gethacktime.md) Get the execution time of a hack() call.
[getHostname()](./bitburner.ns.gethostname.md) Returns a string with the hostname of the server that the script is running on.
[getIP()](./bitburner.ns.getip.md) Returns a string with the IP address of the server that the script is running on.
[getMoneySources()](./bitburner.ns.getmoneysources.md) Get information about the sources of income for this run.
[getPlayer()](./bitburner.ns.getplayer.md) Get information about the player.
[getPortHandle(portNumber)](./bitburner.ns.getporthandle.md) Get all data on a port.
[getRecentScripts()](./bitburner.ns.getrecentscripts.md) Get an array of recently killed scripts across all servers.
[getResetInfo()](./bitburner.ns.getresetinfo.md) Get information about resets.
[getRunningScript(filename, host, args)](./bitburner.ns.getrunningscript.md) Get general info about a running script.
[getScriptExpGain(script, host, args)](./bitburner.ns.getscriptexpgain.md) Get the exp gain of a script.
[getScriptIncome(script, host, args)](./bitburner.ns.getscriptincome.md) Get the income of a script.
[getScriptLogs(fn, host, args)](./bitburner.ns.getscriptlogs.md) Get all the logs of a script.
[getScriptName()](./bitburner.ns.getscriptname.md) Returns the current script name.
[getScriptRam(script, host)](./bitburner.ns.getscriptram.md) Get the ram cost of a script.
[getServer(host)](./bitburner.ns.getserver.md) Returns data of a server. If the server is a darknet server and has recently gone offline, it will return a dummy server object with `isOnline: false`.
[getServerBaseSecurityLevel(host)](./bitburner.ns.getserverbasesecuritylevel.md) Get the base security level of a server.
[getServerGrowth(host)](./bitburner.ns.getservergrowth.md) Get a server growth parameter.
[getServerMaxMoney(host)](./bitburner.ns.getservermaxmoney.md) Get the maximum money available on a server.
[getServerMaxRam(host)](./bitburner.ns.getservermaxram.md) Get the maximum amount of RAM on a server.
[getServerMinSecurityLevel(host)](./bitburner.ns.getserverminsecuritylevel.md) Returns the minimum security level of the target server.
[getServerMoneyAvailable(host)](./bitburner.ns.getservermoneyavailable.md) Get money available on a server.
[getServerNumPortsRequired(host)](./bitburner.ns.getservernumportsrequired.md) Returns the number of open ports required to successfully run NUKE.exe on the specified server.
[getServerRequiredHackingLevel(host)](./bitburner.ns.getserverrequiredhackinglevel.md) Returns the required hacking level of the target server.
[getServerSecurityLevel(host)](./bitburner.ns.getserversecuritylevel.md) Get server security level.
[getServerUsedRam(host)](./bitburner.ns.getserverusedram.md) Get the used RAM on a server. This includes ram used by running scripts as well as blocked ram on darknet servers.
[getSharePower()](./bitburner.ns.getsharepower.md) 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.
[getTotalScriptExpGain()](./bitburner.ns.gettotalscriptexpgain.md) Get the exp gain of all scripts.
[getTotalScriptIncome()](./bitburner.ns.gettotalscriptincome.md) Get the income of all scripts.
[getWeakenTime(host)](./bitburner.ns.getweakentime.md) Get the execution time of a weaken() call.
[grow(host, opts)](./bitburner.ns.grow.md) Spoof money in a server's bank account, increasing the amount available.
[growthAnalyze(host, multiplier, cores)](./bitburner.ns.growthanalyze.md) Calculate the number of grow threads needed for a given multiplicative growth factor.
[growthAnalyzeSecurity(threads, host, cores)](./bitburner.ns.growthanalyzesecurity.md) Calculate the security increase for a number of grow threads.
[hack(host, opts)](./bitburner.ns.hack.md) Steal a server's money.
[hackAnalyze(host)](./bitburner.ns.hackanalyze.md) Get the part of money stolen with a single thread.
[hackAnalyzeChance(host)](./bitburner.ns.hackanalyzechance.md) Get the chance of successfully hacking a server.
[hackAnalyzeSecurity(threads, host)](./bitburner.ns.hackanalyzesecurity.md) Get the security increase for a number of threads.
[hackAnalyzeThreads(host, hackAmount)](./bitburner.ns.hackanalyzethreads.md) Calculate the decimal number of threads needed to hack a specified amount of money from a target host.
[hasRootAccess(host)](./bitburner.ns.hasrootaccess.md) Check if you have root access on a server.
[hasTorRouter()](./bitburner.ns.hastorrouter.md) Returns whether the player has access to the darkweb.
[httpworm(host)](./bitburner.ns.httpworm.md) Runs HTTPWorm.exe on a server.
[isLogEnabled(fn)](./bitburner.ns.islogenabled.md) Checks the status of the logging for the given NS function.
[isRunning(script, host, args)](./bitburner.ns.isrunning.md) Check if a script is running.
[kill(pid)](./bitburner.ns.kill.md) Terminate the script with the provided PID.
[kill(filename, host, args)](./bitburner.ns.kill_1.md) Terminate the script(s) with the provided filename, host, and script arguments.
[killall(host, safetyGuard)](./bitburner.ns.killall.md) Terminate all scripts on a server.
[ls(host, substring)](./bitburner.ns.ls.md) List files on a server.
[mv(host, source, destination)](./bitburner.ns.mv.md) Move a file on the target server.
[nextPortWrite(port)](./bitburner.ns.nextportwrite.md) Listen for a port write.
[nuke(host)](./bitburner.ns.nuke.md) Runs NUKE.exe on a server.
[peek(portNumber)](./bitburner.ns.peek.md) Get a copy of the data from a port without popping it.
[print(args)](./bitburner.ns.print.md) Prints one or more values or variables to the script’s logs.
[printf(format, args)](./bitburner.ns.printf.md) Prints a formatted string to the script’s logs.
[printRaw(node)](./bitburner.ns.printraw.md) Prints a ReactNode to the script logs.
[prompt(txt, options)](./bitburner.ns.prompt.md) Prompt the player with an input modal.
[ps(host)](./bitburner.ns.ps.md) List running scripts on a server.
[ramOverride(ram)](./bitburner.ns.ramoverride.md) Change the current static RAM allocation of the script.
[read(filename)](./bitburner.ns.read.md) Read content of a file.
[readPort(portNumber)](./bitburner.ns.readport.md) Read data from a port.
[relaysmtp(host)](./bitburner.ns.relaysmtp.md) Runs relaySMTP.exe on a server.
[rm(name, host)](./bitburner.ns.rm.md) Delete a file.
[run(script, threadOrOptions, args)](./bitburner.ns.run.md) Start another script on the current server.
[scan(host, returnOpts)](./bitburner.ns.scan.md) 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.
[scp(files, destination, source)](./bitburner.ns.scp.md) Copy file between servers.
[scriptKill(script, host)](./bitburner.ns.scriptkill.md) Kill all scripts with a filename.
[scriptRunning(script, host)](./bitburner.ns.scriptrunning.md) Check if any script with a filename is running.
[self()](./bitburner.ns.self.md) Returns the currently running script.
[serverExists(host)](./bitburner.ns.serverexists.md) Returns a boolean denoting whether or not the specified server exists.
[share()](./bitburner.ns.share.md) 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.
[sleep(millis)](./bitburner.ns.sleep.md) Suspends the script for n milliseconds.
[spawn(script, threadOrOptions, args)](./bitburner.ns.spawn.md) Terminate current script and start another in a defined number of milliseconds.
[sprintf(format, args)](./bitburner.ns.sprintf.md) Format a string.
[sqlinject(host)](./bitburner.ns.sqlinject.md) Runs SQLInject.exe on a server.
[toast(msg, variant, duration)](./bitburner.ns.toast.md) Queue a toast (bottom-right notification).
[tprint(args)](./bitburner.ns.tprint.md) Prints one or more values or variables to the Terminal.
[tprintf(format, values)](./bitburner.ns.tprintf.md) Prints a raw value or a variable to the Terminal.
[tprintRaw(node)](./bitburner.ns.tprintraw.md) Prints a ReactNode to the terminal.
[tryWritePort(portNumber, data)](./bitburner.ns.trywriteport.md) Attempt to write to a port.
[vsprintf(format, args)](./bitburner.ns.vsprintf.md) Format a string with an array of arguments.
[weaken(host, opts)](./bitburner.ns.weaken.md) Reduce a server's security level.
[weakenAnalyze(threads, cores)](./bitburner.ns.weakenanalyze.md) Predict the effect of weaken.
[wget(url, target, host)](./bitburner.ns.wget.md) Download a file from the internet.
[write(filename, data, mode)](./bitburner.ns.write.md) Write data to a file.
[writePort(portNumber, data)](./bitburner.ns.writeport.md) Write data to a port.