TibiaWikiApi icon indicating copy to clipboard operation
TibiaWikiApi copied to clipboard

Feature: image of item, creature etc.

Open biaggio12 opened this issue 5 years ago • 4 comments

Hey, so far i'm loving the API. Easy and simple to use, but it's missing one feature. I'm not an expert but as far as it's possible would be great if you add the image URL in responses on the creatures and items etc. Would be really usefull

biaggio12 avatar Jun 17 '20 09:06 biaggio12

Hi! Glad you like it!

Which image URL would you prefer to have? Let's take a creature, say a dragon for example. We could add an imageUrl field which could hold https://tibia.fandom.com/wiki/File:Dragon.gif, but that is something we can simply derive from the name attribute (because images of 'things' in TibiaWiki are always structured as 'File:{PAGENAME}.gif' and the page name is in the name field).

But I can imagine you want a direct URL to the image, e.g. https://vignette.wikia.nocookie.net/tibia/images/e/e0/Dragon.gif/revision/latest?cb=20140823213526&path-prefix=en

I think this URL is a bit more dynamic and can change over time, maybe also differ per region you access TibiaWiki from.

benjaminkomen avatar Jun 17 '20 10:06 benjaminkomen

Hmm, that's actually kinda pain in the ass. Yea i'd like to have direct URL to img like the second one you posted. I wonder how dynamic it is. I think the URL is changing each time someone edits the article but i'm not really sure. Well if that's gonna help you somehow then i don't think this URL depends on region of access. The URL u sent here is working perfectly fine for me. (I'm accessing it from Poland. )

biaggio12 avatar Jun 17 '20 10:06 biaggio12

Ok, well, let's see what I can do, I think it might be obtainable using the MediaWiki API and if not, we'll just have to be a bit more creative :)

benjaminkomen avatar Jun 17 '20 11:06 benjaminkomen

Ok, the MediaWiki API does support this, e.g.: https://tibia.fandom.com/api.php?action=query&titles=File%3ADragon.gif&prop=imageinfo&iilimit=50&iiend=2007-12-31T23%3A59%3A59Z&iiprop=timestamp%7Cuser%7Curl&format=json results in:

{
  "query": {
    "pages": {
      "1317": {
        "pageid": 1317,
        "ns": 6,
        "title": "File:Dragon.gif",
        "imagerepository": "local",
        "imageinfo": [
          {
            "timestamp": "2014-08-23T21:35:26Z",
            "user": "Kapitan Kuna",
            "url": "https://vignette.wikia.nocookie.net/tibia/images/e/e0/Dragon.gif/revision/latest?cb=20140823213526&path-prefix=en",
            "descriptionurl": "https://tibia.fandom.com/wiki/File:Dragon.gif"
          }
        ]
      }
    }
  }
}

benjaminkomen avatar Jun 17 '20 19:06 benjaminkomen