List tags
Log in to add to favouritesGet 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
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
Name | Type | Description |
---|---|---|
groupId | string | The tag GUID identifier |
options | TagListOptions | An 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
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)
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)
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
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']}`);
}