Notice: We are now selling NEW Gelbooru Merch~! Domestic shipping is free on all orders! Do you have an artist tag on Gelbooru? Let us know so we can properly credit you!

Now Viewing: Pulling tag data with single API call?

Keep it civil, do not flame or bait other users. If you notice anything illegal or inappropriate being discussed, contact an administrator or moderator.

Strahan Group: Member - Total Posts: 43
Pulling tag data with single API call?
Posted on: 09/02/18 03:19AM
Hi. I wrote a little command line tool that I can point at a file and it pulls tags for the image. Works fine. I wanted to expand on it so it would mark artist, series and character. I know how to do it using the s=tag, but that involves looping over the tags I get via s=post and making a call to the API for each tag. I have a MySQL database where I am caching tags and their types, but when I pull tags for a file and do not find an artist/series match I do the live API loop to check if I just don't have that particular artist cached, so for every image where artist wasn't tagged I end up looping calls.

It's fairly fast, so it's not really the end of the world I just don't want to be hammering away on your servers. Though granted, it's not like I use the tool all that often. Was just curious if the API can do something like a SQL INNER JOIN to link posts/tags in one call. Or failing that, I don't suppose you have the tag DB as a downloadable for locale caching like AniDB does with their titles DB?

Jerl Group: Administrator's Pet - Total Posts: 4554
Posted on: 09/02/18 09:38AM
The API doesn't use SQL.

That said, use a query like this to pull multiple tags:


This will return the tag information for "brown_eyes", "blue_eyes", and "black_eyes" in one query.

Strahan Group: Member - Total Posts: 43
Posted on: 09/05/18 11:41PM
Yea, I meant SQL as an example not that it literally was SQL :) Ahh, that's cool, that'll work just fine then. Thanks!

add_replyAdd Reply