DEV Community

Alex Spinov
Alex Spinov

Posted on

Appwrite Has a Free API — Here's How to Build a Full Backend in 10 Minutes

Why Appwrite?

Appwrite is an open-source backend-as-a-service that replaces Firebase. It provides authentication, databases, storage, functions, and messaging — all self-hosted or cloud-hosted.

Appwrite Cloud free tier: unlimited projects, 75K requests/month, 10GB bandwidth, 2GB storage, 750K function executions.

Getting Started

Option 1: Appwrite Cloud (Free)

Sign up at appwrite.io — free, no credit card.

Option 2: Self-Hosted (Docker)

docker run -it --rm \
  --volume /var/run/docker.sock:/var/run/docker.sock \
  --volume "$(pwd)"/appwrite:/usr/src/code/appwrite:rw \
  --entrypoint="install" \
  appwrite/appwrite:latest
Enter fullscreen mode Exit fullscreen mode

JavaScript SDK

import { Client, Databases, Account, ID } from "appwrite";

const client = new Client()
  .setEndpoint("https://cloud.appwrite.io/v1")
  .setProject("YOUR_PROJECT_ID");

const account = new Account(client);
const databases = new Databases(client);

// Authentication
await account.create(ID.unique(), "user@example.com", "password123", "Alice");
await account.createEmailPasswordSession("user@example.com", "password123");
const user = await account.get();
console.log(`Logged in as ${user.name}`);

// Create document
const doc = await databases.createDocument(
  "mydb", "posts", ID.unique(),
  {
    title: "My First Post",
    content: "Appwrite makes backend development easy!",
    author: user.name,
    published: true,
    views: 0
  }
);
console.log(`Created post: ${doc.$id}`);

// Query documents
const posts = await databases.listDocuments("mydb", "posts", [
  Query.equal("published", true),
  Query.orderDesc("$createdAt"),
  Query.limit(10)
]);

posts.documents.forEach(p => console.log(`${p.title} by ${p.author}`));
Enter fullscreen mode Exit fullscreen mode

Python SDK

from appwrite.client import Client
from appwrite.services.databases import Databases
from appwrite.id import ID

client = Client()
client.set_endpoint("https://cloud.appwrite.io/v1")
client.set_project("YOUR_PROJECT_ID")
client.set_key("YOUR_API_KEY")  # Server-side

databases = Databases(client)

# Create collection
databases.create_collection(
    database_id="mydb",
    collection_id=ID.unique(),
    name="products"
)

# Add attributes
databases.create_string_attribute("mydb", "products", "name", 255, required=True)
databases.create_float_attribute("mydb", "products", "price", required=True)
databases.create_string_attribute("mydb", "products", "category", 100)

# Create documents
for product in [{"name": "Widget", "price": 9.99, "category": "tools"},
                {"name": "Gadget", "price": 24.99, "category": "electronics"}]:
    databases.create_document("mydb", "products", ID.unique(), product)
    print(f"Created: {product['name']}")

# List with filters
results = databases.list_documents("mydb", "products", queries=[
    'equal("category", "electronics")'
])
for doc in results["documents"]:
    print(f"{doc['name']}: ${doc['price']}")
Enter fullscreen mode Exit fullscreen mode

Real-Time Updates

// Subscribe to document changes — real-time!
client.subscribe('databases.mydb.collections.posts.documents', (response) => {
  console.log(`Event: ${response.events}`);
  console.log(`Data: ${JSON.stringify(response.payload)}`);
});
Enter fullscreen mode Exit fullscreen mode

Cloud Functions

// functions/hello/src/main.js
export default async ({ req, res, log }) => {
  const { name } = JSON.parse(req.body);
  log(`Hello from ${name}`);
  return res.json({ message: `Hello, ${name}!`, timestamp: new Date().toISOString() });
};
Enter fullscreen mode Exit fullscreen mode

Appwrite vs Alternatives

Feature Appwrite Firebase Supabase
Open source Yes No Yes
Self-hosted Yes No Yes
Auth providers 30+ 10+ 20+
Database MariaDB Firestore PostgreSQL
Storage Built-in Built-in Built-in
Functions Node, Python, etc. Node, Python Edge (Deno)
Free tier Generous Limited 500 MB

Need to scrape data for your Appwrite app? I build production-ready web scrapers. Check out my Apify actors or email spinov001@gmail.com for custom solutions.

Building with Appwrite? Share your project below!

Top comments (0)