Danbooru

iqdb_queries API help? (developer)

Posted under General

This is gonna be stackoverflow-y, but this error only occurs with Danbooru, so I thought I'd ask and see if anyone else is having the same issue/knows how to fix it.

How do you authenticate iqdb_queries using python? I've tried using the requests module in the following way:

res = requests.post(url, data={'Url':file_url}, auth=('username', 'APIkey'))

but I'm getting a website error that says <p>undefined method `[]' for nil:NilClass</p> (note that this is the same as undefined method `[]' for nil:NilClass). Google says that this is caused by the method/attribute not being properly defined, but since I don't have access to danbooru's code, I don't know what it's missing. https://dev.to/ben/nomethoderror-undefined-method-for-nil-nilclass-explained-422b

This only occurs if I include the auth component; if I neglect it, I get a failed authentication error (duh, since it doesn't include the API key). Anyone know how to fix this?

Note that I've already looked through help:api and it doesn't seem to help.

Have you tried using 'url' (lowercase) or 'search[url]' instead of 'Url' as a data field?

What exactly does the failed authentication error say?

Please also post values for url and file_url that you’re trying it with.

Updated

In addition to the above, have you tried using GET instead of POST? I'm not exactly sure what POST /iqdb_queries does in this context (docs for iqdb_queries seem to be absent and I'm too dumb to figure it out from the source code) but GET works fine for querying similarity matches, doesn't even need authentication.

but since I don't have access to danbooru's code,

You do.

ehh said:

In addition to the above, have you tried using GET instead of POST? I'm not exactly sure what POST /iqdb_queries does in this context (docs for iqdb_queries seem to be absent and I'm too dumb to figure it out from the source code) but GET works fine for querying similarity matches, doesn't even need authentication.

You do.

Huh, didn't know it was open source. I ended up solving the problem (Url had to be search[url]), but thanks for the advice! POST did end up being what I needed lol

1