Search, filtering, and pagination

View as Markdown

This guide explains how to retrieve and refine data efficiently using AISquare APIs.

These features are essential for building:

  • Discovery pages
  • Search experiences
  • Scalable feeds

Overview

Most AISquare endpoints support:

  • Search
  • Filtering
  • Sorting
  • Pagination

These are applied using query parameters.


Search allows you to retrieve content using free text.

Example

GET /api/v1/aistudios/experiences/flattened/?search=machine%20learning

What search covers

Search typically works across:

  • Titles
  • Tags
  • Categories
  • Focus areas

Best practices

  • Keep search queries simple
  • Avoid overly long strings
  • Combine with filters for better results

Filtering

Filtering allows you to narrow down results based on specific fields.

Common filters

ParameterDescription
typeFilter by resource type
categoryFilter by category ID
category_nameFilter by category name
tagsFilter by tags
publication_urlFilter by specific studio

Example

GET /api/v1/aistudios/experiences/flattened/?type=AI_EXPERT&category_name=ai

Multiple filters

You can combine filters:

GET /api/v1/aistudios/experiences/flattened/?type=AI_NOTE&search=data

Sorting

Sorting controls the order of results.

Supported options

ValueDescription
trendingBased on engagement and recency
newestMost recently created
popularHighest engagement
updatedRecently updated

Example

GET /api/v1/aistudios/experiences/flattened/?ordering=trending

Ascending vs descending

Use - prefix for descending order:

GET /api/v1/aistudios/experiences/flattened/?ordering=-newest

Pagination

Pagination allows you to retrieve large datasets in smaller chunks.

Parameters

ParameterDescription
pagePage number
page_sizeNumber of results per page

Example

GET /api/v1/aistudios/experiences/flattened/?page=1&page_size=10

Response structure

1{
2 "count": 100,
3 "next": "url_to_next_page",
4 "previous": null,
5 "results": []
6}

How to use pagination

  • Use next to load more results
  • Stop when next is null

Combining everything

You can use search, filters, sorting, and pagination together.

Example

GET /api/v1/aistudios/experiences/flattened/?search=ai&type=AI_EXPERT&ordering=trending&page=1&page_size=10

Performance best practices

Use pagination always

Avoid fetching large datasets in a single request.

Limit page size

Use reasonable values like:

  • 10–20 items per page

Combine filters early

Reduce unnecessary data transfer.

Cache frequent queries

Especially for:

  • Trending content
  • Popular resources

Common mistakes

Fetching all data at once

Leads to slow performance and large payloads.

Not handling pagination

Missing next leads to incomplete data.

Use filters when possible for better performance.


Example implementation flow

  1. User searches for “ai”
  2. Apply filters (type = AI_EXPERT)
  3. Sort by trending
  4. Fetch page 1
  5. Load more using next