{
    "openapi": "3.1.0",
    "info": {
        "title": "KraftstoffTanken.de Spritpreis-API",
        "version": "1.0.0",
        "description": "Aktuelle Kraftstoffpreise (Diesel, Super E5, Super E10) aus den Daten der Markttransparenzstelle für Kraftstoffe (MTS-K). Authentifizierung über den Parameter apikey. Kontingent-Stufen: free (10.000/Tag), pro (100.000/Tag), partner (1.000.000/Tag).",
        "contact": {
            "name": "KraftstoffTanken.de",
            "url": "https://kraftstofftanken.de/portal/docs.php"
        },
        "license": {
            "name": "Datenquelle: Markttransparenzstelle für Kraftstoffe (MTS-K)"
        }
    },
    "servers": [
        {
            "url": "https://kraftstofftanken.de/api.php"
        }
    ],
    "components": {
        "securitySchemes": {
            "apiKey": {
                "type": "apiKey",
                "in": "query",
                "name": "apikey"
            }
        },
        "schemas": {
            "Station": {
                "type": "object",
                "properties": {
                    "id": {
                        "type": "string"
                    },
                    "brand": {
                        "type": "string"
                    },
                    "name": {
                        "type": "string"
                    },
                    "street": {
                        "type": "string"
                    },
                    "houseNumber": {
                        "type": "string"
                    },
                    "postCode": {
                        "type": "string"
                    },
                    "place": {
                        "type": "string"
                    },
                    "lat": {
                        "type": "number"
                    },
                    "lng": {
                        "type": "number"
                    },
                    "dist": {
                        "type": "number"
                    },
                    "diesel": {
                        "type": [
                            "number",
                            "null"
                        ]
                    },
                    "e5": {
                        "type": [
                            "number",
                            "null"
                        ]
                    },
                    "e10": {
                        "type": [
                            "number",
                            "null"
                        ]
                    },
                    "isOpen": {
                        "type": "boolean"
                    }
                }
            }
        }
    },
    "security": [
        {
            "apiKey": []
        }
    ],
    "paths": {
        "/?action=v1_stations": {
            "get": {
                "summary": "Tankstellen im Umkreis",
                "parameters": [
                    {
                        "name": "action",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "const": "v1_stations"
                        }
                    },
                    {
                        "name": "apikey",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Dein API-Key"
                    },
                    {
                        "name": "lat",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "number"
                        }
                    },
                    {
                        "name": "lng",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "number"
                        }
                    },
                    {
                        "name": "rad",
                        "in": "query",
                        "schema": {
                            "type": "number",
                            "minimum": 1,
                            "maximum": 25,
                            "default": 5
                        }
                    },
                    {
                        "name": "type",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "all",
                                "diesel",
                                "e5",
                                "e10"
                            ],
                            "default": "all"
                        }
                    },
                    {
                        "name": "page",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "default": 1
                        }
                    },
                    {
                        "name": "per_page",
                        "in": "query",
                        "schema": {
                            "type": "integer",
                            "minimum": 1,
                            "maximum": 200,
                            "default": 50
                        }
                    },
                    {
                        "name": "format",
                        "in": "query",
                        "schema": {
                            "type": "string",
                            "enum": [
                                "json",
                                "geojson"
                            ],
                            "default": "json"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Liste von Tankstellen (JSON oder GeoJSON FeatureCollection)",
                        "headers": {
                            "X-RateLimit-Limit": {
                                "schema": {
                                    "type": "integer"
                                },
                                "description": "Tageslimit der Stufe"
                            },
                            "X-RateLimit-Remaining": {
                                "schema": {
                                    "type": "integer"
                                },
                                "description": "Verbleibende Anfragen heute"
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "ok": {
                                            "type": "boolean"
                                        },
                                        "total": {
                                            "type": "integer"
                                        },
                                        "page": {
                                            "type": "integer"
                                        },
                                        "per_page": {
                                            "type": "integer"
                                        },
                                        "stations": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/components/schemas/Station"
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "API-Key ungültig/nicht freigegeben/deaktiviert"
                    },
                    "429": {
                        "description": "Tageslimit erreicht"
                    }
                }
            }
        },
        "/?action=v1_prices": {
            "get": {
                "summary": "Preise für bis zu 50 Stationen",
                "parameters": [
                    {
                        "name": "action",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "const": "v1_prices"
                        }
                    },
                    {
                        "name": "apikey",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Dein API-Key"
                    },
                    {
                        "name": "ids",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Komma-getrennte IDs"
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Preis-Map je Station",
                        "headers": {
                            "X-RateLimit-Limit": {
                                "schema": {
                                    "type": "integer"
                                },
                                "description": "Tageslimit der Stufe"
                            },
                            "X-RateLimit-Remaining": {
                                "schema": {
                                    "type": "integer"
                                },
                                "description": "Verbleibende Anfragen heute"
                            }
                        }
                    },
                    "403": {
                        "description": "Auth-Fehler"
                    },
                    "429": {
                        "description": "Limit"
                    }
                }
            }
        },
        "/?action=v1_detail": {
            "get": {
                "summary": "Einzelne Station",
                "parameters": [
                    {
                        "name": "action",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "const": "v1_detail"
                        }
                    },
                    {
                        "name": "apikey",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Dein API-Key"
                    },
                    {
                        "name": "id",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "Stationsdetail",
                        "headers": {
                            "X-RateLimit-Limit": {
                                "schema": {
                                    "type": "integer"
                                },
                                "description": "Tageslimit der Stufe"
                            },
                            "X-RateLimit-Remaining": {
                                "schema": {
                                    "type": "integer"
                                },
                                "description": "Verbleibende Anfragen heute"
                            }
                        },
                        "content": {
                            "application/json": {
                                "schema": {
                                    "type": "object",
                                    "properties": {
                                        "ok": {
                                            "type": "boolean"
                                        },
                                        "station": {
                                            "$ref": "#/components/schemas/Station"
                                        }
                                    }
                                }
                            }
                        }
                    },
                    "403": {
                        "description": "Auth-Fehler"
                    },
                    "429": {
                        "description": "Limit"
                    }
                }
            }
        },
        "/?action=v1_complaint": {
            "post": {
                "summary": "Beschwerde an die MTS-K melden",
                "parameters": [
                    {
                        "name": "action",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string",
                            "const": "v1_complaint"
                        }
                    },
                    {
                        "name": "apikey",
                        "in": "query",
                        "required": true,
                        "schema": {
                            "type": "string"
                        },
                        "description": "Dein API-Key"
                    }
                ],
                "requestBody": {
                    "required": true,
                    "content": {
                        "application/x-www-form-urlencoded": {
                            "schema": {
                                "type": "object",
                                "required": [
                                    "id",
                                    "type"
                                ],
                                "properties": {
                                    "id": {
                                        "type": "string"
                                    },
                                    "type": {
                                        "type": "string",
                                        "enum": [
                                            "wrongPriceE5",
                                            "wrongPriceE10",
                                            "wrongPriceDiesel",
                                            "wrongStatusOpen",
                                            "wrongStatusClosed",
                                            "wrongPetrolStationLocation"
                                        ]
                                    },
                                    "content": {
                                        "type": "string",
                                        "description": "Korrigierter Preis bzw. lat,lng"
                                    }
                                }
                            }
                        }
                    }
                },
                "responses": {
                    "202": {
                        "description": "Beschwerde entgegengenommen",
                        "headers": {
                            "X-RateLimit-Limit": {
                                "schema": {
                                    "type": "integer"
                                },
                                "description": "Tageslimit der Stufe"
                            },
                            "X-RateLimit-Remaining": {
                                "schema": {
                                    "type": "integer"
                                },
                                "description": "Verbleibende Anfragen heute"
                            }
                        }
                    },
                    "400": {
                        "description": "Ungültige Parameter"
                    },
                    "403": {
                        "description": "Auth-Fehler"
                    },
                    "429": {
                        "description": "Limit"
                    }
                }
            }
        }
    }
}