wikipedia api results vary between list and generator queries - mediawiki

I'm exploring wiki apis...
Based on the below post, i 've some doubts.
Wikipedia list=search REST API: how to retrieve also Url of matching articles
I need to fetch the wiki URLs for my search. So I used generator=search instead of list=search
But the results got from both methods vary in the order they are returned.
Can someone tell me based on what factor the results are being ordered in generator method?
sample try:
generator: http://en.wikipedia.org/w/api.php?action=query&generator=search&gsrsearch=sachin+tendulkar&format=jsonfm&prop=info&inprop=url|displaytitle
list: http://en.wikipedia.org/w/api.php?action=query&list=search&srsearch=sachin+tendulkar&format=jsonfm

Related

Retrieve Wikipedia page title when performing full text search in Wikidata API

I want to search a term using Wikidata API, and retrieve a list of corresponding entities identifiers and related Wikipedia page titles (if available).
I'm currently using the following URL:
https://www.wikidata.org/w/api.php?action=query&list=search&format=json&srinterwiki&srsearch=nyc
however parameter 'srinterwiki', documented here, does not return any Wikipedia link.
Many many thanks
Ps: I know this can be achieved using 'wbsearchentities' with 'props' parameter, but it does not perform a full-text search. Indeed, it is not capable of returning the same results of the Wikdata search box as stated here.
srinterwiki returns interwiki search results (that is, search results for the same search query from other wikis), not interwiki links for the normal search results. Pass the results to wbgetentities to get sitelinks.
(Normally you would use generators for this kind of thing, unfortunately wbgetentities does not support generators.)

Filtering JSON From Twitter's API

I am currently pulling data from Twitter's API through a Node.js connection running on my computer. Here's the heart of my search:
///
var param = {q: "Futbol -filter:retweets -filter:replies", lang: "en", result_type: "popular", count: 10}
client.get('search/tweets',param,function(error,tweets,response){// MY SEARCH GOES HERE}
The git repo is here: https://github.com/KingOfCramers/Twitter-Stream-JSON-in-Node
I have a few questions because I am confused about the twitter syntax for Node.js.
First, I pass it to "q" any information relating to a search. What are those parameters called? What page on the Twitter API lists all of them?
Secondly, I am currently passing other arguments as well, such as lang and result_type. I want to tailor my search to specific accounts. Is there a parameter to search by username or the id of the user on Twitter? Eventually I want to stream twitter JSON data from specific groups, like Congresspeople (a different request, client.stream()).
Thanks!
You are using standard search operators, which are explained here. If you want to filter your search by specific accounts, you need to use from: query parameter described in that page.

JSON API filter included resources

The question is about JSON API specification and how properly do a request
(I'm using ruby on rails and the json api resources gem but that's a general question anyway, I know how to implement it, I just want to follow the rules of JSON API at: http://jsonapi.org/format/)
Situation 1:
I want to get all shelves
I want to include all books that are on those shelves
The get I'm supposed to use in this case is:
www.library.com/shelves?include=books
Situation 2:
I want to get all books but only books that are marked as unread
The get I'm supposed to use is:
www.library.com/books?filter[unread]=true
What would be correct way of designing request for all shelves with included unread books?
Can't figure this one out
www.library.com/shelves?include=books&filter[books.unread]=true ?
www.library.com/shelves?include=unread_books ? <- would have to specify another resource, books that are unread
www.library.com/shelves?filter[books.unread]=true ?
What's the most correct way of doing this?
EDIT
After speaking with my tech lead and a few other programmers, the first options is favoured the most in such cases
I would bet on the first one:
www.library.com/shelves?include=books&filter[books.unread]=true
JSON API currently does not support filtering includes, but this doesn't mean you have to be strict on the definition (check https://github.com/cerebris/jsonapi-resources/issues/314)
I would go with the same approach as brian:
www.library.com/shelves?include=books&filter[books.unread]=true
I just wanted to give some more background to the answer.

How to get table data from Wikipedia page?

Is there somebody who knows how to use the Wikipedia API to get JSON or XML data out from a table on a specific Wikipedia page?
Is there maybe a different way to do this?
For example from here https://en.wikipedia.org/wiki/List_of_action_films_of_the_2010s
You can use curl (or use any other method/tool) to retrieve and/or parse a Wikipedia-URL via the public API. Here are two examples that should help you:
Retrieval of List_of_action_films_of_the_2010s:
JSON unparsed via the query action
JSON parsed via the parse action
Next, you would need to parse for and/or select the sub-elements relevant for your analysis. In this case I would assume: wikitable elements.
For reference and a detailed explanation, you can have a look at the general API page of MediaWiki and at the list of parameters on how to use the API to parse Wikipedia pages for certain data elements.

Twitter API and json schema

Is there any official or unofficial documentation of twitter api which includes json schemas? For example the following link contains only sample response
https://dev.twitter.com/rest/reference/get/lists/members
https://dev.twitter.com/overview/api/tweets
Field Guide
Consumers of Tweets should tolerate the addition of new
fields and variance in ordering of fields with ease. Not all fields
appear in all contexts. It is generally safe to consider a nulled
field, an empty set, and the absence of a field as the same thing.
Please note that Tweets found in Search results vary somewhat in
structure from this document.