<p>The <a href="https://github.com/appwrite/sdk-for-cli" target="_blank" rel="noopener">Appwrite CLI</a> is a command-line application that allows you to interact with the <a href="/docs/getting-started-for-server">Appwrite server</a> and perform server-side tasks using your terminal. This includes creating and managing projects, managing resources (documents, files, users), creating and deploying Appwrite Functions, and other operations available through Appwrite's API.</p>

<h2><a href="/docs/command-line#installation" id="installation">Installation</a></h2>

<p>The CLI is packaged both as an <a href="https://www.npmjs.com/package/appwrite-cli">npm module</a> as well as a <a href="https://github.com/appwrite/sdk-for-cli/releases/latest">standalone binary</a> for your operating system, making it completely dependency free, platform independent and language agnostic.</p>

<p>If you plan to use the CLI to initialize new Appwrite Functions, ensure that <a href="https://git-scm.com/book/en/v2/Getting-Started-Installing-Git" target="_blank" rel="noopener">Git is installed</a> on your machine.</p>

<h3><a href="/docs/command-line#installWithNpm" id="installWithNpm">Install with NPM</a></h3>

<p>If you have npm set up, run the command below to install the CLI</p>

<div class="ide margin-bottom" data-lang="bash" data-lang-label="Bash">
    <pre class="line-numbers"><code class="prism language-bash" data-prism>npm install -g appwrite-cli</code></pre>
</div>


<h3><a href="/docs/command-line#installWithScript" id="installWithScript">Install with Script</a></h3>

<p>For a completely dependency-free installation, the CLI also ships with a convenient installation script for your operating system</p>

<ul class="phases clear" data-ui-phases>
    <li>
        <h4>MacOS</h4>
        <p>Using <a href="https://brew.sh" target="_blank">Homebrew</a></p>
        <div class="ide margin-bottom" data-lang="bash" data-lang-label="Bash">
            <pre class="line-numbers"><code class="prism language-bash" data-prism>brew tap appwrite/sdk-for-cli https://github.com/appwrite/sdk-for-cli
brew update
brew install --HEAD appwrite</code></pre>
        </div>

        <p>or terminal</p>
        <div class="ide margin-bottom" data-lang="bash" data-lang-label="Bash">
            <pre class="line-numbers"><code class="prism language-bash" data-prism>curl -sL <?php echo $this->getParam('home'); ?>/cli/install.sh | bash</code></pre>
        </div>
    </li>
    
    <li>
        <h4>Windows</h4>
        <div class="ide margin-bottom" data-lang="powershell" data-lang-label="PowerShell">
            <pre class="line-numbers"><code class="prism language-powershell" data-prism>iwr -useb <?php echo $this->getParam('home'); ?>/cli/install.ps1 | iex</code></pre>
        </div>
    </li>
    
    <li>
        <h4>Linux</h4>
        <div class="ide margin-bottom" data-lang="bash" data-lang-label="Bash">
            <pre class="line-numbers"><code class="prism language-bash" data-prism>curl -sL <?php echo $this->getParam('home'); ?>/cli/install.sh | bash</code></pre>
        </div>
    </li>
</ul>

<p>After the installation is complete, verify the install using</p>

<div class="ide margin-bottom" data-lang="bash" data-lang-label="CLI">
    <pre class="line-numbers"><code class="prism language-bash" data-prism>appwrite -v</code></pre>
</div>

<h2><a href="/docs/command-line#gettingStarted" id="gettingStarted">Getting Started</a></h2>

<p>Before you can use the CLI, you need to login to your Appwrite account using</p>

<div class="ide margin-bottom" data-lang="bash" data-lang-label="CLI">
    <pre class="line-numbers"><code class="prism language-bash" data-prism>appwrite login</code></pre>
</div>

<div class="notice margin-bottom"> 
    <h3>Self-Signed Certificates</h3> 
    <p>By default, requests to domains with self-signed SSL certificates (or no certificates) are disabled. If you trust the domain, you can bypass the certificate validation using</p>
    <div class="ide margin-bottom" data-lang="bash" data-lang-label="CLI">
        <pre class="line-numbers"><code class="prism language-bash" data-prism>appwrite client --selfSigned true</code></pre>
    </div>
</div>

<p>You can run your first CLI command after logging in. Try fetching information about your Appwrite project.</p>

<div class="ide margin-bottom" data-lang="bash" data-lang-label="CLI">
    <pre class="line-numbers"><code class="prism language-bash" data-prism>appwrite projects get --projectId [PROJECT_ID]</code></pre>
</div>

<h2><a href="/docs/command-line#next-steps" id="next-steps">Next Steps</a></h2>
<p>You can use the CLI to create and deploy functions and collections. Deploy commands allow you to configure your Appwrite project programmatically and replicate functions and collection schemas across Appwrite projects.</p>
<p>
<a href="/docs/command-line-deployment"><i class="icon-angle-circled-right"></i>Learn more about deployment</a>
</p>
<p>Besides utility commands, the CLI can be used to execute commands like a Server SDK.</p>
<p>
<a href="/docs/command-line-commands"><i class="icon-angle-circled-right"></i>Find a full list of commands</a>
</p>
<p>You can choose to use the CLI in a headless and non-interactive mode without the need for config files or sessions. This is useful for CI or scripting use cases.</p>
<p>
<a href="/docs/command-line-ci"><i class="icon-angle-circled-right"></i>Learn more about CI mode</a>
</p>

<h2><a href="/docs/command-line#help" id="help">Help</a></h2>

<p>If you get stuck anywhere, you can always use the <code>help</code> command to get the usage examples.</p>

<h2><a href="/docs/command-line#configuration" id="configuration">Configuration</a></h2>

<p>At any point, if you would like to change your server's endpoint, project ID, or self-signed certificate acceptance, use the <code>client</code> command.</p>

<div class="ide margin-bottom" data-lang="bash" data-lang-label="CLI">
    <pre class="line-numbers"><code class="prism language-bash" data-prism>appwrite client --endpoint https://cloud.appwrite.io/v1
appwrite client --key 23f24gwrhSDgefaY
appwrite client --selfSigned true
appwrite client --reset // Resets your CLI configuration
appwrite client --debug // Prints your current configuration</code></pre>
</div>

<h2><a href="/docs/command-line#uninstall" id="uninstall">Uninstall</a></h2>

<p>If you installed Appwrite CLI using NPM, you can use the following command to uninstall it.</p>

<div class="ide margin-bottom" data-lang="bash" data-lang-label="Bash">
    <pre class="line-numbers"><code class="prism language-bash" data-prism>npm uninstall -g appwrite-cli</code></pre>
</div>

<p>If you installed the Appwrite CLI with brew or the installation script for your operating system, use the following command to uninstall it.</p>

<ul class="phases clear" data-ui-phases>
    <li>
        <h4>MacOS</h4>
        <p>Using <a href="https://brew.sh" target="_blank">Homebrew</a></p>
        <div class="ide margin-bottom" data-lang="bash" data-lang-label="Bash">
            <pre class="line-numbers"><code class="prism language-bash" data-prism>brew uninstall appwrite</code></pre>
        </div>

        <p>or terminal</p>
        <div class="ide margin-bottom" data-lang="bash" data-lang-label="Bash">
            <pre class="line-numbers"><code class="prism language-bash" data-prism>rm -f /usr/local/bin/appwrite | bash</code></pre>
        </div>
    </li>
    
    <li>
        <h4>Windows</h4>
        <div class="ide margin-bottom" data-lang="powershell" data-lang-label="PowerShell">
            <pre class="line-numbers"><code class="prism language-powershell" data-prism>$APPWRITE_INSTALL_DIR = Join-Path -Path $env:LOCALAPPDATA -ChildPath "Appwrite"; Remove-Item -Force -Path $APPWRITE_INSTALL_DIR</code></pre>
        </div>
    </li>
    
    <li>
        <h4>Linux</h4>
        <div class="ide margin-bottom" data-lang="bash" data-lang-label="Bash">
            <pre class="line-numbers"><code class="prism language-bash" data-prism>rm -f /usr/local/bin/appwrite | bash</code></pre>
        </div>
    </li>
</ul>

<p>You can also remove the configuration, cookies, and API Keys the Appwrite CLI stored. To remove those, run the following command.</p>

<ul class="phases clear" data-ui-phases>
    <li>
        <h4>MacOS</h4>
        <div class="ide margin-bottom" data-lang="bash" data-lang-label="Bash">
            <pre class="line-numbers"><code class="prism language-bash" data-prism>rm -rf ~/.appwrite | bash</code></pre>
        </div>
    </li>
    
    <li>
        <h4>Windows</h4>
        <div class="ide margin-bottom" data-lang="powershell" data-lang-label="PowerShell">
            <pre class="line-numbers"><code class="prism language-powershell" data-prism>$APPWRITE_CONFIG_DIR = Join-Path -Path $env:UserProfile -ChildPath ".appwrite"; Remove-Item -Recurse -Force -Path $APPWRITE_CONFIG_DIR</code></pre>
        </div>
    </li>
    
    <li>
        <h4>Linux</h4>
        <div class="ide margin-bottom" data-lang="bash" data-lang-label="Bash">
            <pre class="line-numbers"><code class="prism language-bash" data-prism>rm -rf ~/.appwrite | bash</code></pre>
        </div>
    </li>
</ul>