Page 1 of 1

How to use the API to check if an item has been read

Posted: Thu Jul 13, 2017 8:11 pm
by awasu.user
I try get JSON data from Awasu with code:

Code: Select all

phrase = "Donald Trump"
import requests

print("Check in Awasu: ", phrase)

a_search = "http://localhost:2604/search/query"

opt = {}
opt["token"] = "GYmh3B"
opt["age"] = "1"
opt["p"] = "1"
opt["ps"] = "20"
opt["l"] = "title,content"
opt["format"] = "json"
opt["feedItemDescriptionFormat"] = "excerpt"
opt["q"] = phrase

r = requests.get(a_search, params=opt)
print(r.url)
code = r.json()
code = code["searchResults"]
code = code["results"]
print(code)
But how combine using API call search result and check that search result article is unread using API?

Fx. Awasu result: "New president" and "Last speach" and I check that articles are fresh and juicy or old (= I read it before).

Re: How to use the API to check if an item has been read

Posted: Fri Jul 14, 2017 1:29 am
by support
There isn't an API call to get the read/unread status of an item, but you could do it like this:
  1. Use $/search/query to run the query (as you did above).
  2. Get each item's ID (code[item_no]["id"]).
  3. Get the channel's summary page (HTML) using $/channels/get (but see below).
  4. Look for a <div> with a class of "item" that has the ID you want, and it will also have the item's new/read/unread state.
However, the tricky bit is (3), since there's no way of knowing which channel an item belongs to, so you would need to start off by getting the summary page for every channel, then scanning them for items, which would be very slow. It also won't work if the item is not recent enough to be included in the page.

There is an API call $/feedItems/get that returns information about a feed item, but it currently doesn't return the item's state. I'll update this and get a new build out to you...

Re: How to use the API to check if an item has been read

Posted: Wed Jul 19, 2017 8:23 am
by support
I've sent you a new build, and $/feedItems/get will now return each item's state (new|unread|read).

This API call can take multiple item ID's (comma-separated), and it will be much quicker to do them all in one go, rather than calling the API for each individual item.

Re: How to use the API to check if an item has been read

Posted: Wed Jul 19, 2017 7:14 pm
by awasu.user
It's working! Thank you!