Api Filter logo

Api Filter

Organization
api-platform
api-filter

Adds filters to API Platform collections using the canonical QueryParameter approach. Use whenever the user wants search, sorting, date ranges, boolean/enum/numeric filtering, IRI lookups, free-text search, or any 'let users filter/search/sort the list by X' request on a collection — even if they never say 'filter'. Also use when migrating legacy #[ApiFilter]/SearchFilter code.

Overview

Publisherapi-platform
Repositoryskillset
Skill nameapi-filter
Stars
29
Forks
1
Bundled files
Instructions only
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by api-platform on GitHub. Read the source before you install it.

Installation

Install the Api Filter AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/api-platform/skillset/tree/main/skills/api-filter
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/api-platform/skillset.git /tmp/skillset
mkdir -p .claude/skills
cp -r /tmp/skillset/skills/api-filter .claude/skills/api-filter
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Api Filter in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Api Filter on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Api Filter is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Adding Filters to Collections

Declare filters with QueryParameter in the operation's parameters: array. The key is the query-string parameter exposed to clients; the filter: is the filter instance. This is the canonical approach for API Platform 4.4+ — it works with any state provider and is per-operation explicit.

php
use ApiPlatform\Metadata\GetCollection;
use ApiPlatform\Metadata\QueryParameter;
use ApiPlatform\Doctrine\Orm\Filter\ExactFilter;

#[GetCollection(
    parameters: [
        'status' => new QueryParameter(filter: new ExactFilter()),
    ],
)]
class Order {}

Client: GET /orders?status=shipped

#[ApiFilter] is legacy. The class-level #[ApiFilter(SearchFilter::class, ...)] attribute and the multi-strategy filters (SearchFilter, BooleanFilter, NumericFilter, OrderFilter, BackedEnumFilter) are deprecated in 4.4 and removed in 6.0. Don't teach or add them in new code. If you encounter them, the migration target is the QueryParameter + single-purpose filter set below. The mapping is in the table at the bottom.

Canonical filter set

Each filter does one thing. They live in two parallel namespaces — pick the one matching your persistence layer:

FilterPurposeORMMongoDB ODM
ExactFilterequality, multi-value (IN); booleans/ints/enums via nativeTypeApiPlatform\Doctrine\Orm\Filter\ExactFilterApiPlatform\Doctrine\Odm\Filter\ExactFilter
PartialSearchFilterLIKE %x% substring…\Orm\Filter\PartialSearchFilter…\Odm\Filter\PartialSearchFilter
ComparisonFiltergt/gte/lt/lte/ne (decorates an equality filter)…\Orm\Filter\ComparisonFilter…\Odm\Filter\ComparisonFilter
SortFilterORDER BY…\Orm\Filter\SortFilter…\Odm\Filter\SortFilter
DateFilterbefore/after date ranges…\Orm\Filter\DateFilter…\Odm\Filter\DateFilter
RangeFilterbetween/gt/lt on numbers…\Orm\Filter\RangeFilter…\Odm\Filter\RangeFilter
ExistsFilterIS NULL / IS NOT NULL…\Orm\Filter\ExistsFilter…\Odm\Filter\ExistsFilter
IriFilterrelationship lookup by IRI…\Orm\Filter\IriFilter…\Odm\Filter\IriFilter
OrFilterdecorator: switches a primary's WHERE to orWhere…\Orm\Filter\OrFilter…\Odm\Filter\OrFilter
FreeTextQueryFilterdecorator: broadcasts one value across N properties…\Orm\Filter\FreeTextQueryFilter…\Odm\Filter\FreeTextQueryFilter

ComparisonFilter and OrFilter are still marked @experimental in 4.4 — they are the intended migration target but their API may shift before stabilizing.

Common filters

Exact match

php
'status' => new QueryParameter(filter: new ExactFilter())

GET /orders?status=shipped. Arrays produce an IN: ?status[]=draft&status[]=sent.

Boolean / integer / enum — ExactFilter + nativeType

There is no BooleanFilter in the canonical set. Use ExactFilter and declare the native type so values are cast and documented correctly:

php
use Symfony\Component\TypeInfo\Type\BuiltinType;
use Symfony\Component\TypeInfo\TypeIdentifier;

'active' => new QueryParameter(
    filter: new ExactFilter(),
    nativeType: new BuiltinType(TypeIdentifier::BOOL),
),

GET /orders?active=true. Use TypeIdentifier::INT for integers; pass an enum's native type for backed enums.

Partial search (LIKE)

php
use ApiPlatform\Doctrine\Orm\Filter\PartialSearchFilter;

'q' => new QueryParameter(filter: new PartialSearchFilter(), property: 'title')

GET /books?q=harry. property: maps the public param name to the entity field.

Comparison (gt/gte/lt/lte/ne)

php
use ApiPlatform\Doctrine\Orm\Filter\ComparisonFilter;

'price' => new QueryParameter(filter: new ComparisonFilter(new ExactFilter()))

GET /products?price[gt]=100&price[lte]=500.

Date range

php
use ApiPlatform\Doctrine\Orm\Filter\DateFilter;

'createdAt' => new QueryParameter(filter: new DateFilter())

GET /orders?createdAt[after]=2024-01-01&createdAt[before]=2024-12-31.

Numeric range

php
use ApiPlatform\Doctrine\Orm\Filter\RangeFilter;

'price' => new QueryParameter(filter: new RangeFilter())

GET /products?price[between]=10..100.

Exists (null check)

php
use ApiPlatform\Doctrine\Orm\Filter\ExistsFilter;

'deletedAt' => new QueryParameter(filter: new ExistsFilter())

GET /orders?deletedAt[exists]=false.

Relation (IRI)

php
use ApiPlatform\Doctrine\Orm\Filter\IriFilter;

'author' => new QueryParameter(filter: new IriFilter())

GET /books?author=/authors/1.

Sorting — SortFilter

There is no OrderFilter in the canonical set. Use SortFilter. Two forms:

php
use ApiPlatform\Doctrine\Orm\Filter\SortFilter;

// Per-property named parameter
'orderName' => new QueryParameter(filter: new SortFilter(), property: 'name'),
// → GET /books?orderName=desc

// Dynamic, OrderFilter-style: one parameter, any allowed property
'order[:property]' => new QueryParameter(filter: new SortFilter()),
// → GET /books?order[name]=asc&order[createdAt]=desc

property: can traverse relations ('department.company.name' sorts across joins). Control null placement with nullsComparison:

php
use ApiPlatform\Doctrine\Common\Filter\OrderFilterInterface;

'orderHireDate' => new QueryParameter(
    filter: new SortFilter(nullsComparison: OrderFilterInterface::NULLS_ALWAYS_FIRST),
    property: 'hireDate',
),

Free-text across multiple fields

FreeTextQueryFilter decorates a primary and broadcasts one value to several properties; wrap with OrFilter to match any of them:

php
use ApiPlatform\Doctrine\Orm\Filter\FreeTextQueryFilter;
use ApiPlatform\Doctrine\Orm\Filter\OrFilter;
use ApiPlatform\Doctrine\Orm\Filter\ExactFilter;

'autocomplete' => new QueryParameter(
    filter: new FreeTextQueryFilter(new OrFilter(new ExactFilter())),
    properties: ['name', 'email', 'description'],
),

GET /users?autocomplete=alice.

Validating filter parameters

php
use Symfony\Component\Validator\Constraints as Assert;

'length' => new QueryParameter(
    filter: new ExactFilter(),
    constraints: [new Assert\Length(max: 100)],
)

Invalid values yield a 422 before the query runs.

Default ordering

Set a default sort directly on the operation (no parameter needed):

php
new GetCollection(order: ['createdAt' => 'DESC'])

Legacy → canonical migration map

Legacy (deprecated 4.4, removed 6.0)Canonical replacement
#[ApiFilter(SearchFilter::class, ['x' => 'exact'])]'x' => new QueryParameter(filter: new ExactFilter())
SearchFilter strategy partialPartialSearchFilter
BooleanFilterExactFilter + nativeType: BOOL
NumericFilterExactFilter + nativeType: INT
BackedEnumFilterExactFilter + enum nativeType
OrderFilterSortFilter
RangeFilter, DateFilter, ExistsFiltersame class — survives as drop-in, just move to QueryParameter

Laravel (Eloquent)

The QueryParameter wiring is identical, but Laravel ships its own Eloquent filter set under ApiPlatform\Laravel\Eloquent\Filter\ — these are not the Doctrine classes and the names differ. Declare them with class-level #[QueryParameter] / #[GetCollection(parameters: …)] on the model (or DTO). The key, property, properties, :property placeholder and constraints options work the same.

NeedDoctrine (above)Laravel Eloquent class
equalityExactFilterEqualsFilter
LIKE %x%PartialSearchFilterPartialSearchFilter
LIKE x% / %xStartSearchFilter / EndSearchFilterStartSearchFilter / EndSearchFilter
booleanExactFilter + nativeTypeBooleanFilter
date rangeDateFilterDateFilter (filterContext: ['include_nulls' => true] to keep nulls; default excludes)
numeric rangeRangeFilterRangeFilter
sortSortFilterOrderFilter
OROrFilterOrFilter (decorator: new OrFilter(new EqualsFilter()))
php
use ApiPlatform\Laravel\Eloquent\Filter\EqualsFilter;
use ApiPlatform\Laravel\Eloquent\Filter\OrderFilter;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\QueryParameter;

#[ApiResource]
#[QueryParameter(key: 'name', filter: EqualsFilter::class)]
#[QueryParameter(key: 'sort[:property]', filter: OrderFilter::class, properties: ['name', 'id'])]
class Book extends Model {}

Constraints are Laravel validation rules (a string/array), not Symfony constraints: new QueryParameter(key: 'name', filter: PartialSearchFilter::class, constraints: 'min:2'). Custom filters implement ApiPlatform\Laravel\Eloquent\Filter\FilterInterface (apply(Builder $builder, mixed $values, Parameter $parameter, array $context = []): Builder); scaffold with php artisan make:filter. There is no ExistsFilter, ComparisonFilter, IriFilter or FreeTextQueryFilter in the Eloquent set — nativeType on a parameter is also unused (use BooleanFilter for booleans). #[ApiFilter] is not the Laravel idiom; models declare #[QueryParameter] directly.

Frequently asked questions

What does the Api Filter AI skill do?

Adds filters to API Platform collections using the canonical QueryParameter approach. Use whenever the user wants search, sorting, date ranges, boolean/enum/numeric filtering, IRI lookups, free-text search, or any 'let users filter/search/sort the list by X' request on a collection — even if they never say 'filter'. Also use when migrating legacy #[ApiFilter]/SearchFilter code.

Why use Api Filter on TypingMind?

Because you install it once and use it with any model. Api Filter is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Api Filter in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/api-platform/skillset/tree/main/skills/api-filter. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Api Filter?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Api Filter?

As many as you like. As long as a model supports skills, you can use Api Filter with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Api Filter AI skill free?

It is published on GitHub by api-platform. Check the repository for licensing terms. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇