Skip to content

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.

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.

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:

ParameterTypeDescription
filterAdminPostFilterFilter criteria (see Filtering)
pageIntPage number for pagination
perPageIntNumber of items per page (default: 20, max: 50)
limitIntAlternative to perPage

Returns:

  • AdminPostPage object with:
    • nodes: Array of AdminPost objects
    • currentPage: Current page number
    • hasNextPage: Whether there are more pages
    • hasPreviousPage: Whether there are previous pages
    • nodesCount: Total number of items matching the query
    • totalPages: 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:

ParameterTypeDescription
idString!The unique identifier of the post

Returns:

  • A single AdminPost object, or null if 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
}
}

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 objects
    • pageInfo: Relay page info (hasNextPage, hasPreviousPage, startCursor, endCursor)

Example:

query {
postCategories {
nodes {
id
name
slug
description
coverPhoto
}
pageInfo {
hasNextPage
endCursor
}
}
}

The AdminPost object contains the following fields:

FieldTypeDescription
idString!Unique identifier
titleString!The post title
subtitleStringThe post subtitle
bodyString!The full body content of the post
excerptStringA short excerpt of the post
slugString!The URL-friendly identifier for the post
coverPhotoStringThe URL of the post’s cover photo
publishedBoolean!Whether the post is published
publishedAtIntUnix Timestamp. When the post was published
createdAtInt!Unix Timestamp. When the post was created
updatedAtInt!Unix Timestamp. When the post was last updated
noindexBoolean!Whether search engines are instructed not to index the post
accessTypeString!The access level of the post
authorLecturerThe author of the post
tags[String]The list of tag names applied to the post
categoryCategoryThe category the post belongs to
commentCountInt!Total number of top-level comments
unrepliedCommentCountInt!Number of top-level comments with no replies

The Category object (returned by postCategories) contains the following fields:

FieldTypeDescription
idString!The unique identifier of the category
nameString!The name of the category
slugStringThe URL-friendly identifier for the category
descriptionStringA detailed description of the category
coverPhotoStringThe URL of the category’s cover photo

The posts query accepts a filter parameter of type AdminPostFilter. This allows you to narrow down results based on various criteria.

Filter FieldTypeDescription
idStringOperatorFilter by post ID
titleStringOperatorFilter by post title
slugStringOperatorFilter by post slug
accessTypeStringOperatorFilter by access type
publishedAtIntOperatorFilter by published timestamp (Unix seconds)
createdAtIntOperatorFilter by creation timestamp (Unix seconds)
updatedAtIntOperatorFilter by update timestamp (Unix seconds)
publishedBooleanFilter 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)

The StringOperator used in filters has these operations:

OperationDescription
eqEqual to
neqNot equal to
inIn a list of values
ninNot in a list of values
likeMatch text values against a pattern using wildcards (case-sensitive)
containsContains substring (case-insensitive)

The IntOperator used in timestamp filters has these operations:

OperationDescription
eqEqual to
neqNot equal to
gtGreater than
gteGreater than or equal to
ltLess than
lteLess than or equal to

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
}
}