Posts Query
Note: The Teachify Admin API is currently under development and not yet available for public use. This documentation is provided for preview purposes only.
Overview
Section titled “Overview”The Posts API allows you to retrieve blog posts and their categories for your school. You can list posts with pagination and filtering, fetch a single post by ID, and retrieve the list of post categories.
Available Queries
Section titled “Available Queries”Returns a paginated list of posts for the authenticated school, ordered by creation date (newest first). Soft-deleted posts are excluded.
Required scope: Requires the posts:read scope.
Parameters:
| Parameter | Type | Description |
|---|---|---|
filter | AdminPostFilter | Filter criteria (see Filtering) |
page | Int | Page number for pagination |
perPage | Int | Number of items per page (default: 20, max: 50) |
limit | Int | Alternative to perPage |
Returns:
- AdminPostPage object with:
nodes: Array of AdminPost objectscurrentPage: Current page numberhasNextPage: Whether there are more pageshasPreviousPage: Whether there are previous pagesnodesCount: Total number of items matching the querytotalPages: Total number of pages
Example:
query { posts( page: 1, perPage: 10 ) { nodes { id title subtitle slug published publishedAt accessType commentCount unrepliedCommentCount author { id name } category { id name } tags } currentPage hasNextPage hasPreviousPage nodesCount totalPages }}Returns a single post by ID, scoped to the current school. Returns null if the post does not exist or has been soft-deleted.
Required scope: Requires the posts:read scope.
Parameters:
| Parameter | Type | Description |
|---|---|---|
id | String! | The unique identifier of the post |
Returns:
- A single AdminPost object, or
nullif not found.
Example:
query { post(id: "post-123") { id title subtitle body excerpt slug coverPhoto published publishedAt noindex accessType createdAt updatedAt author { id name } category { id name } tags }}postCategories
Section titled “postCategories”Returns the list of active post categories for the authenticated school, ordered by position (ascending).
Required scope: Requires the posts:read scope.
Parameters:
This query takes no arguments.
Returns:
- A connection of Category objects with:
nodes: Array of Category objectspageInfo: Relay page info (hasNextPage,hasPreviousPage,startCursor,endCursor)
Example:
query { postCategories { nodes { id name slug description coverPhoto } pageInfo { hasNextPage endCursor } }}Post Object
Section titled “Post Object”The AdminPost object contains the following fields:
| Field | Type | Description |
|---|---|---|
id | String! | Unique identifier |
title | String! | The post title |
subtitle | String | The post subtitle |
body | String! | The full body content of the post |
excerpt | String | A short excerpt of the post |
slug | String! | The URL-friendly identifier for the post |
coverPhoto | String | The URL of the post’s cover photo |
published | Boolean! | Whether the post is published |
publishedAt | Int | Unix Timestamp. When the post was published |
createdAt | Int! | Unix Timestamp. When the post was created |
updatedAt | Int! | Unix Timestamp. When the post was last updated |
noindex | Boolean! | Whether search engines are instructed not to index the post |
accessType | String! | The access level of the post |
author | Lecturer | The author of the post |
tags | [String] | The list of tag names applied to the post |
category | Category | The category the post belongs to |
commentCount | Int! | Total number of top-level comments |
unrepliedCommentCount | Int! | Number of top-level comments with no replies |
Category Object
Section titled “Category Object”The Category object (returned by postCategories) contains the following fields:
| Field | Type | Description |
|---|---|---|
id | String! | The unique identifier of the category |
name | String! | The name of the category |
slug | String | The URL-friendly identifier for the category |
description | String | A detailed description of the category |
coverPhoto | String | The URL of the category’s cover photo |
Filtering
Section titled “Filtering”The posts query accepts a filter parameter of type AdminPostFilter. This allows you to narrow down results based on various criteria.
Available Filters
Section titled “Available Filters”| Filter Field | Type | Description |
|---|---|---|
id | StringOperator | Filter by post ID |
title | StringOperator | Filter by post title |
slug | StringOperator | Filter by post slug |
accessType | StringOperator | Filter by access type |
publishedAt | IntOperator | Filter by published timestamp (Unix seconds) |
createdAt | IntOperator | Filter by creation timestamp (Unix seconds) |
updatedAt | IntOperator | Filter by update timestamp (Unix seconds) |
published | Boolean | Filter by published flag |
tags | [String] | Return posts tagged with any of the given tags |
categoryIds | [String] | Return posts in the given categories (including their subcategories) |
StringOperator
Section titled “StringOperator”The StringOperator used in filters has these operations:
| Operation | Description |
|---|---|
eq | Equal to |
neq | Not equal to |
in | In a list of values |
nin | Not in a list of values |
like | Match text values against a pattern using wildcards (case-sensitive) |
contains | Contains substring (case-insensitive) |
IntOperator
Section titled “IntOperator”The IntOperator used in timestamp filters has these operations:
| Operation | Description |
|---|---|
eq | Equal to |
neq | Not equal to |
gt | Greater than |
gte | Greater than or equal to |
lt | Less than |
lte | Less than or equal to |
Filter Examples
Section titled “Filter Examples”Find published posts:
query { posts( filter: { published: true } ) { nodes { id title publishedAt } nodesCount }}Find posts by tag:
query { posts( filter: { tags: ["marketing", "product"] } ) { nodes { id title tags } nodesCount }}Find posts in specific categories:
query { posts( filter: { categoryIds: ["cat-123", "cat-456"] } ) { nodes { id title category { id name } } nodesCount }}Find posts published after a given time:
query { posts( filter: { publishedAt: { gte: 1700000000 } } ) { nodes { id title publishedAt } nodesCount }}