I don't want to really waste a credit to the search.json just to see
my remaining credits.
Is there something I may be doing wrong, or is this indented, or might
it be a bug?
Thanks
Instead of requesting credit.json and then search.json, just request search.json.
If you are out of credits, search.json will return http status code 503 to let you know and the headers will contain the reset time for your credits.
credit.json probably shouldn't even be an exposed api because its easy to make the mistake of thinking you need to use it and end up doing two requests instead of one which is a waste. The behavior you're seeing can be viewed as a bug or a feature, depending on how you look at it. Without going into implementation details, the short explanation is that credit tracking is not exact, so you should not depend on the numbers and instead just make requests until they fail.
- Jason T.
OK, I misunderstood then. When you wrote "before doing a bulk search to make sure that I have enough credits", it sounded like you were using it before each batch of search queries. Using credit.json for a dashboard type display is one of the few legit usages. I'll see if I can track down the bug that is causing it to always return 0 remaining credits. I'd still caution that the values returned are not reliable for a variety of good reasons and it is best to ignore them and just make requests.