Filtering - Ghost Developer Docs
https://docs.ghost.org/content-api/filtering • 277 KB fetched Open original page
Filtering - Ghost Developer Docs
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Skip to main content
Ghost Developer Docs home page
Search...
⌘ K
* Sign in
* Get Started
* Get Started
Search...
Navigation
Content API
Filtering
Home
Documentation
Migration Guides
*
Tutorials
*
Developer Forum
Getting Started
* Introduction
* Installation
* Hosting Guide
* Updates & Versions
Core Concepts
* Overview
* Architecture
* Configuration
* Staff Users
* Publishing
* Memberships
* Recommendations
* Newsletters
* Security
Themes
* Overview
* Structure
* Contexts
* Assets
* Helpers
* Content
* Search
* Share
* Members
* Routing
* Custom Settings
* GScan
Advanced Tools
* Ghost CLI
* Content API
* Overview
* Posts
* Pages
* Tags
* Authors
* Settings
* Tiers
* Parameters
* Filtering
* Pagination
* Errors
* Versioning
* JavaScript Client
* Admin API
* JAMstack
* Webhooks
Resources
* FAQ
* Breaking Changes
* Contributing
* LLM
* License
* Logos
* Trademark
On this page
* Syntax Reference
* Filter Expressions
* Property
* Value
* Operators
* Combinations
* Strings vs Literals
Advanced Tools
Content API
Filtering
Ghost uses a query language called NQL to allow filtering API results. You can filter any field or included field using matches, greater/less than or negation, as well as combining with and/or. NQL doesn’t yet support ’like’ or partial matches.
Filter strings must be URL encoded. The {{get}} helper and client library handle this for you.
At it’s most simple, filtering works the same as in GMail, GitHub or Slack - you provide a field and a value, separated by a colon.
Syntax Reference
Filter Expressions
A filter expression is a string which provides the property , operator and value in the form property: operator value :
* property - a path representing the field to filter on
* : - separator between property and an operator - value expression
* operator (optional) - how to compare values ( : on its own is roughly = )
* value - the value to match against
Property
Matches: [a-zA-Z_][a-zA-Z0-9_.]
* can contain only alpha-numeric characters and _
* cannot contain whitespace
* must start with a letter
* supports . separated paths, E.g. authors.slug or posts.count
* is always lowercase, but accepts and converts uppercase
Value
Can be one of the following
*
null
*
true
*
false
*
a number (integer)
*
a literal
* Any character string which follows these rules:
* Cannot start with - but may contain it
* Cannot contain any of these symbols: '"+,()><=[] unless they are escaped
* Cannot contain whitespace
*
a string
* ' string here ' Any character except a single or double quote surrounded by single quotes
* Single or Double quote __MUST __be escaped*
* Can contain whitespace
* A string can contain a date any format that can be understood by new Date()
*
a relative date
* Uses the pattern now-30d
* Must start with now
* Can use - or +
* Any integer can be used for the size of the interval
* Supports the following intervals: d, w, M, y, h, m, s
Operators
* - - not
* > - greater than
* >= - greater than or equals
* < - less than
* <= - less than or equals
* ~ - contains
* ~^ - starts with
* ~$ - ends with
* [ value, value, … ] - “in” group, can be negated with -
Combinations
* + - represents and
* , - represents or
* ( filter expression ) - overrides operator precedence
Strings vs Literals
Most of the time, there’s no need to put quotes around strings when building filters in Ghost. If you filter based on slugs, slugs are always compatible with literals. However, in some cases you may need to use a string that contains one of the other characters used in the filter syntax, e.g. dates & times contain : . Use single-quotes for these.
Suggest edits Raise issue
Parameters
Pagination
github twitter bluesky reddit
Powered by This documentation is built and hosted on Mintlify, a developer documentation platform
Links found on this page
- /llms.txt [direct]
- Skip to main content [direct]
- Ghost Developer Docs home page [direct]
- Sign in [direct]
- Get Started [direct]
- Home [direct]
- Documentation [direct]
- Migration Guides [direct]
- Tutorials [direct]
- Developer Forum [direct]
- Installation [direct]
- Hosting Guide [direct]
- Updates & Versions [direct]
- Overview [direct]
- Architecture [direct]
- Configuration [direct]
- Staff Users [direct]
- Publishing [direct]
- Memberships [direct]
- Recommendations [direct]
- Newsletters [direct]
- Security [direct]
- Overview [direct]
- Structure [direct]
- Assets [direct]
- Content [direct]
- Search [direct]
- Share [direct]
- Members [direct]
- Routing [direct]
- Custom Settings [direct]
- GScan [direct]
- Ghost CLI [direct]
- Overview [direct]
- Posts [direct]
- Pages [direct]
- Tags [direct]
- Authors [direct]
- Settings [direct]
- Tiers [direct]
- Parameters [direct]
- Pagination [direct]
- Errors [direct]
- Versioning [direct]
- JavaScript Client [direct]
- Webhooks [direct]
- FAQ [direct]
- Breaking Changes [direct]
- Contributing [direct]
- LLM [direct]
- License [direct]
- Logos [direct]
- Trademark [direct]
- {{get}} [direct]
- Suggest edits [direct]
- Raise issue [direct]
- github [direct]
- twitter [direct]
- bluesky [direct]
- reddit [direct]
- Powered by This documentation is built and hosted on Mintlify, a developer documentation platform [direct]
|
|