You need to enable JavaScript to run this app.
Torch Object Storage

Torch Object Storage

Copy page
Download PDF
Vector bucket
GetVectorBucket(TOS Vectors Node.js SDK)
Copy page
Download PDF
GetVectorBucket(TOS Vectors Node.js SDK)
The getVectorBucket interface retrieves metadata for a vector Bucket. This article explains how to use the getVectorBucket interface in the TOS Vectors Node.js SDK to perform this operation.​
Notes​
  • You need to fill in the region and access domain name in the sample code according to your situation. For details, see Regions and Endpoints.​
  • To prevent key leakage, the sample code reads the Access Key ID and Secret Access Key from environment variables. Therefore, before using the SDK, configure long-term credentials. For details, see Configure long-term credentials.​
  • The TOS Vectors Node.js SDK supports temporary credentials and allows configuring timeout mechanisms, retry policies, and other settings. You can adjust these flexibly according to your business needs to enhance application security. For details, see Common configuration scenarios.​
Permissions required​
The main account has full permissions by default, while IAM users have no permissions by default. If a sub-account needs to perform getVectorBucket operations, the main account must grant the following permissions to the sub-account through IAM policies and bucket policies:​
tosvectors:GetVectorBucket​
Code examples​
Query information of the specified vector bucket​
​
// Query information of the specified vector bucket​
import {​
TosVectorsClient,​
TosClientError,​
TosServerError,​
} from "@volcengine/tos-sdk";​
​
// Create client​
const client = new TosVectorsClient({​
accessKeyId: process.env["TOS_ACCESS_KEY"],​
accessKeySecret: process.env["TOS_SECRET_KEY"],​
region: 'Provide your region', // Specify the region where the bucket is located. For example, if your bucket is in China (Beijing), replace "Provide your region" with "cn-beijing".​
endpoint: 'Provide your vector endpoint', // Specify domain address​
});​
​
const bucketName = 'Provide your vector bucket name';​
const accountId = process.env["TOS_ACCOUNT_ID"];​
​
function handleError(error: Error) {​
if (error instanceof TosClientError) {​
console.log("Client Err Msg:", error.message);​
console.log("Client Err Stack:", error.stack);​
} else if (error instanceof TosServerError) {​
console.log("Request ID:", error.requestId);​
console.log("Response Status Code:", error.statusCode);​
console.log("Response Header:", error.headers);​
console.log("Response Err Code:", error.code);​
console.log("Response Err Msg:", error.message);​
} else {​
console.log("unexpected exception, message: ", error);​
}​
}​
​
async function main() {​
try {​
const res = await client.getVectorBucket({​
vectorBucketName: bucketName,​
accountID: accountId,​
});​
console.log("vector bucket name", res.data.vectorBucket.vectorBucketName);​
console.log(​
"vector bucket creation time",​
res.data.vectorBucket.creationTime,​
);​
console.log("vector bucket trn", res.data.vectorBucket.vectorBucketTrn);​
} catch (error: any) {​
handleError(error);​
}​
}​
​
main();​
​
​
Related documentation​
For the API documentation of GetVectorBucket, see GetVectorBucket.​
​
Last updated: 2026.02.06 18:01:45