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. Before starting, make sure you have followed the Appwrite installation guide, and you have an Appwrite server instance up and running on your host machine or server.
Get the 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 code examples using Appwrite SDKs for Node.js, PHP, Python, Ruby, and Deno, but the same can be applied to any of our server side SDKs.
-
Node.js
npm install node-appwrite --save
-
PHP
composer require 'appwrite/appwrite'
-
Python
pip install appwrite
-
Ruby
gem install appwrite --save
-
Deno
import * as sdk from "https://deno.land/x/appwrite/mod.ts";
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.
-
Node.js
const sdk = require('node-appwrite'); let client = new sdk.Client(); client .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ;
-
PHP
$client = new Client(); $client ->setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ;
-
Python
from appwrite.client import Client from appwrite.services.users import Users client = Client() (client .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint .set_project('5df5acd0d48c2') # Your project ID .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key )
-
Ruby
require 'appwrite' client = Appwrite::Client.new() client .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint .set_project('5df5acd0d48c2') # Your project ID .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key ;
-
Deno
let client = new sdk.Client(); client .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret 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.
-
Node.js
let users = new sdk.Users(client); let promise = users.create('email@example.com', 'password'); promise.then(function (response) { console.log(response); }, function (error) { console.log(error); });
-
PHP
$users = new Users($client); $result = $users->create('email@example.com', 'password');
-
Python
users = Users(client) result = users.create('email@example.com', 'password')
-
Ruby
users = Appwrite::Users.new(client); response = users.create(email: 'email@example.com', password: 'password'); puts response
-
Deno
let users = new sdk.Users(client); let promise = users.create('email@example.com', 'password'); promise.then(function (response) { console.log(response); }, function (error) { console.log(error); });
Full Example
-
Node.js
const sdk = require('node-appwrite'); let client = new sdk.Client(); client .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; let users = new sdk.Users(client); let promise = users.create('email@example.com', 'password'); promise.then(function (response) { console.log(response); }, function (error) { console.log(error); });
-
PHP
use Appwrite\Client; use Appwrite\Services\Users; $client = new Client(); $client ->setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint ->setProject('5df5acd0d48c2') // Your project ID ->setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; $users = new Users($client); $result = $users->create('email@example.com', 'password');
-
Python
from appwrite.client import Client from appwrite.services.users import Users client = Client() (client .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint .set_project('5df5acd0d48c2') # Your project ID .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key ) users = Users(client) result = users.create('email@example.com', 'password')
-
Ruby
require 'appwrite' client = Appwrite::Client.new() client .set_endpoint('https://[HOSTNAME_OR_IP]/v1') # Your API Endpoint .set_project('5df5acd0d48c2') # Your project ID .set_key('919c2d18fb5d4...a2ae413da83346ad2') # Your secret API key ; users = Appwrite::Users.new(client); response = users.create(email: 'email@example.com', password: 'password'); puts response
-
Deno
import * as sdk from "https://deno.land/x/appwrite/mod.ts"; let client = new sdk.Client(); let users = new sdk.Users(client); client .setEndpoint('https://[HOSTNAME_OR_IP]/v1') // Your API Endpoint .setProject('5df5acd0d48c2') // Your project ID .setKey('919c2d18fb5d4...a2ae413da83346ad2') // Your secret API key ; let promise = users.create('email@example.com', 'password'); promise.then(function (response) { console.log(response); }, function (error) { console.log(error); });
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.