March 23, 2025
+ 12
How to make an API call with the Couchbase Edge Server REST API.

Prerequisites

In order make an API call with the Edge Server REST API, you must have configured Edge Server for REST-based access.

  • You must have specified the host information, including the base URL and port.

  • You must have specified TLS certificate information.

  • If necessary, you must have specified a HTTP Basic user name and password. The user specified must have the role required to carry out the API call.

To configure Edge Server for REST-based access, see Get Started with the Edge Server REST API.

Make an API Call

You can use a client such as cURL or a native SDK call to make an API call with the Management API.

To make an API call:

  1. Use the base URL and port that you specified when configuring Edge Server, for example:

  2. Pass the TLS certificate information and the HTTP Basic username and password as required.

  3. If a request body is required, pass it in JSON format.

Alternatively, you can use a client such as Insomnia or Postman to explore the details of the REST API, generate code samples, and so on. The Edge Server REST API uses an OpenAPI v3 specification. To download the Edge Server REST API specification, go to the REST API Reference and click Download.

Examples

In the command line examples:

  • $USER and $PASSWORD are the credentials for Couchbase Edge Server.

  • $CERT is the name and path to a TLS certificate file, for example cert.cer.

  • $HOST and $PORT are the host and port to connect to Couchbase Edge Server, for example localhost:59840.

Note that the following cURL examples use a self-signed TLS server certificate. In production, you are strongly recommended to use a TLS certificate generated by a well-known authority.

Get Server Information

The following request gets information about the Edge Server node.

HTTP Request
curl --cacert $CERT --user $USER:$PASSWORD \
  "https://$HOST:$PORT/"

The response is a JSON object similar to the following.

HTTP Response
json
{ "couchdb": "Welcome", "vendor": { "name": "Couchbase Edge Server", "version": "1.0.0 (37; )" }, "version": "CouchbaseEdgeServer/1.0.0 (37; ) CouchbaseLiteCore/0.0.0-EE (770a516a19d505b7+403e27d509bb1131)" }

List All Databases

The following request lists all the databases available on the Edge Server node.

HTTP Request
curl --cacert $CERT --user $USER:$PASSWORD \
  "https://$HOST:$PORT/_all_dbs"

The response is a JSON array similar to the following. In this case, the Edge Server node has two databases.

HTTP Response
json
[ "scratch", "travel-sample" ]

Get Information About a Database

The following request gets information about the specified database.

HTTP Request
curl --cacert $CERT --user $USER:$PASSWORD \
  "https://$HOST:$PORT/travel-sample"

The response is a JSON object similar to the following.

HTTP Response
json
{ "db_name": "travel-sample", "db_uuid": "8478be31c9674c499c07edd4e3115de7", "collections": { "_default": { "doc_count": 0, "update_seq": 0 }, "inventory.airline": { "doc_count": 1, "update_seq": 1 }, "inventory.airport": { "doc_count": 1980, "update_seq": 1980 }, "inventory.hotel": { "doc_count": 0, "update_seq": 0 }, "inventory.landmark": { "doc_count": 0, "update_seq": 0 }, "inventory.route": { "doc_count": 0, "update_seq": 0 } } }

Get Information About a Keyspace

The following request gets information about the specified keyspace.

HTTP Request
curl --cacert $CERT --user $USER:$PASSWORD \
  "https://$HOST:$PORT/travel-sample.inventory.airport"

The response is a JSON object similar to the following.

HTTP Response
json
{ "db_name": "travel-sample", "db_uuid": "8478be31c9674c499c07edd4e3115de7", "scope_name": "inventory", "collection_name": "airport", "doc_count": 1980, "update_seq": 1980, "committed_update_seq": 1980 }