diff --git a/app.py b/app.py index 42e95a3..f1a9432 100644 --- a/app.py +++ b/app.py @@ -945,5 +945,76 @@ def meds(): situations=situations) +@app.route("/barters") +def barters(): + import requests as _req + + API_URL = "https://api.tarkov.dev/graphql" + query = """ + { + barters(lang: en) { + id + trader { name } + level + taskUnlock { name } + requiredItems { + item { id name shortName iconLink wikiLink } + count + } + rewardItems { + item { id name shortName iconLink wikiLink } + count + } + } + } + """ + try: + resp = _req.post(API_URL, json={"query": query}, timeout=15) + data = resp.json() + raw_barters = data.get("data", {}).get("barters", []) + except Exception: + raw_barters = [] + + barter_list = [] + for b in raw_barters: + reward_items = b.get("rewardItems", []) + required_items = b.get("requiredItems", []) + if not reward_items or not required_items: + continue + + # Use first reward item as the "output" item + reward = reward_items[0] + reward_item = reward.get("item") or {} + reward_count = reward.get("count", 1) + + required = [] + for ri in required_items: + item = ri.get("item") or {} + required.append({ + "id": item.get("id", ""), + "name": item.get("name", "Unknown"), + "short": item.get("shortName", ""), + "icon": item.get("iconLink"), + "count": ri.get("count", 1), + }) + + task_unlock = b.get("taskUnlock") + barter_list.append({ + "id": b.get("id", ""), + "trader": (b.get("trader") or {}).get("name", "Unknown"), + "level": b.get("level", 1), + "task_unlock": task_unlock.get("name") if task_unlock else None, + "reward_name": reward_item.get("name", "Unknown"), + "reward_short": reward_item.get("shortName", ""), + "reward_icon": reward_item.get("iconLink"), + "reward_wiki": reward_item.get("wikiLink"), + "reward_count": reward_count, + "required": required, + }) + + barter_list.sort(key=lambda b: (b["trader"], b["level"], b["reward_name"])) + return render_template("barters.html", barters=barter_list) + + if __name__ == "__main__": app.run(host="0.0.0.0", port=5000, debug=True) diff --git a/templates/barters.html b/templates/barters.html new file mode 100644 index 0000000..35e5c86 --- /dev/null +++ b/templates/barters.html @@ -0,0 +1,398 @@ + + + + OnlyScavs – Barter Calculator + + + + +
+ + + +

Barter Calculator

+

Enter flea market prices for required items to see the total rouble cost of any barter.

+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+ +
+
+ + {% if barters %} +
+ {% for b in barters %} +
+ +
+ {% if b.reward_icon %} + {{ b.reward_short }} + {% endif %} +
+
+ {% if b.reward_wiki %} + {{ b.reward_name }}{% if b.reward_count > 1 %} ×{{ b.reward_count }}{% endif %} + {% else %} + {{ b.reward_name }}{% if b.reward_count > 1 %} ×{{ b.reward_count }}{% endif %} + {% endif %} +
+
{{ b.trader }} · LL{{ b.level }}
+
+ {{ b.trader }} LL{{ b.level }} + {% if b.task_unlock %} + 🔒 {{ b.task_unlock }} + {% endif %} +
+ +
Required items
+
+ {% for ri in b.required %} +
+ {% if ri.icon %} + {{ ri.short }} + {% else %} +
+ {% endif %} +
+
{{ ri.name }}
+
× {{ ri.count }}
+
+
+ + +
+
+ {% endfor %} +
+ +
+ Total cost: + + Enter prices above to calculate +
+ +
+ {% endfor %} +
+ {% else %} +
No barter data available. Check your connection to tarkov.dev.
+ {% endif %} + +
+ + + diff --git a/templates/collector.html b/templates/collector.html index c5db8c1..2ecd068 100644 --- a/templates/collector.html +++ b/templates/collector.html @@ -299,6 +299,8 @@ Loadout Planner  |  Injectors +  |  + Barters

Collector Checklist

diff --git a/templates/index.html b/templates/index.html index 9ec8296..24aa36e 100644 --- a/templates/index.html +++ b/templates/index.html @@ -176,6 +176,8 @@ Loadout Planner  |  Injectors +  |  + Barters

OnlyScavs – Keys

diff --git a/templates/keys.html b/templates/keys.html index 131221d..92ac4df 100644 --- a/templates/keys.html +++ b/templates/keys.html @@ -235,6 +235,7 @@ Quests Loadout Injectors + Barters

Key Ratings

diff --git a/templates/landing.html b/templates/landing.html index b278e15..4328669 100644 --- a/templates/landing.html +++ b/templates/landing.html @@ -114,6 +114,11 @@
Injectors
Compare stim effects, skills, and side effects.
+ +
🔄
+
Barter Calculator
+
Calculate the true rouble cost of any barter by entering flea market prices.
+
diff --git a/templates/loadout.html b/templates/loadout.html index 4551c86..9912bf2 100644 --- a/templates/loadout.html +++ b/templates/loadout.html @@ -226,7 +226,8 @@ Keys  |  Collector  |  Quests  |  - Injectors + Injectors  |  + Barters

Loadout Planner

diff --git a/templates/meds.html b/templates/meds.html index 2325d9b..82c80b6 100644 --- a/templates/meds.html +++ b/templates/meds.html @@ -253,6 +253,7 @@ Collector Loadout Injectors + Barters

Injector Quick Reference

diff --git a/templates/quests.html b/templates/quests.html index 8f1487a..dc4a6e7 100644 --- a/templates/quests.html +++ b/templates/quests.html @@ -236,6 +236,8 @@ Loadout Planner  |  Injectors +  |  + Barters

Quest Trees