Taxonomy

View as Markdown

Taxonomy

Taxonomy helps you categorize pieces of content within your stack to facilitate easy navigation, search, and retrieval of information. You can hierarchically organize your web properties based on your requirements, such as their purpose, target audience, or any other aspects of your business.

addParam

The addParam method adds a parameter to a collection using a key-value pair.

NameTypeDescription
key (required)string

The key of the parameter

value (required)Object

The value of the parameter

import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Taxonomy taxonomy = contentstack.taxonomy ();
taxonomy.addParam("key", "value");

addHeader

The addHeader method adds a header with a key-value pair to a request.

NameTypeDescription
key (required)string

The key of the header

value (required)String

The value of the header

import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Taxonomy taxonomy = contentstack.taxonomy ();
taxonomy.addHeader("key", "value");

addHeaders

The addHeaders method adds a headers to a HashMap.

NameTypeDescription
headers (required)HashMap

The key-value pair of the header

import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Taxonomy taxonomy = contentstack.taxonomy ();
taxonomy.addHeaders("headers");

addParams

The addParams takes a HashMap of String keys and Object values as input and returns a generic type T.

NameTypeDescription
params (required)HashMap

The parameters to be added

import contentstack;
Contentstack contentstack = new Contentstack.Builder().build();
Taxonomy taxonomy = contentstack.taxonomy ();
taxonomy.addParams("params");

find

The find method retrieves the list of all taxonomies in the stack.

NameTypeDescription
include_terms_countboolean

Whether to include the count of terms in the response.

include_referenced_terms_countboolean

Whether to include the count of referenced terms in the response.

include_referenced_entries_countboolean

Whether to include the count of referenced entries in the response.

include_countboolean

Whether to include the total count of taxonomies in the response.

asc or descstring

Sort order based on the UID field.

typeaheadstring

Search string for typeahead functionality.

include_deletedboolean

Whether to include deleted taxonomies in the response.

skipnumber

Number of records to skip in pagination.

limitnumber

Maximum number of records to return

Response<ResponseBody> response = taxonomy.find().execute();

fetch

The fetch method retrieves the information of a specific taxonomy.

NameTypeDescription
include_terms_countboolean

Whether to include the count of terms in the response.

include_referenced_terms_countboolean

Whether to include the count of referenced terms in the response.

include_referenced_entries_countboolean

Whether to include the count of referenced entries in the response.

taxonomyId (required)string

UID of the taxonomy

Response<ResponseBody> response = taxonomy.fetch("taxonomyId").execute();

create

The create method lets you add a new taxonomy in the stack.

NameTypeDescription
body (required)JSON Object

The request body to sent in the call.

JSONObject body = new JSONObject

     Response<ResponseBody> response = taxonomy.create(body).execute();

update

The update method lets you make changes in the existing taxonomy in the stack.

NameTypeDescription
taxonomyId (required)string

UID of the taxonomy

JSONObject body = new JSONObject();

     JSONObject bodyContent = new JSONObject();

     bodyContent.put("name", "Taxonomy 1");

     bodyContent.put("description", "Description updated for Taxonomy 1);

     body.put("taxonomy", bodyContent);

     Response<ResponseBody> response = taxonomy.update("taxonomyId", body).execute();

delete

The delete method lets you remove an existing taxonomy from the stack.

NameTypeDescription
taxonomyId (required)string

UID of the taxonomy

Response<ResponseBody> response = taxonomy.delete("taxonomyId").execute();

query

Get an instance of the taxonomy search filter class through which you can query on a taxonomy based on an entry endpoint. Provide the user's email address in JSON format.

NameTypeDescription
query (required)JSONObject

The query of type JSONObject.

import contentstack; 

Taxonomy taxonomy = new Contentstack.Builder()

       .setAuthtoken(TestClient.AUTHTOKEN)

       .setHost("api.contentstack.io")

       .build()

       .stack("apiKey")

       .taxonomy();

JSONObject query = new JSONObject();

query.put("taxonomies.taxonomy_uid", "{"$in" : ["term_uid1" , "term_uid2" ] }");

Response

terms

The terms method retrieves the information of the terms in the specific taxonomy.

NameTypeDescription
taxonomyId (required)string

UID of the taxonomy

Term terms = stack("authtoken").taxonomy("taxonomyId").term();