Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 45 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,35 @@
# Couchbase Data API Tutorial
# Couchbase Data API Serverless Cookbook

This tutorial demonstrates how to work with Couchbase's Data API to manage airport data from the travel-sample dataset.
> **Important:** This cookbook demonstrates building **serverless REST APIs** that use **Couchbase Data API** under the hood. Your applications interact with standard REST endpoints, while the serverless functions handle all communication with Couchbase's Data API internally.

This cookbook demonstrates how to build serverless REST APIs across multiple cloud platforms (AWS Lambda, Azure Functions, Cloudflare Workers, and Google Cloud Functions) that interface with Couchbase's Data API to manage airport data from the travel-sample dataset.

## Overview

This provides a comprehensive Airport Information System that manages airport data and provides related travel information from the Couchbase travel-sample dataset.
This cookbook provides a comprehensive Airport Information System that manages airport data and provides related travel information from the Couchbase travel-sample dataset. Each serverless implementation exposes REST API endpoints that internally call Couchbase's Data API, following REST API principles while abstracting the underlying Data API interactions.

### Architecture

The serverless functions act as a REST API layer that interfaces with Couchbase Data API. Here's how the request flow works:

**REST API Flow:**
1. **Client Request**: Your application sends a standard HTTP request to the REST API endpoint (e.g., `POST /airports`)
2. **Serverless Function Layer**:
- Receives and validates the incoming HTTP request
- Extracts required parameters (path parameters, query strings, request body)
- Performs business logic and data transformation
- Authenticates with Couchbase Data API using stored credentials
3. **Couchbase Data API Call**: The serverless function makes an HTTP request to Couchbase's Data API endpoint with proper authentication headers
4. **Response Processing**: The serverless function receives the Data API response, formats it appropriately, and returns it to the client

### Learn More About Couchbase Data API

This cookbook's serverless functions are built on top of Couchbase's Data API. To learn more about the underlying API:

- **[Get Started with Data API](https://docs.couchbase.com/cloud/data-api-guide/data-api-start.html)** - Complete guide covering setup, authentication, and networking options
- **[Data API Reference](https://docs.couchbase.com/cloud/data-api-reference/index.html)** - Full API reference for all available endpoints (document operations, queries, search, etc.)

Understanding these resources will help you extend the serverless functions or build custom integrations.

## Platform Tutorials

Expand Down Expand Up @@ -36,12 +61,20 @@ Choose your preferred serverless platform to get started:

## Prerequisites

- [Couchbase Capella](https://www.couchbase.com/products/capella/) cluster with Data API enabled
- Couchbase [travel-sample](https://docs.couchbase.com/dotnet-sdk/current/ref/travel-app-data-model.html) bucket loaded
- [Couchbase Capella](https://www.couchbase.com/products/capella/) cluster
- Couchbase [travel-sample](https://docs.couchbase.com/cloud/clusters/data-service/import-data-documents.html) bucket loaded

## Database Configuration

### Enable the Data API

Before you can use this cookbook, you must enable the Data API for your Couchbase Capella cluster. Follow the instructions in the [Couchbase documentation](https://docs.couchbase.com/cloud/data-api-guide/data-api-start.html#enable-the-data-api) to:

1. Enable the Data API for your cluster
2. Copy the Data API endpoint URL (you'll need this for `DATA_API_ENDPOINT`)

### Setup Database Connection

To connect to your Capella cluster, please follow the [instructions](https://docs.couchbase.com/cloud/get-started/connect.html).

Specifically, you need to do the following:
Expand All @@ -51,9 +84,9 @@ Specifically, you need to do the following:

### Required Environment Variables
The following Couchbase Data API credentials are required:
- `DATA_API_USERNAME` - Your Couchbase database username
- `DATA_API_PASSWORD` - Your Couchbase database password
- `DATA_API_ENDPOINT` - Your Couchbase Data API endpoint URL
- `DATA_API_USERNAME` - Your Couchbase database username (from the database credentials created in step 1 above)
- `DATA_API_PASSWORD` - Your Couchbase database password (from the database credentials created in step 1 above)
- `DATA_API_ENDPOINT` - Your Couchbase Data API endpoint URL (obtained when enabling the Data API)

## FTS Index Setup

Expand All @@ -65,9 +98,11 @@ A common Node.js script is provided to create the required geo-spatial FTS index



## API Examples
## REST API Endpoints & Usage Examples

> **Note:** These are the **REST API endpoints** that your client applications will use. Behind the scenes, the serverless functions translate these REST calls into Couchbase Data API requests, handling authentication and data transformation automatically.

The following examples demonstrate the API endpoints that interface with Couchbase's Data API:
The following examples demonstrate how to interact with the REST API endpoints:

### Get an airport
```bash
Expand Down
4 changes: 2 additions & 2 deletions aws-lambdas/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ Once deployed, the API Gateway will provide the following endpoints:
- [Node.js](https://nodejs.org/) (v18.x or later)
- [AWS CLI](https://aws.amazon.com/cli/) configured with appropriate credentials
- [Serverless Framework](https://www.serverless.com/) (will be installed as dev dependency)
- [Couchbase Capella](https://www.couchbase.com/products/capella/) cluster with Data API enabled
- Couchbase [travel-sample bucket](https://docs.couchbase.com/dotnet-sdk/current/ref/travel-app-data-model.html) loaded
- [Couchbase Capella](https://www.couchbase.com/products/capella/) cluster with [Data API enabled](https://docs.couchbase.com/cloud/data-api-guide/data-api-start.html#enable-the-data-api)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For consistency with the main README.md, which now has a dedicated section for enabling the Data API, it would be clearer to simplify this prerequisite. The main README.md lists [Couchbase Capella] cluster as a prerequisite and then details enabling the Data API in the Database Configuration section.

Consider also adding a step in the Setup section of this file to refer users to the main README.md for database configuration, similar to how it's done in the azure-functions and cloudflare-workers READMEs.

Suggested change
- [Couchbase Capella](https://www.couchbase.com/products/capella/) cluster with [Data API enabled](https://docs.couchbase.com/cloud/data-api-guide/data-api-start.html#enable-the-data-api)
- [Couchbase Capella](https://www.couchbase.com/products/capella/) cluster

- Couchbase [travel-sample bucket](https://docs.couchbase.com/cloud/clusters/data-service/import-data-documents.html) loaded

## Setup

Expand Down
4 changes: 2 additions & 2 deletions azure-functions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ This project demonstrates how to build an Azure Functions-based API that interfa
- [Azure CLI](https://docs.microsoft.com/en-us/cli/azure/) configured with appropriate credentials
- [Azure Functions Core Tools](https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local) (v4.x)
- Azure subscription with Functions and API Management permissions
- [Couchbase Capella](https://www.couchbase.com/products/capella/) cluster with Data API enabled
- Couchbase [travel-sample](https://docs.couchbase.com/dotnet-sdk/current/ref/travel-app-data-model.html) bucket loaded
- [Couchbase Capella](https://www.couchbase.com/products/capella/) cluster with [Data API enabled](https://docs.couchbase.com/cloud/data-api-guide/data-api-start.html#enable-the-data-api)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To maintain consistency with the main README.md's new structure, consider simplifying this prerequisite. The main README.md now lists [Couchbase Capella] cluster as a prerequisite and details enabling the Data API in a separate Database Configuration section. Since this file already links to that section under Setup, removing 'with [Data API enabled]' from here would improve clarity and reduce redundancy.

Suggested change
- [Couchbase Capella](https://www.couchbase.com/products/capella/) cluster with [Data API enabled](https://docs.couchbase.com/cloud/data-api-guide/data-api-start.html#enable-the-data-api)
- [Couchbase Capella](https://www.couchbase.com/products/capella/) cluster

- Couchbase [travel-sample](https://docs.couchbase.com/cloud/clusters/data-service/import-data-documents.html) bucket loaded

## Setup

Expand Down
4 changes: 2 additions & 2 deletions cloudflare-workers/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ This project demonstrates how to build a Cloudflare Workers-based API using the
- [Node.js](https://nodejs.org/) (v20 or later)
- [Wrangler CLI](https://developers.cloudflare.com/workers/wrangler/install-and-update/)
- [Cloudflare account](https://dash.cloudflare.com/) with verified email
- [Couchbase Capella](https://www.couchbase.com/products/capella/) cluster with Data API enabled
- Couchbase [travel-sample](https://docs.couchbase.com/dotnet-sdk/current/ref/travel-app-data-model.html) bucket loaded
- [Couchbase Capella](https://www.couchbase.com/products/capella/) cluster with [Data API enabled](https://docs.couchbase.com/cloud/data-api-guide/data-api-start.html#enable-the-data-api)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For better consistency with the refactored main README.md, it would be best to simplify this prerequisite. The main README.md now lists [Couchbase Capella] cluster as a prerequisite and explains how to enable the Data API in the Database Configuration section. This file already points to that section in the Setup instructions, so removing 'with [Data API enabled]' here will make the documentation more consistent.

Suggested change
- [Couchbase Capella](https://www.couchbase.com/products/capella/) cluster with [Data API enabled](https://docs.couchbase.com/cloud/data-api-guide/data-api-start.html#enable-the-data-api)
- [Couchbase Capella](https://www.couchbase.com/products/capella/) cluster

- Couchbase [travel-sample](https://docs.couchbase.com/cloud/clusters/data-service/import-data-documents.html) bucket loaded

## Setup

Expand Down
4 changes: 2 additions & 2 deletions gcp/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ This project demonstrates how to build a serverless API using **[GCP Cloud Funct
- [Node.js](https://nodejs.org/) (v22.x or later)
- [Google Cloud CLI](https://cloud.google.com/sdk/docs/install) configured with appropriate credentials.
- Google Cloud Project with Cloud Functions and API Gateway with [services enabled.](https://cloud.google.com/api-gateway/docs/secure-traffic-gcloud#enabling_required_services)
- [Couchbase Capella](https://www.couchbase.com/products/capella/) cluster with Data API enabled.
- Couchbase [travel-sample](https://docs.couchbase.com/dotnet-sdk/current/ref/travel-app-data-model.html) bucket loaded.
- [Couchbase Capella](https://www.couchbase.com/products/capella/) cluster with [Data API enabled](https://docs.couchbase.com/cloud/data-api-guide/data-api-start.html#enable-the-data-api).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

To align with the structure of the main README.md, which now has a dedicated section for enabling the Data API, it would be clearer to simplify this prerequisite. The main README.md lists [Couchbase Capella] cluster as a prerequisite and then details enabling the Data API in the Database Configuration section.

Consider also adding a step in the Setup section of this file to refer users to the main README.md for database configuration, similar to how it's done in the azure-functions and cloudflare-workers READMEs. This will ensure users follow the correct setup flow.

Suggested change
- [Couchbase Capella](https://www.couchbase.com/products/capella/) cluster with [Data API enabled](https://docs.couchbase.com/cloud/data-api-guide/data-api-start.html#enable-the-data-api).
- [Couchbase Capella](https://www.couchbase.com/products/capella/) cluster.

- Couchbase [travel-sample](https://docs.couchbase.com/cloud/clusters/data-service/import-data-documents.html) bucket loaded.

## Setup

Expand Down