Taxonomy
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.
| Name | Type | Description |
|---|---|---|
| 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.
| Name | Type | Description |
|---|---|---|
| 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.
| Name | Type | Description |
|---|---|---|
| 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.
| Name | Type | Description |
|---|---|---|
| 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.
| Name | Type | Description |
|---|---|---|
| include_terms_count | boolean | Whether to include the count of terms in the response. |
| include_referenced_terms_count | boolean | Whether to include the count of referenced terms in the response. |
| include_referenced_entries_count | boolean | Whether to include the count of referenced entries in the response. |
| include_count | boolean | Whether to include the total count of taxonomies in the response. |
| asc or desc | string | Sort order based on the UID field. |
| typeahead | string | Search string for typeahead functionality. |
| include_deleted | boolean | Whether to include deleted taxonomies in the response. |
| skip | number | Number of records to skip in pagination. |
| limit | number | Maximum number of records to return |
Response<ResponseBody> response = taxonomy.find().execute();
fetch
The fetch method retrieves the information of a specific taxonomy.
| Name | Type | Description |
|---|---|---|
| include_terms_count | boolean | Whether to include the count of terms in the response. |
| include_referenced_terms_count | boolean | Whether to include the count of referenced terms in the response. |
| include_referenced_entries_count | boolean | 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.
| Name | Type | Description |
|---|---|---|
| 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.
| Name | Type | Description |
|---|---|---|
| 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.
| Name | Type | Description |
|---|---|---|
| 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.
| Name | Type | Description |
|---|---|---|
| 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" ] }");
Responseterms
The terms method retrieves the information of the terms in the specific taxonomy.
| Name | Type | Description |
|---|---|---|
| taxonomyId (required) | string | UID of the taxonomy |
Term terms = stack("authtoken").taxonomy("taxonomyId").term();