Every ResearchBox API call goes through here: it adds the key, waits as long as ResearchBox asks when a request comes too soon, and turns every failure into an error message instead of a condition.
Arguments
- action
the API action (
"box_meta","list_files","download_files","search"or"get_aspredicted")- ...
further form fields for the action (e.g.
box_id)- code
a box's peer-review passcode (see
.rbox_code()), sent only when it is not NA- path
a file to write the response to (for
"download_files"), or NULL to keep it in memory
Value
a list with ok (logical), error (NA or a message), and body
(the parsed JSON reply, or NULL when path is given)
Details
A refusal that cannot be waited out (a wait longer than a minute, which
ResearchBox's hourly and daily limits ask for, or a wait that kept being
refused) is reported with the prefix "API rate limit exhausted: ", the same
text download_repo_files() uses, so these can be told apart from other
failures and rerun once the limit has passed.
ResearchBox blocks a key for 10 days after 10 requests for boxes that are not public, sent without their passcode, and answers those as if the box did not exist. After 8 such answers within 10 days, a request for a box without a passcode is not sent; the error says why.
"get_aspredicted" (AsPredicted's preregistrations, see
aspredicted_info()) has limits of its own: its daily limit is recorded
apart from the limit for boxes, so reaching one does not stop requests of
the other kind. A key ResearchBox refuses stops both. Its count of
preregistrations that could not be found is kept by
.aspredicted_info_api().
