Yammer JSON Feed returning only 20 messages
Categories:
Understanding and Overcoming Yammer JSON Feed Message Limits

Explore why Yammer JSON feeds often return only 20 messages and discover strategies to retrieve more comprehensive data for your applications and integrations.
When integrating with Yammer, developers often encounter a common challenge: the JSON feed, particularly for groups or user activity, consistently returns a maximum of 20 messages. This limitation can be frustrating when building applications that require a more extensive history or a higher volume of real-time data. This article delves into the reasons behind this default behavior and provides practical solutions to access more data from the Yammer API.
The Default Yammer API Behavior
The Yammer API, by default, is designed to provide a quick snapshot of recent activity. For many endpoints, such as /api/v1/messages/in_group/:group_id.json
or /api/v1/messages/sent.json
, the default limit
parameter is set to 20. This is a common practice in RESTful APIs to prevent overwhelming the server with large requests and to ensure fast response times for typical use cases, like displaying a recent activity feed on a dashboard.
flowchart TD A[Yammer API Request] --> B{Endpoint Called} B --> C{Default Limit Applied (20 messages)} C --> D[JSON Response (max 20 messages)] D --> E[Application Receives Limited Data]
Default Yammer API Request Flow with 20-Message Limit
Overcoming the 20-Message Limit with the 'limit' Parameter
Fortunately, the Yammer API provides a limit
parameter that allows you to specify the number of messages you wish to retrieve, up to a certain maximum. While the exact maximum can vary by endpoint and API version, a common upper bound is 50 messages per request. To retrieve more than the default 20, you simply need to include this parameter in your API call.
GET /api/v1/messages/in_group/:group_id.json?limit=50 HTTP/1.1
Authorization: Bearer YOUR_ACCESS_TOKEN
Example API call to retrieve 50 messages from a Yammer group
limit
value for the specific endpoint you are using, as it can sometimes be higher or lower than 50 depending on the API version and type of feed.Paginating for More Extensive Data Retrieval
When you need to retrieve more than the maximum allowed by the limit
parameter (e.g., more than 50 messages), you must implement pagination. The Yammer API supports pagination using older_than
and newer_than
parameters, which refer to message IDs. This allows you to fetch messages in chunks, moving backward or forward in time.
sequenceDiagram participant App as Your Application participant Yammer as Yammer API App->>Yammer: Request messages (limit=50) Yammer-->>App: First 50 messages + oldest_message_id App->>Yammer: Request messages (limit=50, older_than=oldest_message_id) Yammer-->>App: Next 50 messages + new oldest_message_id App->>Yammer: ... (repeat until no more messages or desired count reached)
Sequence Diagram for Paginating Yammer Messages
Here's how the pagination process typically works:
- Initial Request: Make your first API call with the
limit
parameter set to its maximum (e.g., 50). - Extract
older_than
: From the response, identify the ID of the oldest message returned. The API response usually includesolder_than_id
or similar metadata. - Subsequent Requests: In your next API call, use the
older_than
parameter with the ID you extracted from the previous response. This tells Yammer to return messages older than that specific ID. - Repeat: Continue this process until you have retrieved all the messages you need or until the API returns an empty set, indicating no more older messages are available.
# First request
GET /api/v1/messages/in_group/:group_id.json?limit=50 HTTP/1.1
# Response will contain messages and an 'older_than_id' (e.g., 12345)
# Second request to get messages older than 12345
GET /api/v1/messages/in_group/:group_id.json?limit=50&older_than=12345 HTTP/1.1
Example of paginated API calls using older_than
Considerations for Real-time Data and Webhooks
For applications requiring near real-time updates rather than historical data, relying solely on polling the API with pagination might not be the most efficient approach. Yammer offers webhook capabilities that can push notifications to your application when new messages or events occur. This can significantly reduce the number of API calls needed and provide a more immediate data stream.
While webhooks are excellent for new data, they don't solve the problem of retrieving historical data beyond the limit
parameter. A robust integration often combines both: using pagination for initial historical sync and webhooks for ongoing real-time updates.