The Appwrite CLI is a command-line application that allows you to interact with the Appwrite server and perform server-side tasks using your terminal. This includes creating and managing projects, managing resources (documents, files, users), creating and deploying Cloud Functions, and other operations available through Appwrite's API.
If you plan to use the CLI to initialize new Cloud Functions, ensure that Git is installed on your machine.
If you have npm set up, run the command below to install the CLI
For a completely dependency-free installation, the CLI also ships with a convenient installation script for your operating system
After the installation is complete, verify the install using
The next step is to have your Appwrite server running. You can grab our simple installation command and execute it. Now, we're all set to play around with the CLI.
Before you can use the CLI, you need to login to your Appwrite account using
After you're logged in, the CLI needs to be initialized with your Appwrite project. You can initialize the CLI using:
The following prompts will guide you through the setup process. The init command also creates an appwrite.json file representing your Appwrite project.
You can also fetch all the collections in your current project using
The init command also comes with a convenient --all flag to perform both these steps at once using
The CLI also handles the creation and deployment of Appwrite's Cloud Functions. You can initialize a new function using
This command creates a new function My Awesome Function in your current Appwrite project and also creates a template function for you to get started. You can now deploy this function using:
The Appwrite CLI also helps you migrate your project's collections from a development server to a production server. You can deploy all the collections in your appwrite.json file using:
The deploy command also comes with a convenient --all flag to deploy all your functions and collections at once.
An appwrite.json file is created by the CLI when you initialize your project. It stores all the configuration for the CLI to be able to interact with your Appwrite project. The file has a structure as depicted below. When using the appwrite deploy command, the CLI uses information from appwrite.json to deploy your functions and collections.
The appwrite.json file does the following things
The Appwrite CLI follows the following general syntax.
A complete list of supported commands can be found below.
|login||The login command allows you to authenticate a user into the CLI|
|init||The init command helps you initialize your Appwrite project, functions and collections|
|deploy||The deploy command provides a convenient wrapper for deploying your functions and collections|
|logout||The logout command allows you to logout from the CLI|
|projects||The projects command allows you to view, create and manage your Appwrite projects|
|storage||The storage command allows you to manage your project files|
|teams||The teams command allows you to group users of your project and to enable them to share read and write access to your project's resources|
|users||The users command allows you to manage your project users|
|client||The client command allows you to configure your CLI|
|account||The account command allows you to authenticate and manage a user account|
|avatars||The avatars command aims to help you complete everyday tasks related to your app image, icons, and avatars|
|functions||The functions command allows you view, create and manage your Cloud Functions|
|database||The database command allows you to create structured collections of documents, query and filter lists of documents|
|health||The health command allows you to both validate and monitor your Appwrite server's health|
|locale||The locale command allows you to customize your app based on your users' location|
Here are a few sample commands to get you started
To create a new user in your project, you can use the `create` command. To successfully create a user, make sure your API key is granted with the scope "users.write".
To get a list of all your project users, you can use the `list` command. To successfully view the list, make sure your API key is granted with the scope "users.read".
In case of errors with any command, you can get more information about what went wrong using the --verbose flag
To get a list of all your collections, you can use the `listCollections` command. To successfully view the list, make sure your API key is granted with the scope "collections.read".
If you wish to parse the output from the CLI, you can request the CLI output in JSON format using the --json flag
Get a Collection
To get more information on a particular collection, you can make use of the `getCollection` command and pass in the `collectionId`. To successfully fetch the collection, make sure your API key is granted with the scope "collections.read".
To create a new document in an existing collection, use the `createDocument` command.
At any point, if you would like to change your server endpoint, project key, or self-signed certificate acceptance, use the client service.
If you get stuck anywhere, you can always use the help command to get the usage examples. All the examples are also available on the Appwrite API specs docs, and you can view them by switching the examples to the "Appwrite CLI" from the top dropdown.
If you installed Appwrite CLI using NPM, you can use the following command to uninstall it.
If you installed the Appwrite CLI with brew or the installation script for your operating system, use the following command to uninstall it.
You can also remove the configuration, cookies, and API Keys the Appwrite CLI stored. To remove those, run the following command.