### Example Pagination Usage in TypeScript Source: https://github.com/usemarble/marble-ts/blob/main/docs/models/pagination.md Demonstrates how to import and instantiate the Pagination model in TypeScript. This example shows the structure of a Pagination object with all its fields. ```typescript import { Pagination } from "@usemarble/sdk/models"; let value: Pagination = { limit: 10, currentPage: 1, nextPage: 2, previousPage: null, totalPages: 5, totalItems: 42, }; ``` -------------------------------- ### Install @usemarble/sdk Package Source: https://context7.com/usemarble/marble-ts/llms.txt Installs the Marble SDK package using various package managers like npm, pnpm, yarn, or bun. ```bash npm add @usemarble/sdk # or pnpm add @usemarble/sdk # or yarn add @usemarble/sdk # or bun add @usemarble/sdk ``` -------------------------------- ### Install @usemarble/sdk using NPM, PNPM, Bun, or Yarn Source: https://github.com/usemarble/marble-ts/blob/main/README.md Instructions for installing the @usemarble/sdk package using popular JavaScript package managers like NPM, PNPM, Bun, and Yarn. The package supports both CommonJS and ES Modules (ESM). ```bash npm add @usemarble/sdk ``` ```bash pnpm add @usemarble/sdk ``` ```bash bun add @usemarble/sdk ``` ```bash yarn add @usemarble/sdk ``` -------------------------------- ### Example Usage of TagsListResponse in TypeScript Source: https://github.com/usemarble/marble-ts/blob/main/docs/models/tagslistresponse.md Demonstrates how to instantiate and use the TagsListResponse model in TypeScript. This example shows the expected structure for tags and pagination data. ```typescript import { TagsListResponse } from "@usemarble/sdk/models"; let value: TagsListResponse = { tags: [ { id: "cryitfjp4567no07ygqadhm1", name: "JavaScript", slug: "javascript", description: "JavaScript tutorials", count: { posts: 8, }, }, ], pagination: { limit: 10, currentPage: 1, nextPage: 2, previousPage: null, totalPages: 5, totalItems: 42, }, }; ``` -------------------------------- ### PostResponse Model Example (TypeScript) Source: https://github.com/usemarble/marble-ts/blob/main/docs/models/postresponse.md Demonstrates how to import and use the PostResponse model from the @usemarble/sdk in TypeScript. This example shows the structure of a typical PostResponse object, including nested post details, author information, category, and tags. ```typescript import { PostResponse } from "@usemarble/sdk/models"; let value: PostResponse = { post: { id: "cryitfjp5678mn09qrstuvwx", slug: "getting-started-with-nextjs", title: "Getting Started with Next.js", content: "
Hello world
", featured: false, coverImage: "https://media.marblecms.com/cover.jpg", description: "A beginner's guide to Next.js", publishedAt: new Date("2024-01-15T10:00:00Z"), updatedAt: new Date("2024-01-16T12:00:00Z"), attribution: { author: "John Doe", url: "https://original-source.com/article", }, authors: [ { id: "cryitfjp1234jl04vdnycek8", name: "John Doe", image: "https://media.marblecms.com/avatar.jpg", bio: "Technical writer and developer", role: "Editor", slug: "john-doe", socials: [], }, ], category: { id: "cryitfjp1234jl04vdnycek8", name: "Technology", slug: "technology", description: "Tech news and tutorials", }, tags: [ { id: "cryitfjp1234jl04vdnycek8", name: "JavaScript", slug: "javascript", description: "JavaScript tutorials", }, ], }, }; ``` -------------------------------- ### Get Author Data using Marble SDK (TypeScript) Source: https://github.com/usemarble/marble-ts/blob/main/docs/sdks/authors/README.md Demonstrates how to fetch author information using the `get` method from the Marble SDK's authors module. It initializes the Marble client with an API key and calls the `get` method with an author identifier. Requires the @usemarble/sdk package. ```typescript import { Marble } from "@usemarble/sdk"; const marble = new Marble({ apiKey: process.env["MARBLE_API_KEY"] ?? "", }); async function run() { const result = await marble.authors.get({ identifier: "john-doe", }); console.log(result); } run(); ``` -------------------------------- ### AuthorsListResponse Model Example Usage (TypeScript) Source: https://github.com/usemarble/marble-ts/blob/main/docs/models/authorslistresponse.md Demonstrates how to instantiate and use the AuthorsListResponse model in TypeScript. This example shows the structure of the response, including the list of authors and pagination details. ```typescript import { AuthorsListResponse } from "@usemarble/sdk/models"; let value: AuthorsListResponse = { authors: [ { id: "cryitfjp3456lm06xfpzcgl0", name: "John Doe", image: "https://media.marblecms.com/avatar.jpg", slug: "john-doe", bio: "Technical writer and developer", role: "Editor", socials: [], count: { posts: 12, }, }, ], pagination: { limit: 10, currentPage: 1, nextPage: 2, previousPage: null, totalPages: 5, totalItems: 42, }, }; ``` -------------------------------- ### Example Usage of GetV1PostsResponse in TypeScript Source: https://github.com/usemarble/marble-ts/blob/main/docs/models/operations/getv1postsresponse.md Demonstrates how to import and utilize the GetV1PostsResponse model in a TypeScript application. This example shows the structure of the response object, including posts and pagination details. ```typescript import { GetV1PostsResponse } from "@usemarble/sdk/models/operations"; let value: GetV1PostsResponse = { result: { posts: [ { id: "cryitfjp5678mn09qrstuvwx", slug: "getting-started-with-nextjs", title: "Getting Started with Next.js", content: "Hello world
", featured: false, coverImage: "https://media.marblecms.com/cover.jpg", description: "A beginner's guide to Next.js", publishedAt: new Date("2024-01-15T10:00:00Z"), updatedAt: new Date("2024-01-16T12:00:00Z"), attribution: { author: "John Doe", url: "https://original-source.com/article", }, authors: [], category: { id: "cryitfjp1234jl04vdnycek8", name: "Technology", slug: "technology", description: "Tech news and tutorials", }, tags: [ { id: "cryitfjp1234jl04vdnycek8", name: "JavaScript", slug: "javascript", description: "JavaScript tutorials", }, ], }, ], pagination: { limit: 10, currentPage: 1, nextPage: 2, previousPage: null, totalPages: 5, totalItems: 42, }, }, }; ``` -------------------------------- ### Example Usage of AuthorResponse Model (TypeScript) Source: https://github.com/usemarble/marble-ts/blob/main/docs/models/authorresponse.md Demonstrates how to import and instantiate the AuthorResponse model in TypeScript. This example shows the structure of the data expected for an author, including their ID, name, image, slug, bio, role, social links, and post count. ```typescript import { AuthorResponse } from "@usemarble/sdk/models"; let value: AuthorResponse = { author: { id: "cryitfjp3456lm06xfpzcgl0", name: "John Doe", image: "https://media.marblecms.com/avatar.jpg", slug: "john-doe", bio: "Technical writer and developer", role: "Editor", socials: [], count: { posts: 12, }, }, }; ``` -------------------------------- ### Instantiate Security Model in TypeScript Source: https://github.com/usemarble/marble-ts/blob/main/docs/models/security.md Demonstrates how to import and initialize an empty Security object using the Marble TS SDK. This serves as a basic starting point for defining security-related configurations. ```typescript import { Security } from "@usemarble/sdk/models"; let value: Security = {}; ``` -------------------------------- ### Fetch Posts with Filtering using Marble SDK (TypeScript) Source: https://github.com/usemarble/marble-ts/blob/main/USAGE.md This snippet demonstrates how to initialize the Marble SDK and fetch a list of posts with multiple filtering criteria. It includes options for limiting results, pagination, including/excluding categories and tags, searching by query, specifying format, and filtering by featured posts. The output is iterated through using an async generator. ```typescript import { Marble } from "@usemarble/sdk"; const marble = new Marble({ apiKey: process.env["MARBLE_API_KEY"] ?? "", }); async function run() { const result = await marble.posts.list({ limit: 10, page: 1, categories: [ "tech", "news", ], excludeCategories: [ "changelog", ], tags: [ "javascript", "react", ], excludeTags: [ "outdated", ], query: "nextjs", format: "html", featured: "true", }); for await (const page of result) { console.log(page); } } run(); ``` -------------------------------- ### Initialize Marble SDK with Custom Server URL Source: https://github.com/usemarble/marble-ts/blob/main/README.md Demonstrates how to initialize the Marble SDK client with a custom server URL by passing the `serverURL` parameter. This allows you to direct API calls to a specific endpoint. The example also shows a typical usage of the `marble.posts.list` method with various filtering options. ```typescript import { Marble } from "@usemarble/sdk"; const marble = new Marble({ serverURL: "https://api.marblecms.com", apiKey: process.env["MARBLE_API_KEY"] ?? "", }); async function run() { const result = await marble.posts.list({ limit: 10, page: 1, categories: [ "tech", "news", ], excludeCategories: [ "changelog", ], tags: [ "javascript", "react", ], excludeTags: [ "outdated", ], query: "nextjs", format: "html", featured: "true", }); for await (const page of result) { console.log(page); } } run(); ``` -------------------------------- ### Instantiate CategoriesListResponse in TypeScript Source: https://github.com/usemarble/marble-ts/blob/main/docs/models/categorieslistresponse.md Demonstrates how to import and create an instance of the CategoriesListResponse model in TypeScript. This example shows the structure with empty categories and pagination details. ```typescript import { CategoriesListResponse } from "@usemarble/sdk/models"; let value: CategoriesListResponse = { categories: [], pagination: { limit: 10, currentPage: 1, nextPage: 2, previousPage: null, totalPages: 5, totalItems: 42, }, }; ``` -------------------------------- ### Example Usage of Marble TS Detail Model Source: https://github.com/usemarble/marble-ts/blob/main/docs/models/detail.md Demonstrates how to import and instantiate the Detail model in TypeScript. This model is used to represent detailed error or informational messages within the Marble SDK. ```typescript import { Detail } from "@usemarble/sdk/models"; let value: Detail = { field: "limit", message: "Expected number, received string", }; ``` -------------------------------- ### Instantiate Tag Model in TypeScript Source: https://github.com/usemarble/marble-ts/blob/main/docs/models/tag.md Demonstrates how to create an instance of the Tag model using TypeScript. This example shows the expected structure for a Tag object, including its ID, name, slug, description, and post count. ```typescript import { Tag } from "@usemarble/sdk/models"; let value: Tag = { id: "cryitfjp4567no07ygqadhm1", name: "JavaScript", slug: "javascript", description: "JavaScript tutorials", count: { posts: 8, }, }; ``` -------------------------------- ### Import ServerError Model (TypeScript) Source: https://github.com/usemarble/marble-ts/blob/main/docs/models/errors/servererror.md Demonstrates how to import the ServerError model from the @usemarble/sdk. Currently, no specific usage examples are available for this model. ```typescript import { ServerError } from "@usemarble/sdk/models/errors"; // No examples available for this model ``` -------------------------------- ### Instantiate CategoryResponse in TypeScript Source: https://github.com/usemarble/marble-ts/blob/main/docs/models/categoryresponse.md Demonstrates how to create an instance of the CategoryResponse model in TypeScript. This requires importing the model from the @usemarble/sdk/models package. The example shows the expected structure for the category object within the response. ```typescript import { CategoryResponse } from "@usemarble/sdk/models"; let value: CategoryResponse = { category: { id: "cryitfjp2345kl05weoybfk9", name: "Technology", slug: "technology", description: "Tech news and tutorials", count: { posts: 15, }, }, }; ``` -------------------------------- ### Initialize GetV1CategoriesResponse in TypeScript Source: https://github.com/usemarble/marble-ts/blob/main/docs/models/operations/getv1categoriesresponse.md Demonstrates how to import and initialize the GetV1CategoriesResponse model in TypeScript. This example shows the expected structure for the response, including the nested result object with categories and pagination details. ```typescript import { GetV1CategoriesResponse } from "@usemarble/sdk/models/operations"; let value: GetV1CategoriesResponse = { result: { categories: [], pagination: { limit: 10, currentPage: 1, nextPage: 2, previousPage: null, totalPages: 5, totalItems: 42, }, }, }; ``` -------------------------------- ### TypeScript Example Usage of Details Model Source: https://github.com/usemarble/marble-ts/blob/main/docs/models/details.md Demonstrates how to import and instantiate the Details model in TypeScript. This model is used to represent details about a paginated resource, including a message, total pages, and the requested page number. ```typescript import { Details } from "@usemarble/sdk/models"; let value: Details = { message: "Page 10 does not exist.", totalPages: 5, requestedPage: 10, }; ``` -------------------------------- ### Tags - Get Single Tag (TypeScript) Source: https://context7.com/usemarble/marble-ts/llms.txt Retrieves a single tag's details using its ID or slug. It initializes the Marble SDK, calls the `get` method on the `tags` service, and logs the tag's name, slug, description, and total post count. ```typescript import { Marble } from "@usemarble/sdk"; const marble = new Marble({ apiKey: process.env["MARBLE_API_KEY"] ?? "", }); async function getTag() { const result = await marble.tags.get({ identifier: "javascript", }); const tag = result.tag; console.log(`Name: ${tag.name}`); console.log(`Slug: ${tag.slug}`); console.log(`Description: ${tag.description}`); console.log(`Total Posts: ${tag.count.posts}`); } getTag(); ``` -------------------------------- ### Instantiate GetV1AuthorsResponse Model in TypeScript Source: https://github.com/usemarble/marble-ts/blob/main/docs/models/operations/getv1authorsresponse.md Demonstrates how to import and instantiate the GetV1AuthorsResponse model using the Marble TS SDK. This example shows the structure of the response object, including author details and pagination information. ```typescript import { GetV1AuthorsResponse } from "@usemarble/sdk/models/operations"; let value: GetV1AuthorsResponse = { result: { authors: [ { id: "cryitfjp3456lm06xfpzcgl0", name: "John Doe", image: "https://media.marblecms.com/avatar.jpg", slug: "john-doe", bio: "Technical writer and developer", role: "Editor", socials: [], count: { posts: 12, }, }, ], pagination: { limit: 10, currentPage: 1, nextPage: 2, previousPage: null, totalPages: 5, totalItems: 42, }, }, }; ``` -------------------------------- ### Create Category Object in TypeScript Source: https://github.com/usemarble/marble-ts/blob/main/docs/models/category.md Demonstrates how to instantiate a Category object using the Marble TS SDK. This example shows the required fields and their expected data types for a valid Category. ```typescript import { Category } from "@usemarble/sdk/models"; let value: Category = { id: "cryitfjp2345kl05weoybfk9", name: "Technology", slug: "technology", description: "Tech news and tutorials", count: { posts: 15, }, }; ``` -------------------------------- ### GetV1PostsRequest Model Source: https://github.com/usemarble/marble-ts/blob/main/docs/models/operations/getv1postsrequest.md This section details the structure and example usage of the GetV1PostsRequest model, used for fetching posts with various filtering and sorting options. ```APIDOC ## GetV1PostsRequest ### Description Represents a request object for fetching posts, allowing filtering by categories, tags, a search query, and specifying the desired format and featured status. ### Method N/A (This is a model definition, not an endpoint) ### Endpoint N/A ### Parameters #### Query Parameters - **limit** (number) - Optional - The maximum number of posts to return. - **page** (number) - Optional - The page number for pagination. - **categories** (string[]) - Optional - An array of category slugs to filter posts by. - **excludeCategories** (string[]) - Optional - An array of category slugs to exclude posts from. - **tags** (string[]) - Optional - An array of tag slugs to filter posts by. - **excludeTags** (string[]) - Optional - An array of tag slugs to exclude posts from. - **query** (string) - Optional - A search query string to filter posts. - **format** (string) - Optional - The desired format for the posts (e.g., 'html'). - **featured** (string) - Optional - A flag to filter for featured posts (e.g., 'true'). ### Request Example ```typescript { "limit": 10, "page": 1, "categories": [ "tech", "news" ], "excludeCategories": [ "changelog" ], "tags": [ "javascript", "react" ], "excludeTags": [ "outdated" ], "query": "nextjs", "format": "html", "featured": "true" } ``` ### Response #### Success Response (200) This model does not define a response structure. It is used as a request parameter. #### Response Example N/A ``` -------------------------------- ### Posts - Get Single Post Source: https://context7.com/usemarble/marble-ts/llms.txt Retrieves a single post by its ID or slug, with options to specify content format and status. ```APIDOC ## GET /posts/{identifier} ### Description Retrieve a single post by its ID or slug. Optionally specify content format (html or markdown) and status filter. ### Method GET ### Endpoint /posts/{identifier} ### Path Parameters - **identifier** (string) - Required - The ID or slug of the post to retrieve. ### Query Parameters - **format** (string) - Optional - The desired content format ('html' or 'markdown'). - **status** (string) - Optional - Filter by post status ('published', 'draft', etc.). ### Response #### Success Response (200) - **post** (object) - The post object containing details like title, content, author, category, tags, etc. #### Response Example { "post": { "id": "post-1", "title": "Getting Started with Next.js", "slug": "getting-started-with-nextjs", "description": "A comprehensive guide to starting your project with Next.js.", "content": "This is the HTML content of the post...
", "featured": false, "coverImage": "https://example.com/image.jpg", "publishedAt": "2023-10-26T09:00:00Z", "updatedAt": "2023-10-27T11:30:00Z", "category": { "id": "cat-1", "name": "Web Development", "slug": "web-dev" }, "authors": [ { "id": "author-1", "name": "Jane Smith", "slug": "jane-smith", "role": "Developer" } ], "tags": [ { "id": "tag-1", "name": "Next.js", "slug": "nextjs" }, { "id": "tag-2", "name": "React", "slug": "react" } ], "attribution": null } } ``` -------------------------------- ### Marble CMS Fields Source: https://github.com/usemarble/marble-ts/blob/main/docs/models/post.md This section details the fields available in the Marble CMS, including their types, whether they are required, and example values. ```APIDOC ## Fields This documentation outlines the fields available within the Marble CMS. ### Fields Overview | Field | Type | Required | Description | Example | |---|---|---|---|---| | `id` | string | Yes | N/A | cryitfjp5678mn09qrstuvwx | | `slug` | string | Yes | N/A | getting-started-with-nextjs | | `title` | string | Yes | N/A | Getting Started with Next.js | | `content` | string | Yes | N/A |Hello world
| | `featured` | boolean | Yes | N/A | false | | `coverImage` | string | Yes | N/A | https://media.marblecms.com/cover.jpg | | `description` | string | Yes | N/A | A beginner's guide to Next.js | | `publishedAt` | Date | Yes | N/A | 2024-01-15T10:00:00Z | ``` -------------------------------- ### Fetch Post by Identifier using Marble SDK (TypeScript) Source: https://github.com/usemarble/marble-ts/blob/main/docs/sdks/posts/README.md Demonstrates how to fetch a single post by its identifier using the Marble SDK's class-based approach. It initializes the Marble client with an API key and calls the `get` method on the `posts` service. The output is logged to the console. ```typescript import { Marble } from "@usemarble/sdk"; const marble = new Marble({ apiKey: process.env["MARBLE_API_KEY"] ?? "", }); async function run() { const result = await marble.posts.get({ identifier: "my-post-slug", format: "html", }); console.log(result); } run(); ``` -------------------------------- ### Import ErrorT Model (TypeScript) Source: https://github.com/usemarble/marble-ts/blob/main/docs/models/errors/errort.md Demonstrates how to import the ErrorT model from the Marble TS SDK. This is a foundational step for using the model in your TypeScript projects. No specific usage examples are available at this time. ```typescript import { ErrorT } from "@usemarble/sdk/models/errors"; // No examples available for this model ``` -------------------------------- ### GET /v1/authors Source: https://github.com/usemarble/marble-ts/blob/main/docs/sdks/authors/README.md Retrieves a list of authors. This endpoint can be used to get a single author by providing an ID or slug in the request. ```APIDOC ## GET /v1/authors ### Description Get a single author by ID or slug. ### Method GET ### Endpoint /v1/authors ### Parameters #### Query Parameters - **request** (operations.GetV1AuthorsRequest) - Required - The request object to use for the request. - **options** (RequestOptions) - Optional - Used to set various options for making HTTP requests. - **options.fetchOptions** (RequestInit) - Optional - 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) - Optional - Enables retrying HTTP requests under certain failure conditions. ### Response #### Success Response (200) - **Promise