Titles that contain a category & page limit questions

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Titles that contain a category & page limit questions

Beebe, Mary J

I am new to the Mediawiki API. 

I would like a list of all titles that have a certain category. 

 

This command gives me page titles with categories listed within the page. 

http://localhost/wiki1_13/api.php?action=query&generator=allpages&prop=categories&gaplimit=500

 

I can deal with this command but I would get way more than I need. 

 

Also, how can I avoid the limit?  I want all pages.   If I have to deal with limits, can I get 1-500, then 501-1000, etc.

Thanks,

Mary Beebe
Email: [hidden email]

 


_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Reply | Threaded
Open this post in threaded view
|

Re: Titles that contain a category & page limit questions

Brad Jorsch
On Fri, Dec 12, 2008 at 02:33:05PM -0500, Beebe, Mary J wrote:
> I am new to the Mediawiki API.
> I would like a list of all titles that have a certain category.

Use list=categorymembers, for example
http://en.wikipedia.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Physics

_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Reply | Threaded
Open this post in threaded view
|

Re: Titles that contain a category & page limit questions

Beebe, Mary J
Thank you that is exactly what I am looking for.

The other question was about page limit.  I guess I would have to use

"...Cmsort=timestamp&Cmprop=ids|title|timestamp"

Then use cmstart with the last timestamp displayed to get the next 500.


-----Original Message-----
From: [hidden email] [mailto:[hidden email]] On Behalf Of Brad Jorsch
Sent: Friday, December 12, 2008 2:53 PM
To: MediaWiki API announcements & discussion
Subject: Re: [Mediawiki-api] Titles that contain a category & page limit questions

On Fri, Dec 12, 2008 at 02:33:05PM -0500, Beebe, Mary J wrote:
> I am new to the Mediawiki API.
> I would like a list of all titles that have a certain category.

Use list=categorymembers, for example
http://en.wikipedia.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Physics

_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api

_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Reply | Threaded
Open this post in threaded view
|

Re: Titles that contain a category & page limit questions

Brad Jorsch
On Fri, Dec 12, 2008 at 04:10:57PM -0500, Beebe, Mary J wrote:
> Thank you that is exactly what I am looking for.
>
> The other question was about page limit.  I guess I would have to use
>
> "...Cmsort=timestamp&Cmprop=ids|title|timestamp"
>
> Then use cmstart with the last timestamp displayed to get the next 500.

Do you know about the "cheat sheet" you get by accessing api.php with no
parameters, e.g. http://en.wikipedia.org/w/api.php ? It's good for
telling you all the available parameters with a sentence about what each
does.

cmlimit=500 will give you your 500 results instead of the default 10. If
there are more than that available, the response will contain a
"query-continue" node with a child "categorymembers", and that child
will have a property "cmcontinue". Just copy that cmcontinue's value to
your request to get the next 500. For example, at this moment
http://en.wikipedia.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Physics
gives a cmcontinue value of "Acoustic droplet ejection|". Urlencoding
that and appending it to the original request gives the next 10 results:
http://en.wikipedia.org/w/api.php?action=query&list=categorymembers&cmtitle=Category:Physics&cmcontinue=Acoustic+droplet+ejection%7C
To get the third 10, add the cmcontinue from the second response onto
the original query. Repeat until you get a response without a
query-continue node.

Note that with complicated queries, you may get multiple values for your
query-continue; for example if you feed prop=images|templates with
generator=categorymembers, you might get imcontinue=X, tlcontinue=Y, and
gcmcontinue=Z. In that case, process the non-generator continues before
the generator: you'd want to use the old gcmcontinue with the new
imcontinue and tlcontinue until you run out of both, and only then use
the new gcmcontinue with no imcontinue/tlcontinue. Like this:
 api.php?...
  => gcmcontinue=Z1, imcontinue=X1, tlcontinue=Y1
 api.php?...&imcontinue=X1&tlcontinue=Y1
  => gcmcontinue=Z1, imcontinue=X2, tlcontinue=Y2
 api.php?...&imcontinue=X2&tlcontinue=Y2
  => gcmcontinue=Z1, imcontinue=X3
 api.php?...&imcontinue=X3&tlcontinue=Y2
  => gcmcontinue=Z1
 api.php?...&gcmcontinue=Z1
  => gcmcontinue=Z2, imcontinue=X5, tlcontinue=Y5
 api.php?...&gcmcontinue=Z1&imcontinue=X5&tlcontinue=Y5
  => gcmcontinue=Z2, tlcontinue=Y6
 api.php?...&gcmcontinue=Z1&imcontinue=X5&tlcontinue=Y6
  => gcmcontinue=Z2
 api.php?...&gcmcontinue=Z2
  => gcmcontinue=Z3, imcontinue=X8, tlcontinue=Y8
 api.php?...&gcmcontinue=Z2&imcontinue=X8&tlcontinue=Y8
 (and so on)

_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api
Reply | Threaded
Open this post in threaded view
|

Re: Titles that contain a category & page limit questions

Roan Kattouw
In reply to this post by Beebe, Mary J
Beebe, Mary J schreef:
> Thank you that is exactly what I am looking for.
>
> The other question was about page limit.  I guess I would have to use
>
> "...Cmsort=timestamp&Cmprop=ids|title|timestamp"
>
> Then use cmstart with the last timestamp displayed to get the next 500.
You don't have to, you can query-continue just fine with cmsort=sortkey
(default) and cmcontinue. Note that cmlimit=max will also work: it'll
give you 500 or 5000 results, depending on what rights you have.

Roan Kattouw (Catrope)

_______________________________________________
Mediawiki-api mailing list
[hidden email]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-api