MarketDB API: Difference between revisions

From MuhRO
Jump to navigation Jump to search
(Created page with "== MarketDB API == The MarketDB API serves pre-generated JSON snapshot files for vending, buying and trend data. This endpoint is snapshot-based: * API requests do ''not'' execute live database queries. * Responses are served from JSON files which are usually refreshed every 5 minutes. == Endpoint == Typical request format: <pre> https://flux.muhro.eu/?module=marketdb&action=api&name=<dataset> </pre> == Query Parameters == {| class="wikitable" ! Parameter !...")
 
Line 124: Line 124:
=== Rate Limiting ===
=== Rate Limiting ===


Simple per-IP rate limiting is controlled by <code>MarketDbCache.ApiRatePerMinute</code>.
Default setting:
* <code>120</code> requests per minute
* <code>120</code> requests per minute
=== Gzip Compression ===
If <code>MarketDbCache.ApiEnableGzip</code> is enabled and the client sends <code>Accept-Encoding: gzip</code>, the API returns a gzipped response body.


== Status Codes ==
== Status Codes ==

Revision as of 06:01, 12 April 2026

MarketDB API

The MarketDB API serves pre-generated JSON snapshot files for vending, buying and trend data.

This endpoint is snapshot-based:

  • API requests do not execute live database queries.
  • Responses are served from JSON files which are usually refreshed every 5 minutes.

Endpoint

Typical request format:

https://flux.muhro.eu/?module=marketdb&action=api&name=<dataset>

Query Parameters

Parameter Required Description
name Yes Dataset to fetch.
key No currently not used

Available Datasets

Dataset Description Notes
vendings Current vendor shop list. Shop-level snapshot.
v_vending Items currently for sale. Full rows from the vending cache view.
v_buying Items currently being bought. Full rows from the buying cache view.
buyingstores Current buying shop list. Shop-level snapshot.
vending_trend_daily Full daily sales trend dataset. Includes all available day buckets and items.
vending_trend_hourly Full hourly sales trend dataset. Includes all available hour buckets and items.
vending_last_sales Latest sales log snapshot. Currently limited to 1000 rows.
vending_trend_daily_latest Rolling summary for the last 24 hours. Ordered by sales_count descending.
vending_trend_hourly_latest Rolling summary for the last 60 minutes. Ordered by sales_count descending.
vending_last_sales_latest Latest sales feed. Currently the same 1000-row payload as vending_last_sales.
meta Snapshot metadata. Includes generated_at and server.

Example Requests

https://flux.muhro.eu/?module=marketdb&action=api&name=vendings
https://flux.muhro.eu/?module=marketdb&action=api&name=v_vending
https://flux.muhro.eu/?module=marketdb&action=api&name=v_buying
https://flux.muhro.eu/?module=marketdb&action=api&name=buyingstores
https://flux.muhro.eu/?module=marketdb&action=api&name=vending_trend_daily_latest
https://flux.muhro.eu/?module=marketdb&action=api&name=vending_trend_hourly_latest
https://flux.muhro.eu/?module=marketdb&action=api&name=vending_last_sales_latest

Response Headers

Header Description
Content-Type application/json; charset=utf-8
Cache-Control Public cache header with max-age from MarketDbCache.ApiCacheSeconds.
ETag Entity tag based on the snapshot file and modification time.
Last-Modified Snapshot file modification timestamp in GMT.
Content-Encoding Set to gzip when gzip is enabled and supported by the client.

Default cache TTL:

  • MarketDbCache.ApiCacheSeconds = 300 (5 minutes)

Authentication, Rate Limits, and Compression

Rate Limiting

  • 120 requests per minute

Status Codes

Status Meaning
200 Snapshot returned successfully.
304 The client cache is still valid for the current ETag.
403 Invalid or missing API key when key protection is enabled.
404 Unknown dataset name or snapshot file missing.
429 Rate limit exceeded.
500 MarketDb cache configuration is missing.