Some love for the API

Posted in

#76 by yorhel
2016-02-16 at 06:08
< report >@eacil: The 100 results limitation is imposed by the API. To get the next 100 you need to call something like
get wishlist basic (uid=0) {"results":100,"page":2}
But I don't know if or how leiven's library exposes that functionality.
#77 by eacil
2016-02-16 at 08:42
< report >Nice, it works. You need to pass your parameters as an array and it do the trick:
#78 by leiven
2016-02-18 at 22:50
< report >Sorry for not catching this earlier.

A quicker way to go about questions would be to either DM me here, on Github, or post an issue on Github, since I'll be getting notifications for that (and I'm checking Github daily).

Your problem obviously stems from a lack of more extensive documentation, which I intend to fix with more examples in the near future.

Edit: You could've also used the SimpleClient's "getCompleteUserWishlist" method, which automatically fetches all wishlist items to circumvent the 100 result limit. Simply call that after logging in.Last modified on 2016-02-18 at 23:01
#79 by eacil
2016-02-18 at 23:27
< report >That's why I love github. Lot of useful scripts with no doc or even better, cryptic ones (with no examples ofc), which assumes you have some kind of programming level I obviously never have haha.
I would suggest you to begin by dumping the full list of methods, slightly commentated when the name is not explicit enough. Your examples are useful and easy to understand but crawling the files to find the method you need like getCoverImage() is a little annoying. But if you intend to fix that in the near future, no problem, then.

Ohh, I am interested because waiting 10mn between two throttle errors is not my cup of tea. How do you use it?
I tried:
$client=Client::make('eacil', 'iamadumbass');
foreach($arr as $d)
but it got errors.
#80 by leiven
2016-02-18 at 23:39
< report >To be honest the client implementation was kind of implemented as a challenge for myself and I just put it on Github because I was fairly happy with the implementation, even though it obviously still lacks documentation.

The getCompleteUserWishlist() method returns an ArrayCollection instead of the usual Response object (since it also fetches VN information instead of just the IDs).

Try fetching the information like this:

$client = Client::make('username', 'password');

$wishlist = $client->getCompleteUserWishlist();


That should give you an idea of the structure you're working with. The additional calls to getVnInfo() should be obsolute, since fetching that information is already handled in the getCompleteUserWishlist() call.

Please note that this might make you hit the API limits on longer wish lists, in which case I'd do the following:

- Use your original call to getWishlist()
- Put all VN IDs in an array
- Use those IDs in getVnInfos(array $ids)

And store the info for later. Should you hit the API limit you should be able to get the first result set out of the cache, then continue with the second page of results, and so on.
#81 by eacil
2016-02-19 at 02:01
< report >What a LOL. I found that some VN were missing and thought it was because you said it could hit the API limit, like this VN was at the end of my list sorted by id. After some research, I found it was because I couldn't getPriority() out of a VN and it screwed my script. It was because of a ghost in my wishlist (i.e. a deletion not really deleted)

Just to report, when I use getCompleteUserWishlist(), it works but I have a
Notice: Undefined index: page in C:\path\to\vendor\ts\vndb-client\src\Command\Queue\CommandQueue.php on line 102
#82 by leiven
2016-02-19 at 09:13
< report >Interesting bug (?) on the API / VNDB side of things.

The notice is most definitely a bug on my end which I'll look into later tonight (I'm in GMT+1).
#83 by yorhel
2016-02-19 at 11:35
< report >Yeah I'm aware of that issue but wasn't sure how to handle it. I can fix the api to not return deleted vns in the user list commands, but that is inconsistent with te site. I can also modify the get vn command to return something when matching on id, but that may have some weird corner cases.Last modified on 2016-02-19 at 11:39
#84 by leiven
2016-02-19 at 12:23
< report >Any way to expose them as being deleted, for example another filter on the 'get' commands for user lists that a consuming client could default to false/0 to just not fetch them at all?

That way we wouldn't run into issues with fetching deleted VNs, would stay backwards-compatible, while still allowing advanced users to fetch them anyways.
#85 by leiven
2016-02-20 at 14:55
< report >The problem with the page number to fetch not being initialized has been fixed in the most recent release.

I also built a stupid, little weekend project for the lulz: link
#86 by eacil
2016-02-21 at 21:52
< report >Yo, leiven, can we have proper values of return instead of fatal errors when we try to get getVnInfo() out of a bad value, in my case: "Integer out of range"? something like false if the getter couldn't find a proper VN. Same for addWishlistItem() which returns "Command [set] requires an "id" field to be set". Thanks.
Maybe is there already a clean way to check if the id actually exists?Last modified on 2016-02-21 at 21:53
#87 by leiven
2016-02-22 at 15:20
< report >What kind of values are you trying to send?

I'm inclined to assume some kind of ID-10T error, but I don't wanna jump to conclusions.
#88 by eacil
2016-02-22 at 18:27
< report >Yeah, that's a ID-10T error because it's from an input. I can sanitize the data to get an integer as requested but that doesn't mean the integer is valid so the function fail and throw a fatal error, which screw the whole script. Ok, I can always input a good int, what I am supposed to do, but why ungracefully screw the script when it could be beautifully handled like what the API is doing?
#89 by leiven
2016-02-23 at 10:50
< report >You still didn't answer the question as to what you're even trying to do.
#90 by eacil
2016-02-23 at 18:34
< report >You want a concrete example of an user input? Something as simple as:

$client=Client::make('haha', 'hoho');

If the user input is not a valid integer, $d should be ==false. It's not a necessity but it would be cleaner with a proper error handler.Last modified on 2016-02-23 at 18:35
#91 by leiven
2016-02-23 at 21:46
< report >This was another bug (yay bug squashing!), related to caching, and is fixed in yet another new version.

For the future I think we should keep this to GH issues.
#92 by wjdtmddnr24
2016-05-03 at 16:20
< report >How can i use API in Java? I cant get even close on connecting to it and sending commands...Last modified on 2016-05-03 at 16:20
#93 by micah686
2016-05-03 at 17:12
< report >Well, it seems that the original java library is no longer on bitbucket, but you might try adapting the code from fredthebarber's C# library, since java and C# are fairly similar.
#94 by leiven
2016-05-04 at 17:56
< report >Out of curiosity and since I had the idea floating around for awhile now... What would people think of a HTTP proxy which they could install locally to use like a JSON API?
#95 by micah686
2016-05-30 at 09:19
< report >So after about a year of working on my program, I am ready for an alpha release:

It has it's fair share of bugs, but it's fairly stable right now. I'm really looking for anyone that can give me input on the program, I want to make it better for everyone.

Big thanks to FredTheBarber for your C# client and Onkelsam for your Winforms Visual Novel database program, I never would have gotten it this far without your projects.
#96 by abyssaleros
2016-05-30 at 13:18
< report >Looks fine will give it a try.
One question, is it possible to add titles which are not visual novels and are therefore permitted here, like J-RPG and tag them with an approbriate category?
#97 by tyr
2016-05-30 at 13:27
< report >I get a "System.AggregateException" when I'm trying to log in.
#98 by micah686
2016-05-30 at 18:32
< report >@abyssaleros, yes and no.
Currently, you can add any exe, but it also needs an ID from vndb to add it to the local database.

@tyr, I'll take a look and try to find the issue
#99 by tyr
2016-05-30 at 19:42
< report >I'm here if you want me to try something or to give more feedback about the problem.
At the moment I can only say that it happens every time I try to log in and the progress bar is always 2/3 filled.
#100 by micah686
2016-06-05 at 02:05
< report >Could you try this version?!iJtWwY4A!LW-Z36E6A442f3CLYLUwUhL3OfHMPFiFyFw3WQIT5bk

It should generate a log file that I can use to narrow down the problem. Then please post the debug.log file to pastebin or github, so I can know what section I need to work on.