This SDK is compatible with Appwrite server version 0.12.x. For older versions, please check previous releases.
Appwrite is an open-source backend as a service server that abstract and simplify complex and repetitive development tasks behind a very simple to use REST API. Appwrite aims to help you develop your apps faster and in a more secure way. Use the Command Line SDK to integrate your app with the Appwrite server to easily start interacting with all of Appwrite backend APIs and tools. For full API documentation and tutorials go to https://appwrite.io/docs
This tutorial assumes that you have docker setup and running on your machine.
You can install the CLI by getting our installation script.
$ wget -q https://appwrite.io/cli/install.sh -O - | /bin/bash
$ iwr -useb https://appwrite.io/cli/install.ps1 | iex
The CLI needs to be initialised with your project settings. This can be done using
$ appwrite init
The CLI requires an endpoint, project ID, API key and a locale to be able to communicate with the Appwrite backend server. There are two ways to achieve this
$ appwrite init --endpoint="YOUR ENDPOINT" --project="YOUR PROJECT ID" --key="YOUR API KEY" --locale="YOUR LOCALE"
If any of the required values are missing, a prompt will show up, asking for those missing values.
Invoking appwrite init
without any params triggers an interactive prompt where you can manually enter the details. These values are saved locally so that you dont have to re-enter them everytime.
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 by using
$ appwrite client setSelfSigned --value=true
The Appwrite CLI follows the following general syntax.
$ appwrite [SERVICE] [COMMAND] --[OPTIONS]
A few sample commands to get you started
$ appwrite users create --email="hello@appwrite.io" --password="very_strong_password"
$ appwrite users list
To create a Document you can use the following command
$ appwrite database createDocument --collectionId="YOUR COLLECTION ID" --data='A VALID JSON STRING' --read=role:member --read="*" --write=role:guest
data
expects the JSON string to be escaped.- If using the wildcard (
*
) read or write permissions , make sure that it is properly escaped using a\
or by enclosing it in"*"
since bash interprets them differently. - Some arguments like
read
andwrite
permissions are expected to be arrays. In the Appwrite CLI, arrays are passed by simply repeating the argument as seen in thecreateDocument
example above.
To get information about the different services available, you can use
$ appwrite help
To get information about a particular service and the commands available in a service you can use
$ appwrite users help
$ appwrite accounts help
To get information about a particular command and the parameters it accepts, you can use
$ appwrite users list --help
$ appwrite account get --help
This library is auto-generated by Appwrite custom SDK Generator. To learn more about how you can help us improve this SDK, please check the contribution guide before sending a pull-request.
To build and test the CLI for development, follow these steps
- Clone the SDK Generator
$ git clone https://github.com/appwrite/sdk-generator
- Ensure that docker is running locally and then run
$ cd sdk-generator
# Install the composer dependencies
$ docker run --rm --interactive --tty --volume "$(pwd)":/app composer install --ignore-platform-reqs --optimize-autoloader --no-plugins --no-scripts --prefer-dist
# Generate the SDKs
$ docker run --rm -v $(pwd):/app -w /app php:7.4-cli php example.php
- Head over to the generated SDK and build the CLI docker image
$ cd examples/CLI
$ docker build -t appwrite/cli .
- Install the CLI
MacOS and Linux
Open install.sh
and change this line to APPWRITE_CLI_IMAGE_VERSION=latest
and
comment these lines.
You can now install the CLI using
$ chmod +x install.sh
$ ./install.sh
Windows
Open install.ps1
and change this line to APPWRITE_CLI_IMAGE_VERSION=latest
and
comment these lines
You can now install the CLI using
$ ./install.ps1
Please see the BSD-3-Clause license file for more information.