Filtering & Sorting
Introduction
Feedframer provides powerful filtering and sorting capabilities to help you retrieve exactly the data you need. This guide covers all available filters and sorting options for both REST and GraphQL APIs.
Filtering
Filter by Post Type
Retrieve posts of a specific type:
Types:
IMAGE- Single image postsVIDEO- Video postsCAROUSEL_ALBUM- Multi-image/video carousel postsREELS- Instagram Reels
REST API:
# Images only
GET /api/v1/me?api_key=YOUR_API_KEY&filter[type]=IMAGE
# Videos only
GET /api/v1/me?api_key=YOUR_API_KEY&filter[type]=VIDEO
# Reels only
GET /api/v1/me?api_key=YOUR_API_KEY&filter[type]=REELS
GraphQL:
query {
posts(first: 12, type: "IMAGE") {
data {
id
caption
mediaUrl
}
}
}
Filter by Instagram Account
When you have multiple Instagram accounts connected (Premium tier), filter by username:
REST API:
GET /api/v1/me?api_key=YOUR_API_KEY&filter[account]=your_username
GraphQL:
query {
posts(first: 12, account: "your_username") {
data {
id
caption
mediaUrl
}
}
}
Filter by Date Range
Retrieve posts published within a specific timeframe:
REST API:
# Posts from 2024 only
GET /api/v1/me?api_key=YOUR_API_KEY&filter[publishedAfter]=2024-01-01&filter[publishedBefore]=2024-12-31
# Posts from last 30 days
GET /api/v1/me?api_key=YOUR_API_KEY&filter[publishedAfter]=2024-01-01
# Posts before a specific date
GET /api/v1/me?api_key=YOUR_API_KEY&filter[publishedBefore]=2024-01-31
GraphQL:
query {
posts(
first: 12
publishedAfter: "2024-01-01T00:00:00Z"
publishedBefore: "2024-12-31T23:59:59Z"
) {
data {
id
caption
publishedAt
}
}
}
Date Format: Use ISO 8601 format (YYYY-MM-DD or YYYY-MM-DDTHH:MM:SSZ)
Combining Filters
All filters can be combined for precise queries:
REST API:
# Image posts from January 2024
GET /api/v1/me?api_key=YOUR_API_KEY&filter[type]=IMAGE&filter[publishedAfter]=2024-01-01&filter[publishedBefore]=2024-01-31
# Videos from specific account in 2024
GET /api/v1/me?api_key=YOUR_API_KEY&filter[type]=VIDEO&filter[account]=username&filter[publishedAfter]=2024-01-01
GraphQL:
query {
posts(
first: 12
type: "IMAGE"
account: "username"
publishedAfter: "2024-01-01T00:00:00Z"
publishedBefore: "2024-01-31T23:59:59Z"
) {
data {
id
caption
mediaUrl
}
}
}
Sorting
Sort by Published Date
REST API:
# Newest first (default)
GET /api/v1/me?api_key=YOUR_API_KEY&sort=-published_at
# Oldest first
GET /api/v1/me?api_key=YOUR_API_KEY&sort=published_at
GraphQL:
# Newest first
query {
posts(
first: 12
orderBy: [{ column: "published_at", order: DESC }]
) {
data {
id
publishedAt
}
}
}
# Oldest first
query {
posts(
first: 12
orderBy: [{ column: "published_at", order: ASC }]
) {
data {
id
publishedAt
}
}
}
Sort by ID
REST API:
# Highest ID first
GET /api/v1/me?api_key=YOUR_API_KEY&sort=-id
# Lowest ID first
GET /api/v1/me?api_key=YOUR_API_KEY&sort=id
GraphQL:
query {
posts(
first: 12
orderBy: [{ column: "id", order: DESC }]
) {
data {
id
}
}
}
Practical Examples
Latest 10 Posts
# REST
GET /api/v1/me?api_key=YOUR_API_KEY&page[size]=10&sort=-published_at
# GraphQL
query {
posts(first: 10, orderBy: [{ column: "published_at", order: DESC }]) {
data { id caption publishedAt }
}
}
All Images from Last Month
# REST
GET /api/v1/me?api_key=YOUR_API_KEY&filter[type]=IMAGE&filter[publishedAfter]=2024-01-01
# GraphQL
query {
posts(first: 100, type: "IMAGE", publishedAfter: "2024-01-01T00:00:00Z") {
data { id mediaUrl caption }
}
}
Videos from Specific Account
# REST
GET /api/v1/me?api_key=YOUR_API_KEY&filter[type]=VIDEO&filter[account]=username
# GraphQL
query {
posts(first: 50, type: "VIDEO", account: "username") {
data { id mediaUrl thumbnailUrl }
}
}
Tips & Best Practices
Use Specific Filters
The more specific your filters, the faster your queries and the less data transferred:
# ✅ Good - specific filter
GET /api/v1/me?api_key=YOUR_API_KEY&filter[type]=IMAGE&filter[publishedAfter]=2024-01-01&page[size]=10
# ❌ Less efficient - no filters
GET /api/v1/me?api_key=YOUR_API_KEY
Combine with Pagination
Always use pagination when fetching filtered results:
# Fetch results in batches
GET /api/v1/me?api_key=YOUR_API_KEY&filter[type]=IMAGE&page[size]=50
Default Sorting
If no sort parameter is provided, results are sorted by published_at descending (newest first).
Framework Examples
See framework-specific filtering examples:
Next Steps
- Pagination - Paginate filtered results
- REST API - Complete REST reference
- GraphQL API - Complete GraphQL reference