Beans API Workflows
Serve Your News App with Beans API
Beans can supply publisher-content data for a news application: current Articles, attention-ranked feeds, topic collections, publisher records, Article detail, related reading, and external mention observations. These are backend data workflows only. They do not prescribe presentation, layout, or interaction design.
Set the shared configuration once:
Code
Operating rules
| Rule | Why it matters |
|---|---|
| Choose a feed route by intent. | latest is chronological, top-headlines uses a fixed recent attention window, and trending ranks observed attention. |
| Preserve Article and Source UUIDs. | IDs are the handoff between search, detail, similar, mentions, and Source-filtered Article calls. |
| Keep collection calls independent. | A temporary failure in one collection does not prevent the others from being served. |
Request full_content=true only for selected Article detail. | Collections remain compact. Body content is available only when Beans has it; use url for attribution. |
Treat pagination.next_cursor as opaque. | Send it back only as cursor with the same route and filters. |
| Use discovery only for an unknown value. | Known normalized categories, entities, regions, and sentiments can go directly into Article filters. |
| Send only documented parameters. | Unknown or route-inapplicable keys, including content_type on top-headlines and from/to on feeds, return HTTP 400. |
Request content_type accepts 14 filterable types: blog, contract, earnings_report, enforcement_action, financial_report, lawsuit, news, official_statement, podcast, press_release, research_paper, site, technical_documentation, and whitepaper. post may appear on responses. content_type=post returns HTTP 400. Omit content_type when a collection should include all stored types.
Shared server helper
The JavaScript examples use the built-in fetch in Node.js 18 and later.
Code
Scenario 1: Serve independent home-feed collections
Use when: A request needs current publication, a fixed headline set, and attention-ranked coverage.
Call sequence: 3 independent calls
GET /beans/articles/latestfor chronological publication.GET /beans/news/top-headlinesfor the fixed recent attention window (news only; nocontent_typeor dates).GET /beans/articles/trendingfor attention-ranked coverage (nofromorto).
Code
Code
Serving rule: Preserve each route as a separate collection. top-headlines and trending are different rankings; do not merge them into one ordered list or substitute one when the other is empty.
Scenario 2: Resolve a topic, then serve filtered Articles
Use when: A request contains a human topic label and needs an accepted Beans filter before Article retrieval.
Call sequence: 2 calls
GET /beans/categories?q={term}to discover an accepted category value when it is unknown.GET /beans/articles/searchwith the selected category and optional natural-language query.
Code
Code
Serving rule: Return the selected normalized filter value with the Article collection so later requests can reuse it. Different filter fields combine with AND; multiple values within one include field use OR.
Scenario 3: Resolve a publisher, then serve its Articles
Use when: A request starts with a publisher or domain and needs current coverage from that publisher.
Call sequence: 3 calls
GET /beans/sourcesto resolve a Source UUID from domain, name, or URL metadata.GET /beans/sources/{id}for one Source record.GET /beans/articles/search?sources={id}for the Source Article collection.
Code
Code
Serving rule: A Source describes a publisher. Use its UUID for sources; do not send a domain value to the sources filter.
Scenario 4: Enrich one selected Article
Use when: A known Article needs its available body, related publisher coverage, and external observations.
Call sequence: 3 calls
GET /beans/articles/{id}?full_content=truefor the selected Article.GET /beans/articles/{id}/similarfor related publisher reading.GET /beans/articles/{id}/mentionsfor external social or forum observations.
Code
Code
Serving rule: similar returns related reading, not guaranteed Story membership. mentions returns external observations, not replacement publisher Articles. content can be null even when full_content=true if a body is unavailable.
Scenario 5: Continue a collection without offset pagination
Use when: A server needs the next bounded batch from an existing route and filter set.
Call sequence: 2 or more calls
- Request the first collection page without
cursor. - Return
pagination.next_cursorwith the collection data. - Reissue the exact route and filters with that token as
cursoronly when it is non-null.
Code
Code
Serving rule: Keep the route and all filters identical while continuing. Do not use offset, page, pageSize, or a cursor from another collection. Stop when next_cursor is null.
Data-serving checklist
- Select the feed route from the requested data intent rather than applying local ordering to a generic search.
- Return API
dataitems without inventing Article, Source, trend, or mention fields. - Keep selected Article and Source UUIDs as opaque values for follow-up calls.
- Preserve separate collection cursors and freshness metadata.
- Treat empty
data: []as a successful result and HTTP 404 as a missing Article, Source, or Story. - Use Beans migration for provider parameter mapping and the Beans API reference for request and response schemas.
Scenario 6: Resolve a Story, then serve its member Articles
Use when: A news request needs a related-coverage group and the publisher Articles that belong to it.
Call sequence: 3 calls
GET /beans/storiesselects a stable Story UUID.GET /beans/stories/{id}returns Story detail.GET /beans/stories/{id}/articlesreturns the first member-Article page. The detail and member calls can run in parallel after selection.
Code
The detail response carries the same stable UUID and a service-relative links.articles path. For a gateway request, call GET /beans followed by that path. The member-Article envelope repeats the requested Story UUID in meta.story_id; Article story_id is present for members assigned to a Story.
Scenario 7: Monitor earnings or litigation coverage
Use when: The application watches publisher financial reports or lawsuits rather than general news.
Call sequence: 1 call (repeat with cursor as needed)
GET /beans/articles/search with a filterable content_type. Do not send content_type=post.
Code
Code
Serving rule: These types are publisher documents. For structured impact or outlook, continue in Espresso after selecting identifiers here.

