# CouchbaseGetBucket

Get a Couchbase bucket instance for bucket-level operations.

## Syntax

```js
couchbaseGetBucket(cacheName)
```

## Parameters

| Parameter   | Type   | Required | Description                     |
| ----------- | ------ | -------- | ------------------------------- |
| `cacheName` | String | Yes      | Name of the cache configuration |

## Returns

Returns the Couchbase `Bucket` instance with access to:

* Scope management
* Collection access
* Bucket statistics
* Ping operations
* View queries (legacy)

## Examples

### Basic Usage

```js
// Get bucket instance
bucket = couchbaseGetBucket("default");

// Get bucket name
println("Bucket name: #bucket.name()#");
```

### Access Collections

```js
bucket = couchbaseGetBucket("default");

// Get default scope and collection
scope = bucket.defaultScope();
collection = scope.defaultCollection();

// Or get specific scope/collection
customScope = bucket.scope("myapp");
customCollection = customScope.collection("users");
```

### Bucket Operations

```js
bucket = couchbaseGetBucket("default");

// Ping bucket health
pingResult = bucket.ping();
println("Bucket status: #pingResult.version()#");

// Get collections
allScopes = bucket.collections();
```

### Multiple Buckets

```js
// Different buckets for different data
usersBucket = couchbaseGetBucket("users-cache");
sessionsBucket = couchbaseGetBucket("sessions-cache");
vectorsBucket = couchbaseGetBucket("vectors-cache");

// Access their collections independently
usersCollection = usersBucket.defaultScope().defaultCollection();
sessionsCollection = sessionsBucket.defaultScope().defaultCollection();
vectorsCollection = vectorsBucket.defaultScope().defaultCollection();
```

### Bucket Statistics

```js
bucket = couchbaseGetBucket("default");

// Get bucket info (requires cluster admin)
cluster = couchbaseGetCluster("default");
bucketManager = cluster.buckets();
bucketSettings = bucketManager.getBucket(bucket.name());

println("RAM quota: #bucketSettings.ramQuota()# MB");
println("Replica count: #bucketSettings.numReplicas()#");
```

## Notes

* Bucket name is determined by cache configuration
* Bucket instance is cached and reused
* Use `couchbaseGetCollection()` for direct collection access
* Most operations should use collection-level access
* Bucket-level access is useful for management and statistics

## Related Functions

* [couchbaseGetCluster](/boxlang-+-++/modules/bx-couchbase/built-in-functions/couchbasegetcluster.md) - Get cluster connection
* [couchbaseGetScope](/boxlang-+-++/modules/bx-couchbase/built-in-functions/couchbasegetscope.md) - Get scope instance
* [couchbaseGetCollection](/boxlang-+-++/modules/bx-couchbase/built-in-functions/couchbasegetcollection.md) - Get collection instance

## See Also

* [API Usage Guide](/boxlang-+-++/modules/bx-couchbase/api-usage.md)
* [Couchbase Bucket API](https://docs.couchbase.com/java-sdk/current/howtos/managing-connections.html)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://boxlang.ortusbooks.com/boxlang-+-++/modules/bx-couchbase/built-in-functions/couchbasegetbucket.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
