Wikipedia Mediawiki API get URL in query - mediawiki

Using the MediaWiki API I have a query that returns the results I want:
https://en.wikipedia.org/w/api.php?action=query&list=allpages&apfrom=Apple&aplimit=5
How can I modify it to also include the URL for each of the pages that are returned?
I tried adding the "info" property and "url" info, but it does not return additional information:
https://en.wikipedia.org/w/api.php?action=query&list=allpages&apfrom=Apple&aplimit=5&prop=info&inprop=url

You need to move the parameters you use to get the result to a generator instead of a list and then use prop=info and inprop=url in the query. Like this:
https://en.wikipedia.org/w/api.php?action=query&format=json&prop=info&generator=allpages&inprop=url&gapfrom=Apple&gaplimit=5

Related

How to use the 'query_fields' and 'query' options with Vimeo API?

I'm trying to get my head around Vimeo API with Python. I'm successful in the sense that I can use basic API requests e.g. to list all my videos or similar.
Mostly, I use the /me/videos/ API endpoint. The API reference states, that there can be two options 'query_fields' and 'query'. If I just use 'query', I can filter the results e.g. by a string in the title. I'm assuming this works, because the default value for 'query_fields' is title,description,chapters,tags' according to the API reference.
But what i'd like to do is to use the 'query_fields' for something like:
'query_fields': 'privacy.view'
'query': 'unlisted'
But if I try that, a generic error message is returned
{
"error": "Searching for a page that does not exist or is too far back in our catalog to present.",
"link": null,
"developer_message": "The user's from + size exceeded 10,000, they requested a page of results that does not exist, or they issued an invalid query as defined in the QueryPreprocessorPlugin.",
"error_code": 2969
}
Has anyone been able to use the 'query_fields' option on any way other than the defautl fields?
You can't query any fields with query_fields, the only valid fields are the ones listed in the docs ('title', 'description', 'chapters', 'tags').
You'd need to manually filter on privacy.view, so i.e.
GET /me/videos?fields=uri,privacy.view
And loop through this filtering for the values you want.

How to include SR related work log long description when using maximo oslc rest api?

I am doing an HTTP GET request to /maximo/oslc/os/mxsr and using the oslc.select query string parameter to choose:
*,doclinks{*},worklog{*},rel.commlog{*},rel.woactivity{*,rel.woactivity{*}}
This lets me get related data, including related worklogs, but the worklog does not include the 'description_longdescription' field.
The only way I seem to be able to get that field is if I do a separate HTTP GET to query a worklog id directly through /maxrest/rest/mbo/worklog . Then it provides the description_longdescription field.
I understand this field is stored separately through the linked longdescription table, but I was hoping to get the data through the "next gen" oslc api with one http get request.
I've tried putting in 'worklog{*,description_longdescription}', as I read somewhere that longdescription is a "non-persistent" field and must be explicitly named for inclusion, but it had no effect.
I figured out that for the /maximo/oslc/os/mxsr object in the API, I needed to reference the related MODIFYWORKLOG object through the rel.modifyworklog syntax in the oslc.select query string:
oslc.select=*,doclinks{*},rel.modifyworklog{*,description_longdescription},rel.commlog{*},rel.woactivity{*,rel.woactivity{*}}
I also had to explicitly name the non-persistent field description_longdescription for it to be included.
Ref. for the "rel." syntax: https://developer.ibm.com/static/site-id/155/maximodev/restguide/Maximo_Nextgen_REST_API.html#_querying_maximo_asset_management_by_using_the_rest_api

How to paginate with string provided in JSON result?

I am using Feedly API to access feeds from a particular rss feed. Take a look at this link (1). As you see, it only returns newest 20 items but I think it provides sort of a link to paginate to the next result. There is 'continuation' key provided in the result but it is a string and not a link.
How can I use that to fetch the next result? Is this even possible?
JSON response from the server
See http://developer.feedly.com/v3/streams/
You can pass the continuation key to get the next batch of results.
For example: https://cloud.feedly.com/v3/streams/contents?streamId=feed/http://feeds.engadget.com/weblogsinc/engadget?continuation=14de41de03e:f7bda:87649ed8

Wikipedia api fulltext search to return articles with title, snippet and image

I've been looking for a way to query the wikipedia api based on a search string for a list of articles with the following properties:
Title
Snippet/Description
One or more images related to the article.
I also have to make the query using jsonp.
I've tried using the list=search parameter
http://en.wikipedia.org/w/api.php?action=query&list=search&prop=images&format=json&srsearch=test&srnamespace=0&srprop=snippet&srlimit=10&imlimit=1
But it seems to ignore the prop=images, I've also tried variations using the prop=imageinfo and prop=pageimages. But they all give me the same result as just using the list=search.
I've also tried action=opensearch
http://en.wikipedia.org/w/api.php?action=opensearch&search=test&limit=10&format=xml
Which gives me exactly what I want when i set format=xml, but returns a simple array of page titles when using format=json and therefore fails because of the jsonp requirement.
Is there another approach to doing this? I'd really like to solve this in a single request rather than make the first search request and then a second request for the images using titles=x|y|z
As Bergi suggested, using generators is the way to go here. Specifically what I would do:
use list=search as a generator, to get the list of articles
use prop=pageimages to get a representative image for each article
use prop=extracts to get a description for each article
The whole query could look like this:
http://en.wikipedia.org/w/api.php?format=json&action=query&generator=search&gsrnamespace=0&gsrsearch=test&gsrlimit=10&prop=pageimages|extracts&pilimit=max&exintro&explaintext&exsentences=1&exlimit=max
I've tried using the list=search parameter, but it seems to ignore the prop=images
If you want to retrieve any properties, you need to specify a list of pages for which you want to get these; e.g. by using the titles=, pageids=, or revids= parameters. You didn't send any, so you did not get a result for the prop=images.
If you did use api.php?action=query&list=search&srsearch=test&prop=images&titles=test you would have gotten the search results for test and the images of the Test page.
You can however also use the collection that the list query generates for your property query, using the list module as a generator. The query would look like
api.php?action=query&generator=search&gsrsearch=test&gsrnamespace=0&gsrprop=snippet&prop=images. Unfortunately, it does not yield the attributes that the list contained, but only used the pageids for a basic property query.
Using two queries is probably the way to go. Btw, I'd recommend to use the pageimages property, it will likely give you the best results.

youtube API, get multiple users uploads videos

I try to find in youtube API (jsonp), if I can get in 1 query uploads videos from multiple users.
for 1 users I can use this query string:
http://gdata.youtube.com/feeds/users/myUsername/uploads?alt=json-in-script&callback=?&max-results=20'
but I need something like this:
http://gdata.youtube.com/feeds/users/myUsername+myUsername1+myUsername2/uploads?alt=json ...
myUsername+myUsername1+myUsername2
or Maybe I can use the search query format :
https://gdata.youtube.com/feeds/api/videos?alt=json&q=
and to use something like :
q=from:myUsername1+from:myUsername2
Or if exist any another way to grab this info.
I appreciate any help, thanks!
It's not possible to ask for multiple users for the list of uploads. Instead you can trying using the search api and limiting it to only the users you want.
By including #username you can restrict the search to a user name. Try this link to search for #youtube #googledevelopers
You can try this in as part of the query parameter in the YouTube Data API.
It's not possible to do that in a single YouTube Data API query. You can only use a single channel/user as the value for the author=USER query parameter, or when specifying the feeds/api/users/USER URL.