Nicholas
Nicholas

Reputation: 5520

Possible to retrieve MediaWiki data for a section by using section title instead of rvsection id?

I'm trying to retrieve section data. The only way I found this is possible is by using the rvsection parameter. Is there a way to get section data by the section title?

rvsection is used like this: http://2007.runescape.wikia.com/api.php?action=query&prop=revisions&titles=Abyssal_demon&rvprop=content&format=jsonfm&rvsection=3

changing the rvsection number determines the data you get.

Upvotes: 1

Views: 130

Answers (1)

svick
svick

Reputation: 244988

AFAIK, there is no way to directly get the section contents based on the section name.

What you can do is to get the section name to section index mapping first:

http://2007.runescape.wikia.com/api.php?action=parse&page=Abyssal_demon&prop=sections&format=jsonfm

And use that to figure out the section index of the section that you want.

One possible issue with this approach is what happens when the article changes between the two queries. To solve that, you can make the first query also return revision id:

http://2007.runescape.wikia.com/api.php?action=parse&page=Abyssal_demon&prop=sections|revid&format=jsonfm

And then use that in your second query:

http://2007.runescape.wikia.com/api.php?action=query&prop=revisions&revids=251305&rvprop=content&format=jsonfm&rvsection=3

Upvotes: 1

Related Questions