Docs

Getting Started for Server

Appwrite is a development platform providing you easy yet powerful API and management console to get your next project up and running quickly.

This tutorial will help you start using Appwrite products and build your next project.

Set Up a Self Hosted Environment

Appwrite backend server is designed to run in a container environment. Running your server is as easy as running one command from your terminal. You can run Appwrite on your localhost using docker-compose or on any other container orchestration tool like Kubernetes, Docker Swarm or Rancher.

The easiest way to start running your Appwrite server is by running our docker compose file:

mkdir appwrite-ce && \
cd appwrite-ce && \
curl -o docker-compose.yml https://appwrite.io/docker-compose.yml?version=0.3.0 && \
docker-compose up -d --remove-orphans

Once the Docker installation completes, go to http://localhost to access the Appwrite console from your browser. Please notice that on non-linux native hosts the server might take a few minutes to start after installation completes.

Get Appwrite SDK for Your Platform

We provide libraries and SDKs for major programming languages and platforms so you don't have to write code for interacting with our HTTP APIs from scratch.

Choose your desired SDK corresponding to your product development platform and import it using the given package manager. For the sake of this tutorial we will use Appwrite PHP SDK, but same can be applied to any of our server side SDKs.

composer require 'appwrite/appwrite:1.0.0'

Create Your First Appwrite Project

Go to your new Appwrite console and once inside click the icon in the top navigation header or on the 'Create Project' button on your console homepage. Choose a name for your project and click create to get started.

Grab an API Key

For you to init your SDK and interact with Appwrite services you need an API key. To get your first API key, go to your appwrite console, choose the project you created in the step before and click the 'API Keys' link.

Once inside your API keys screen click the 'Add API Key' button, choose your key name, for example: 'Demo Key' and select the scopes your key will be granted to use. To learn about the different API scopes available to you read more about Appwrite API Keys

A Note About API Keys & Admin Mode

When using Appwrite API from your server-side with an API Key you will automatically run in admin mode. Admin mode disables the default user permission access control restrictions and allows you to access all the resources available on your project. This is very useful when you want to manipulate your users' data like files and documents or even if you want to get a list of your users.

Please notice it is highly not recommended to run the admin mode from your client-side as it will probably lead to huge privacy and security issues. Check the Admin Mode documentation to learn more

Init your SDK

Initialize your SDK code with your project ID which can be found in your project settings page and your new API secret Key from previous phase.

$client = new \Appwrite\Client();

$client
    ->setEndpoint('http://localhost/v1') // Set only when using self-hosted solution
    ->setProject('PROJECT_ID')
    ->setKey('API_KEY')
;

Make Your First Request

Once your SDK object is set, create any of the Appwrite service project objects and choose any request to send. Full documentation for any service method you would like to use can be found in your SDK documentation or in the API References section.

$users = new \Appwrite\Services\Users($client);

var_dump($users->get('USER_ID'));

Full Example

use Appwrite\Client;
use Appwrite\Services\Users;

$client = new Client();

$client
    ->setEndpoint('https://appwrite.io/v1') // Set only when using self-hosted solution
    ->setProject('PROJECT_ID')
    ->setKey('API_KEY')
;

$users = new Users($client);

var_dump($users->getUser('USER_ID'));

Next Steps

Appwrite has many services and tools to help improve your app and speed up your development. The best way to learn how you can take advantage of them is to explore the different API references docs.