Files
f1-circuits/examples/index.html
T
jschoubben db9f386c7a Add a library page: seasons, race weekends and sessions as Plex shows them
The operator wants to browse the posters the way a Plex or Emby Formula 1
library shows them. The page reads the whole library from the one Kometa
file (rounds, race names in the race posters' addresses, sessions in the
episodes'), waits through a fresh server's minutes-long first answer
instead of failing, and loads each picture only when it is on screen, two
at a time, dropping the queue when the reader leaves a level: every
poster is a render of about 10 s that pulls map tiles. Each level has its
own address and back/forward work; a picture the server has none for is
a plain card with its name.

The session order per weekend format moves into site.js, so the posters
page and the library read the same list.

Claude-Session: https://claude.ai/code/session_01NcbgfJAa38xFpzy69BWrqh
2026-11-27 10:33:19 +01:00

146 lines
6.6 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>F1 Circuits API · examples</title>
<meta name="description" content="Worked examples of every route of the F1 Circuits API: circuits, track images, GPS traces, grand prix lookup, posters and Kometa metadata.">
<link rel="icon" href="data:,">
<link rel="stylesheet" href="site.css">
</head>
<body>
<header class="site">
<a class="brand" href="index.html">F1 <span>Circuits</span> API</a>
<nav aria-label="Examples">
<a href="index.html" aria-current="page">Overview</a>
<a href="circuits.html">Circuit browser</a>
<a href="tracks.html">Track images</a>
<a href="map.html">GPS traces</a>
<a href="grand-prix.html">Grand prix lookup</a>
<a href="posters.html">Posters</a>
<a href="kometa.html">Kometa</a>
<a href="library.html">Library</a>
</nav>
<div id="api-base"></div>
</header>
<main>
<h1>The F1 Circuits API, by example</h1>
<p class="lead">
F1 Circuits serves the layout of every Formula 1 circuit, one per period the track was raced in, traced by GPS:
as an SVG drawing, a PNG image and the GeoJSON trace itself. On top of the layouts it renders race and season
posters, session thumbnails and a Kometa metadata file for a Formula 1 library in Plex.
</p>
<p>
The public address is <a href="https://f1-circuits.zurag.be/">https://f1-circuits.zurag.be</a>. Every route is a
plain <code>GET</code>, needs no key, and allows any origin (CORS), so a page anywhere can call it from the browser.
Each page below makes real calls and shows the exact URL it sends next to the answer: copy it into a terminal
(<code>curl -O &lt;url&gt;</code>) or a page of your own.
</p>
<h2>The examples</h2>
<div class="pages">
<a class="page" href="circuits.html">
<h3>Circuit browser</h3>
<p>Walk the catalogue: countries, their cities, the circuits there and each circuit’s layouts, with every layout’s track image.</p>
<ul>
<li><code>/circuits</code></li>
<li><code>/circuits/{country}</code></li>
<li><code>/circuits/{country}/{city}</code></li>
<li><code>/circuits/{country}/{city}/{circuit}</code></li>
<li><code>/circuits/{country}/{city}/{circuit}/layout/{layout}</code></li>
</ul>
</a>
<a class="page" href="tracks.html">
<h3>Track images</h3>
<p>One layout’s file in SVG, PNG or GeoJSON, chosen by its layout or by a year the circuit was raced.</p>
<ul>
<li><code>/circuits/{country}/{city}/{circuit}/layout/{layout}/{format}</code></li>
<li><code>/tracks/{country}/{city}/{circuit}/year/{year}/{format}</code></li>
</ul>
</a>
<a class="page" href="map.html">
<h3>GPS traces on a map</h3>
<p>Draw a layout’s GeoJSON trace on an OpenStreetMap or satellite map, with its length and start point.</p>
<ul>
<li><code>/circuits/{country}/{city}/{circuit}/layout/{layout}/geojson</code></li>
</ul>
</a>
<a class="page" href="grand-prix.html">
<h3>Grand prix lookup</h3>
<p>Name a race and a season; the API finds the circuit and the layout raced that year.</p>
<ul>
<li><code>/grand-prix/{race name}/{season}/{format}</code></li>
</ul>
</a>
<a class="page" href="posters.html">
<h3>Posters</h3>
<p>Race posters on five backgrounds, season posters and a thumbnail per session of a race weekend, rendered on request.</p>
<ul>
<li><code>/posters/race/{race name}/{season}.png?bg={aerial|osm|dark|light|none}</code></li>
<li><code>/posters/season/{season}.png</code></li>
<li><code>/posters/session/{race name}/{season}/{session}.png</code></li>
</ul>
</a>
<a class="page" href="kometa.html">
<h3>Kometa metadata</h3>
<p>The metadata file that gives a Plex Formula 1 library every poster and thumbnail above, and how Kometa uses it.</p>
<ul>
<li><code>/kometa/formula-1-metadata.yml</code></li>
</ul>
</a>
<a class="page" href="library.html">
<h3>Library</h3>
<p>Browse a Formula 1 library as Plex or Emby shows it: seasons, race weekends and sessions, from the Kometa file and the posters.</p>
<ul>
<li><code>/kometa/formula-1-metadata.yml</code></li>
<li><code>/posters/season/{season}.png</code></li>
<li><code>/posters/race/{race name}/{season}.png</code></li>
<li><code>/posters/session/{race name}/{season}/{session}.png</code></li>
</ul>
</a>
</div>
<h2>Choosing which API a page calls</h2>
<div class="card">
<p>
One helper (<a href="site.js"><code>site.js</code></a>) picks the address for every page, in this order:
</p>
<ol>
<li><code>?api=&lt;base&gt;</code> in the page’s address wins, such as <code>?api=http://127.0.0.1:8000</code>. Links between the pages keep it.</li>
<li>A page opened from disk (<code>file://</code>) calls the public service, <code>https://f1-circuits.zurag.be</code>.</li>
<li>A page served over http(s), as the API serves these pages at <code>/examples/</code>, calls its own origin with relative URLs.</li>
</ol>
<p>The address in use is in the header, top right; open it to change it.</p>
</div>
<h2>The API’s own index</h2>
<p>The root route lists the routes and where these examples live.</p>
<div class="card" id="root-call">
<div class="request"></div>
<div class="status"></div>
<div class="result"></div>
</div>
<h2>Words used here</h2>
<table class="kv">
<tr><th>Country, city, circuit</th><td>Slugs in lower case with hyphens, as the <code>/circuits</code> routes list them (<code>belgium</code>, <code>spa</code>, <code>circuit-de-spa-francorchamps</code>). A slug may hold accented letters; encode it in a URL.</td></tr>
<tr><th>Layout</th><td>One shape of a circuit, named by the years it was raced: <code>1950-1970</code>, <code>1983-</code> (1983 until today), or a single year.</td></tr>
<tr><th>Format</th><td><code>svg</code>, <code>png</code> or <code>geojson</code>.</td></tr>
<tr><th>Race name</th><td>The race’s name exactly as <a href="https://api.jolpi.ca/ergast/f1/2024.json">Jolpica</a> (the Ergast successor) writes it, such as <code>Belgian Grand Prix</code>; the API reads the season’s schedule there.</td></tr>
</table>
</main>
<footer class="pager">
<span></span>
<a class="home" href="index.html">All examples</a>
<a rel="next" href="circuits.html">Circuit browser →</a>
</footer>
<script src="site.js"></script>
<script>
F1.callJSON(document.getElementById('root-call'), F1.api('/'));
</script>
</body>
</html>