Blog
Watch a list of LinkedIn company pages for new posts, and pay only for the posts you have not read
A company page's posts cost a credit each, so a poll that asks for 25 mostly rebuys posts you stored last time. Size count to the gap and stop at the overlap.
GET /v1/companies/posts returns a company page’s newest posts, newest first, reposts included. It
bills one credit per post returned, and count, from 1 to 25, is the most a call can charge.
That pricing changes how you poll. On a feed you pay per page, so rereading a page you already have
costs one credit. Here you pay per post, so rereading 25 posts you stored yesterday costs 25.
curl -H "ApiKey: $TRIGUNA_KEY" \
"https://api.triguna.ai/v1/companies/posts?company_id=examplecorp&count=5"
If you want to know when a list of companies posts something new, the job is to ask for roughly the number of posts that are new since your last look, and no more. The rest of this post covers how to size that number, where the bookmark lives, and the two urn details that decide what you can do with a post once you have it.
What one call returns, and what it costs
The response is {company_id, count, posts[]}. Each item in posts[] is exactly the post object
of GET /v1/posts/details, so a parser written for one reads the other. Three rules from
the reference shape everything below:
- There is no next page. 25 is the most you can see. The source can return slightly fewer than
count, so a short list does not mean the company has nothing older. - The charge is per post returned. A company with four posts costs 4 however many you ask for, and a company with none costs 1.
- Your balance must cover
count, not the result. Ask for 25 with 20 credits left and the call is a free402with the bodyinsufficient credits, even if the company has posted twice.
| Poll | Posts returned | Credits |
|---|---|---|
count=25, company posted twice since last poll | 25 | 25 |
count=5, company posted twice since last poll | 5 | 5 |
count=5, company page has no posts | 0 | 1 |
company_id that does not exist | 404 | 1 |
The first two rows return the same two new posts. The difference is how many old ones you bought again to find them.
Your bookmark is the set of activity urns you have stored
Every post carries an activity_urn. Store it per company and you know where the last poll ended:
create table company_posts_seen (
company_id text not null, -- the slug or numeric id you query with
activity_urn text not null, -- as the response returned it
created_at_ms bigint, -- may be null, like every value
first_seen_at timestamptz not null default now(),
primary key (company_id, activity_urn)
);
Query with the identifier you stored, not a display name. company_id takes the slug after
/company/ in the page URL, the numeric id, or the full URL. “Example Corporation” is a 404, and
that 404 costs one credit like any answered lookup, so fix the input rather than retrying it. The
company records guide covers keeping that identifier stable.
Size count to the gap, and keep one post of overlap
Posts come back newest first. If the list contains at least one activity_urn you already stored,
you have reached the overlap with the previous poll and everything newer is what you missed. If
every post in the list is new, you cannot tell whether there are more behind it.
That gives a simple rule. Ask for the number of posts you expect since your last poll, plus one, so that a normal poll ends on a post you already have:
const BASE = 'https://api.triguna.ai/v1';
const headers = { ApiKey: process.env.TRIGUNA_KEY };
async function pollCompany(companyId, seen, count) {
const url = new URL(`${BASE}/companies/posts`);
url.searchParams.set('company_id', companyId);
url.searchParams.set('count', String(count));
const res = await fetch(url, { headers });
const charged = Number(res.headers.get('X-Credits-Charged'));
if (!res.ok) throw new Error(`${res.status} ${await res.text()} (charged ${charged})`);
const { posts } = await res.json();
const fresh = posts.filter((p) => !seen.has(p.activity_urn));
const caughtUp = fresh.length < posts.length; // at least one post was already stored
return { fresh, caughtUp, charged };
}
Then adjust count per company from what the poll saw:
- Caught up with room to spare. Most of the list was old. Lower
countfor the next poll, but not below 2, so there is still room for one new post and one post of overlap. - Caught up on the last post. The size was right. Keep it.
- Not caught up. Every post was new. Raise
countfor the next poll. If the gap matters now, read once more withcount=25and accept that you are rebuying the posts you just read.
Parse X-Credits-Charged as a number, not an integer, and add it to a running total per company.
After a week of polls the totals tell you which pages are worth watching daily and which only need
a weekly look.
Poll at most once a day unless you bypass the cache
use_cache defaults to true and serves a stored copy less than 24 hours old at the same price as a
live read. For this endpoint that means a second poll on the same day, with the same request,
returns the list you already have and charges you for every post in it again.
So pick one of two schedules:
- Daily or slower, cache on. The default. A stored copy that is still fresh is the same list you would have fetched.
- More than once a day,
use_cache=false. Only then is each poll a real re-read. Withuse_cache=falsea failed fetch is a free502rather than a stored copy, so retry it with backoff.
When to bypass the enrichment cache walks through the same trade on the other endpoints.
Decide what a repost means to you
A company page shares other people’s posts. A repost without the company’s own words comes back
with action_type set to repost, the company as author, commentary set to null, and the
original post under reshared_activity. It costs a credit like any other post returned.
Decide up front whether reposts count as news. If you only want the company’s own words, skip items
where action_type is repost and commentary is null when you alert, but still store their
activity_urn so the overlap rule keeps working. If you want them, key any deduplication on
reshared_activity.activity_urn, because several companies you watch may repost the same original.
From a new post to the people engaging with it
A new post is often the start of the job, not the end. Who commented on it and who reacted to it comes from two paged endpoints, and each takes a different urn:
| You want | Endpoint | Urn it takes | Where you get it |
|---|---|---|---|
| Everyone who commented | GET /v1/posts/comments | activity_urn | Already on the company post |
| Everyone who reacted | GET /v1/posts/reactions | share_urn | Often null on the company post: call GET /v1/posts/details with the activity_urn |
The two urns are different numbers and neither can be derived from the other. Passing the wrong
form is a free 400. posts/details costs one credit and fills both, so call it once for the
posts you care about and store both urns.
Each page of comments or reactions costs one credit whatever its size, so ask for count=100. Stop
when items is empty, not when a page comes back short, and deduplicate on the commenter’s or
reactor’s entity_urn, because items occasionally repeat across pages.
Who liked and commented on a LinkedIn post covers those
lists in detail, and the Person API turns any entity_urn in them into a
full profile.
Budget a run before you start it
A watch list is a batch job, and the balance check is free. Read GET /v1/credits before a run and
compare it with the sum of count across the companies you are about to poll. The balance must
cover each call’s count, so a run that starts with too little stops partway with 402 responses
rather than skipping the expensive companies.
Check credits before a batch run has the pattern.
The retry rules are the usual ones. Retry 429, 502 and 503 with backoff, honouring
Retry-After where it is sent. Do not retry 400, 401, 402 or 404. A retried 404 costs a
credit every time and returns the same answer.
How this differs from polling a person’s feed
If you already poll people with GET /v1/activities/personal-feed, the structure is the same and
the economics are not:
| Person feed | Company page posts | |
|---|---|---|
| Billing | 1 credit per page of up to 30 | 1 credit per post returned |
| Paging | pagination_token, page until the overlap | None, 25 at most |
| The lever | Stop paging at the overlap | Ask for fewer posts |
| Cost of rereading old items | One page | One credit per old post |
Polling a person’s activity incrementally covers the feed side. The seen-set table and the cache rule carry over unchanged.
The short version
- Store
activity_urnper company. That set is your bookmark. - Ask for the gap plus one. A poll that ends on a post you already have is the right size.
- Grow or shrink
countper company from what each poll saw, and trackX-Credits-Charged. - Poll at most daily with the cache on, or send
use_cache=falsefor sub-daily polls. - Keep both urns for the posts you follow up on:
activity_urnfor comments,share_urnfromposts/detailsfor reactions.
Fifty free credits are enough to put a few company pages on a daily watch and see the overlap rule
settle each one at a small count. Why the reference documents billing at this level of detail is
on the about page.
Next
- Company API: the company record behind each
company_id, and how its identifiers work. - Polling a person’s activity incrementally: the same seen-set pattern for people.
- Nightly backfill: pacing and checkpointing a scheduled run across a long list.
- Pricing: what each call costs, and the statuses that cost nothing. Sign up for fifty free credits at app.triguna.ai/signup.