Skip to main content

Get a list of all tags, tags belonging to a particular group, or supply options to find tags with a simple query or provide additional refinements.

Call signatures

TypeScript
list(): Promise<PagedList<Tag>>;

list(groupId: string): Promise<PagedList<Tag>>;

list({
    groupId?: string;
	language?: string;
	order?: string[];
	pageOptions?: PageOptions;
	q?: string;
}: TagListOptions): Promise<PagedList<Tag>>;

Parameters

NameTypeDescription
groupIdstringThe tag GUID identifier
optionsTagListOptionsAn options object to find tags with a simple query, in a specific groupId or language, provide paging options or to order results by specific tag fields

Returns

A Promise that will resolve with a PagedList of Tag

Remarks

Throws any error that is returned by the API for any unsuccessful request echoing the HTTP status returned from the API

Examples

Get a list of all tags in any group (with the pageSize set in the client config)

TypeScript
const tags = await client.tags.list();

console.log(`Found ${tags.totalCount} tags`);

if (tags.totalCount > tags.pageSize)
    console.log(`Showing the first ${tags.pageSize}/${tags.totalCount}`);

for (const tag of tags.items) {
    console.log(`${tag.groupId}: ${tag.value} ${tag.label['en-GB']}`);
}

Get a list of tags in a specific group (with the pageSize set in the client config)

TypeScript
const tags = await client.tags.list("topics");

console.log(`Found ${tags.totalCount} tags in Topics`);

Get a list of tags from a specific tag group, filtered by a query in a specific language, results to be ordered by label, then by modified date descending, requesting the second page while returning (up to) 100 tags in each page

TypeScript
const tags = await client.tags.list({
    groupId: "topics",
    q: "Books",
    language: "en-GB",
    pageOptions: {
        pageSize: 100,
        pageIndex: 1
    },
    order: ["label", "-version.modifed"]
});

console.log(`Page ${tags.pageIndex + 1} of ${tags.pageCount}`);

for (const tag of tags.items) {
    console.log(`${tag.value} ${tag.label['en-GB']}`);
}

Still need help?

If you still need help after reading this article, don't hesitate to reach out to the Contensis community on Slack or raise a support ticket to get help from our team.
New support request