comicbox.formats.versedb_api.client ¶
The versedb SDK adapter: the only module in comicbox that imports versedb.
The SDK is generated code (openapi-python-client). It ships no rate limiter, no response cache and no retry, and it reports errors as return values. Its function names come from endpoint summaries and can change when it is regenerated. So the rest of comicbox sees only this module: plain dicts of the server’s own JSON and the comicbox exceptions below. A renamed SDK function touches this file alone, and its internals could be swapped for raw httpx without changing anything else.
What this adds on top of the SDK:
- One
httpx.Client, built eagerly. The SDK builds it lazily and mutates its own headers first, which races across worker threads. - Responses mapped by HTTP status, never by SDK model class.
- A guard for the SDK’s strict parsing. A missing key, or a non-JSON error body, raises inside the SDK before it returns, losing the status. A response hook records each status first, so a failed parse can still be mapped by it.
- The optional response cache (
versedb_api.cache): 200s only, and never one markedno-store. - A 429 cooldown: until the server’s
Retry-Afterhas passed, every call fails at once without sending, so N workers don’t each spend a request to learn the same thing. A wait longer than the retry layer will ever do (a daily cap) is aVerseDBQuotaError, never retried: VerseDB is not asked again until it lapses, and the run’s other sources carry on. - The hourly budget from
X-RateLimit-*, for the doctor and Codex.
versedb is imported inside functions only: its endpoint modules load all 1,011 of its model modules, about 0.8 s, so the exception classes here can be imported without paying for it.
VerseDBAuthError ¶
Bases: VerseDBError
HTTP 401 or 403: the request was refused, and retrying won’t change that.
A 401 is a missing or wrong token. A 403 is a token without a scope the request needs, or, when it carries no X-RateLimit-* headers, something in front of VerseDB’s API refusing it (it sits behind Cloudflare).
Source code in comicbox/formats/versedb_api/client.py
87 88 89 90 91 92 93 94 95 | |
VerseDBClient ¶
VerseDB’s API as plain dicts and comicbox exceptions.
Thread-safe: one instance is shared by every worker of a run.
Source code in comicbox/formats/versedb_api/client.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 | |
closed property ¶
Whether close has run; a closed client cannot send.
__init__(token, *, user_agent, base_url=None, cache=None, transport=None) ¶
Build the SDK client and its httpx.Client now, not lazily.
Source code in comicbox/formats/versedb_api/client.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 | |
close() ¶
Close the connection pool and the cache. Safe to call twice.
Source code in comicbox/formats/versedb_api/client.py
331 332 333 334 335 336 | |
issue(issue_id) ¶
Fetch the full detail of one issue.
Source code in comicbox/formats/versedb_api/client.py
305 306 307 | |
list_issues(series_ids, number=None, *, page=1) ¶
One page of issues across several series, each row with its series.
number goes to the server’s q, which matches loosely: the number’s prefix, the issue’s name, the series name and the slug. The caller filters for the exact number.
Source code in comicbox/formats/versedb_api/client.py
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 | |
probe() ¶
Send the cheapest request, uncached, and return the budget it left.
Source code in comicbox/formats/versedb_api/client.py
309 310 311 312 | |
rate_limit_status() ¶
Report the hourly budget the last response carried, as the doctor reads it.
{"hour": {"limit", "remaining", "reset_epoch"}}, or {} before any response carried the headers. VerseDB sends no reset time.
Source code in comicbox/formats/versedb_api/client.py
314 315 316 317 318 319 320 321 322 323 324 | |
search_series(name, limit) ¶
One page of series whose name matches name, best first.
Source code in comicbox/formats/versedb_api/client.py
274 275 276 277 | |
VerseDBError ¶
Bases: Exception
Base class for every failure the adapter reports.
Source code in comicbox/formats/versedb_api/client.py
83 84 | |
VerseDBNotFoundError ¶
Bases: VerseDBError
HTTP 404: no such issue.
Source code in comicbox/formats/versedb_api/client.py
98 99 | |
VerseDBQuotaError ¶
Bases: VerseDBError
VerseDB refuses requests for longer than comicbox ever waits.
A 429 whose Retry-After is past retry.MAX_RATE_LIMIT_WAIT_S, most likely the free tier’s 4,000-a-day cap. Retrying would only sleep out the ceiling and be refused again, so this is never retried, and the client sends nothing more until resume_at (epoch seconds).
Source code in comicbox/formats/versedb_api/client.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 | |
__init__(message, resume_at) ¶
Keep when VerseDB said to come back.
Source code in comicbox/formats/versedb_api/client.py
126 127 128 129 | |
VerseDBRateLimitError ¶
Bases: VerseDBError
HTTP 429, or a call refused while a 429’s cooldown runs.
retry_after is the seconds the server asked for, read by retry._retry_after; None when it named none.
Source code in comicbox/formats/versedb_api/client.py
102 103 104 105 106 107 108 109 110 111 112 113 | |
__init__(message, retry_after=None) ¶
Keep the server’s hint for the retry layer.
Source code in comicbox/formats/versedb_api/client.py
110 111 112 113 | |
VerseDBResponseError ¶
Bases: VerseDBError
Any other status, or a response the versedb package could not parse.
Source code in comicbox/formats/versedb_api/client.py
136 137 | |
VerseDBServerError ¶
Bases: VerseDBError
HTTP 5xx.
Source code in comicbox/formats/versedb_api/client.py
132 133 | |
endpoint_keywords() ¶
List the keyword parameters of each SDK function, for the drift test.
Imports the SDK; call it from tests only.
Source code in comicbox/formats/versedb_api/client.py
499 500 501 502 503 504 505 506 507 508 509 510 | |