APITube Help Center

How to Sort News by Rank, Length and Sentiment

Put articles in order by source rank, reading time, sentiment or media

Kent Hudson

Written by Kent Hudson

August 22, 2026

Updated October 16, 2026

Open this example in the API Playground ↗

How to sort news by rank, length and sentiment

Use sort.by to choose a field, then set sort.order=desc for higher values first or asc for lower values first. Without either parameter, the API returns the newest articles first.

curl "https://api.apitube.io/v1/news/everything?category.id=medtop:04000000&sort.by=source.rank.opr&sort.order=desc&api_key=YOUR_API_KEY"

You can also send your key in the X-API-Key header. Sorting orders the articles matching your filters; it can change which of those articles appear on the first page.

How to sort news by source rank (OPR)

Set sort.by=source.rank.opr&sort.order=desc for higher-ranked sources first:

curl "https://api.apitube.io/v1/news/everything?title=inflation&sort.by=source.rank.opr&api_key=YOUR_API_KEY"

OPR describes the publisher’s rank. A higher rank does not verify an article’s claims. See what the OPR source score means.

How to sort news by length and read time

Use sort.by=read_time. Reading time is estimated in minutes: desc puts longer articles first, while asc puts shorter ones first.

curl "https://api.apitube.io/v1/news/everything?language.code=en&sort.by=read_time&sort.order=desc&api_key=YOUR_API_KEY"

Article fields such as characters_count, sentences_count, paragraphs_count and words_count are not supported sort keys. Use reading time to order by length, or reading-time filters to require a range.

How to sort news by sentiment score

Choose the part of the article you want to compare:

  • sentiment.overall.score: overall article sentiment.
  • sentiment.title.score: headline sentiment.
  • sentiment.body.score: body-text sentiment.
curl "https://api.apitube.io/v1/news/everything?organization.name=Tesla&sort.by=sentiment.overall.score&sort.order=desc&api_key=YOUR_API_KEY"

Descending puts more positive scores first; ascending puts more negative scores first. Sorting does not exclude neutral or negative articles. Add sentiment.overall.polarity if you want only one polarity.

How to sort news by media count and image size

Supported media fields include:

  • media.images.count and media.videos.count: number of images or videos.
  • media.images.width.min and media.images.width.max: smallest or largest image width.
  • media.images.height.min and media.images.height.max: smallest or largest image height.
curl "https://api.apitube.io/v1/news/everything?title=SpaceX&sort.by=media.images.count&sort.order=desc&api_key=YOUR_API_KEY"

This puts articles with more images first. Use a dimension field when image size matters more than count.

How to set the sort direction

sort.order=desc is the default and puts higher values first. asc reverses the order.

Other supported keys include published_at, created_at, new and id. Use published_at for publication time; created_at and new order articles by when they were added to APITube.

An unsupported sort.by value returns HTTP 400 with ER0309. An invalid sort.order returns ER0314. Check the spelling and use asc or desc for direction.

Which endpoints support sort.by and sort.order?

Use sorting on /v1/news/everything, /v1/news/top-headlines, /v1/news/category, /v1/news/topic, /v1/news/industry and /v1/news/entity. Send sort parameters in a GET query string or POST request body.

Keep the same sort settings as you page through results. See the News API parameters reference for all sort values.

Common Questions

What fields can I sort news by?

Publication time, source rank, reading time, title/body/overall sentiment scores, media counts and image dimensions. Choose a supported field name as sort.by.

Does sorting by a field also filter out articles?

No. It changes the order of the matching set. A different order can put different articles on the page you request.

How is field sorting different from relevance or quality sorting?

A field sort compares one value, such as reading time. Modes such as relevance and quality provide broader rankings. See sorting by relevance, date or quality to choose a mode.

What happens if I use an invalid sort.by value?

The API returns HTTP 400 with ER0309. Correct the value and retry; a misspelled sort key does not produce a successful date-sorted response.


Related Articles