- list - List categories
- create - Create category
- get - Get category
- update - Update category
- delete - Delete category
Get a paginated list of categories
import { Marble } from "@usemarble/sdk";
const marble = new Marble({
apiKey: process.env["MARBLE_API_KEY"] ?? "",
});
async function run() {
const result = await marble.categories.list({});
for await (const page of result) {
console.log(page);
}
}
run();The standalone function version of this method:
import { MarbleCore } from "@usemarble/sdk/core.js";
import { categoriesList } from "@usemarble/sdk/funcs/categoriesList.js";
// Use `MarbleCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const marble = new MarbleCore({
apiKey: process.env["MARBLE_API_KEY"] ?? "",
});
async function run() {
const res = await categoriesList(marble, {});
if (res.ok) {
const { value: result } = res;
for await (const page of result) {
console.log(page);
}
} else {
console.log("categoriesList failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.GetV1CategoriesRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<operations.GetV1CategoriesResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.ErrorT | 400 | application/json |
| errors.PageNotFoundError | 400 | application/json |
| errors.ServerError | 500 | application/json |
| errors.MarbleDefaultError | 4XX, 5XX | */* |
Create a new category. Requires a private API key.
import { Marble } from "@usemarble/sdk";
const marble = new Marble({
apiKey: process.env["MARBLE_API_KEY"] ?? "",
});
async function run() {
const result = await marble.categories.create({
name: "Technology",
slug: "technology",
description: "Tech news and tutorials",
});
console.log(result);
}
run();The standalone function version of this method:
import { MarbleCore } from "@usemarble/sdk/core.js";
import { categoriesCreate } from "@usemarble/sdk/funcs/categoriesCreate.js";
// Use `MarbleCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const marble = new MarbleCore({
apiKey: process.env["MARBLE_API_KEY"] ?? "",
});
async function run() {
const res = await categoriesCreate(marble, {
name: "Technology",
slug: "technology",
description: "Tech news and tutorials",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("categoriesCreate failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
models.CreateCategoryBody | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<models.CreateCategoryResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.ErrorT | 400 | application/json |
| errors.ForbiddenError | 403 | application/json |
| errors.ConflictError | 409 | application/json |
| errors.ServerError | 500 | application/json |
| errors.MarbleDefaultError | 4XX, 5XX | */* |
Get a single category by ID or slug
import { Marble } from "@usemarble/sdk";
const marble = new Marble({
apiKey: process.env["MARBLE_API_KEY"] ?? "",
});
async function run() {
const result = await marble.categories.get({
identifier: "technology",
});
console.log(result);
}
run();The standalone function version of this method:
import { MarbleCore } from "@usemarble/sdk/core.js";
import { categoriesGet } from "@usemarble/sdk/funcs/categoriesGet.js";
// Use `MarbleCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const marble = new MarbleCore({
apiKey: process.env["MARBLE_API_KEY"] ?? "",
});
async function run() {
const res = await categoriesGet(marble, {
identifier: "technology",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("categoriesGet failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.GetV1CategoriesIdentifierRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<models.CategoryResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.NotFoundError | 404 | application/json |
| errors.ServerError | 500 | application/json |
| errors.MarbleDefaultError | 4XX, 5XX | */* |
Update an existing category by ID or slug. Requires a private API key.
import { Marble } from "@usemarble/sdk";
const marble = new Marble({
apiKey: process.env["MARBLE_API_KEY"] ?? "",
});
async function run() {
const result = await marble.categories.update({
identifier: "technology",
body: {
name: "Engineering",
slug: "engineering",
description: "Engineering articles and tutorials",
},
});
console.log(result);
}
run();The standalone function version of this method:
import { MarbleCore } from "@usemarble/sdk/core.js";
import { categoriesUpdate } from "@usemarble/sdk/funcs/categoriesUpdate.js";
// Use `MarbleCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const marble = new MarbleCore({
apiKey: process.env["MARBLE_API_KEY"] ?? "",
});
async function run() {
const res = await categoriesUpdate(marble, {
identifier: "technology",
body: {
name: "Engineering",
slug: "engineering",
description: "Engineering articles and tutorials",
},
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("categoriesUpdate failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.PatchV1CategoriesIdentifierRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<models.CreateCategoryResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.ErrorT | 400 | application/json |
| errors.ForbiddenError | 403 | application/json |
| errors.NotFoundError | 404 | application/json |
| errors.ConflictError | 409 | application/json |
| errors.ServerError | 500 | application/json |
| errors.MarbleDefaultError | 4XX, 5XX | */* |
Delete a category by ID or slug. Requires a private API key. Cannot delete a category that has posts assigned to it.
import { Marble } from "@usemarble/sdk";
const marble = new Marble({
apiKey: process.env["MARBLE_API_KEY"] ?? "",
});
async function run() {
const result = await marble.categories.delete({
identifier: "technology",
});
console.log(result);
}
run();The standalone function version of this method:
import { MarbleCore } from "@usemarble/sdk/core.js";
import { categoriesDelete } from "@usemarble/sdk/funcs/categoriesDelete.js";
// Use `MarbleCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const marble = new MarbleCore({
apiKey: process.env["MARBLE_API_KEY"] ?? "",
});
async function run() {
const res = await categoriesDelete(marble, {
identifier: "technology",
});
if (res.ok) {
const { value: result } = res;
console.log(result);
} else {
console.log("categoriesDelete failed:", res.error);
}
}
run();| Parameter | Type | Required | Description |
|---|---|---|---|
request |
operations.DeleteV1CategoriesIdentifierRequest | ✔️ | The request object to use for the request. |
options |
RequestOptions | ➖ | Used to set various options for making HTTP requests. |
options.fetchOptions |
RequestInit | ➖ | Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed. |
options.retries |
RetryConfig | ➖ | Enables retrying HTTP requests under certain failure conditions. |
Promise<models.DeleteResponse>
| Error Type | Status Code | Content Type |
|---|---|---|
| errors.ErrorT | 400 | application/json |
| errors.ForbiddenError | 403 | application/json |
| errors.NotFoundError | 404 | application/json |
| errors.ServerError | 500 | application/json |
| errors.MarbleDefaultError | 4XX, 5XX | */* |