{"id":50646129,"url":"https://github.com/Flerex/spain-gas","last_synced_at":"2026-06-24T09:00:50.726Z","repository":{"id":62505477,"uuid":"331947359","full_name":"Flerex/spain-gas","owner":"Flerex","description":"A PHP client to get information about Spain's gas stations and fuel prices, directly from the Spanish government's Geoportal Gasolineras.","archived":false,"fork":false,"pushed_at":"2021-06-12T17:40:03.000Z","size":105,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-25T14:46:54.975Z","etag":null,"topics":["api","gas","gasoline","gasoline-prices","gasolineras","geoportal","php","precios","spain"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Flerex.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-01-22T13:00:35.000Z","updated_at":"2024-10-30T15:05:01.000Z","dependencies_parsed_at":"2022-11-02T12:45:29.756Z","dependency_job_id":null,"html_url":"https://github.com/Flerex/spain-gas","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/Flerex/spain-gas","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flerex%2Fspain-gas","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flerex%2Fspain-gas/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flerex%2Fspain-gas/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flerex%2Fspain-gas/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Flerex","download_url":"https://codeload.github.com/Flerex/spain-gas/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Flerex%2Fspain-gas/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34724743,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-24T02:00:07.484Z","response_time":106,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","gas","gasoline","gasoline-prices","gasolineras","geoportal","php","precios","spain"],"created_at":"2026-06-07T13:00:29.297Z","updated_at":"2026-06-24T09:00:50.719Z","avatar_url":"https://github.com/Flerex.png","language":"PHP","funding_links":[],"categories":["Combustible y Estaciones de Servicio"],"sub_categories":["FilmAffinity"],"readme":"# Spain Gas\n![Header](https://github.com/Flerex/spain-gas/blob/main/repo/header.png?raw=true)\n[![Packagist Version](https://img.shields.io/packagist/v/flerex/spain-gas?label=Packagist)](https://packagist.org/packages/flerex/spain-gas)\n[![Total Downloads](https://img.shields.io/packagist/dt/flerex/spain-gas?label=Downloads)](https://packagist.org/packages/flerex/spain-gas)\n\nSpain Gas is a PHP client that act as a wrapper around Spain's Geoportal Gasolineras API. It has the following main features:\n\n- Obtain **data about all gas stations** in Spain: addresses, geolocation, provided services, schedules and much more!\n- Exact **prices of fuel** for every gas station in the country, updated multiple times every day.\n- Beautifully designed interface using design patterns like the builder pattern.\n- Statically typed with the latest PHP typing features. \n- Properly tested with coverage higher than 80%.\n\n## Requirements\n- You need `composer` to be installed, either globally or locally in your project.\n- Compatible with **PHP 7.4 or higher**.\n- PHP's extensions needed: `ext-json` and `ext-simplexml`.\n\n## Installation\nTo install this package be sure to have `composer` installed and run the following command in your project's directory:\n\n```\ncomposer require flerex/spain-gas\n```\n \n## Usage\nAll the API's endpoints are available by using the GasApi class. Currently, there are only two endpoints for the API:\n\n- **`gasStations`**: This is the most useful endpoint. With it, you can find gas stations by different filters such as province or availability.  \n- **`towns`**: Returns a list of `Town` objects. Useful to obtain the ID of a specific town to use as filter in other endpoints.  \n- **`locateGasStations`**: This endpoint provides the geographical location of gas stations. The only difference with the previous endpoint is that provides a ranking of the gas station according to the price of the fuel (if specified as a filter).\n\n**NOTE:** All the aforementioned endpoints will provide the price of the fuel if specified by using the query filter `fuel`. Otherwise, it will always return `null`.\n\nEvery endpoint returns an instance of a Builder class, which provides methods to filter the request to be made. Once you selected your filtering parameters, a call to method `get` is required to actually run the request and retrieve the data.\n\nIn case you need more information about what filters are available check the Documentation.\n\n\n## Endpoints\nHere is a list of all available endpoints, and the differences in the data retrieved.\n| Endpoint          | Documentation                                                                 | Ranking                  | Prices                   | Geographical Location    | Station Information      | Town ID                  |\n|-------------------|-------------------------------------------------------------------------------|--------------------------|--------------------------|--------------------------|--------------------------|--------------------------|\n| gasStations       | [Wiki](https://github.com/Flerex/spain-gas/wiki/Gas-Stations-endpoint)        | :heavy_multiplication_x: | :heavy_check_mark: \\*    | :heavy_check_mark:       | :heavy_check_mark:       | :heavy_multiplication_x: |\n| locateGasStations | [Wiki](https://github.com/Flerex/spain-gas/wiki/Locate-Gas-Stations-endpoint) | :heavy_check_mark: \\*    | :heavy_check_mark: \\*    | :heavy_check_mark:       | :heavy_multiplication_x: | :heavy_multiplication_x: |\n| towns             | [Wiki](https://github.com/Flerex/spain-gas/wiki/Towns-endpoint)               | :heavy_multiplication_x: | :heavy_multiplication_x: | :heavy_multiplication_x: | :heavy_multiplication_x: | :heavy_check_mark:       |\n\n\\* Only returned when filtering by fuel.\n## Example\n\n### Obtain Stations by Fuel\nHere is an example where we are retrieving all CNG gas stations in Spain:\n\n```php\nuse Flerex\\SpainGas\\Enums\\Fuel;\nuse Flerex\\SpainGas\\GasApi;\n\n$stations = GasApi::gasStations()\n    -\u003efuel(Fuel::CNG())\n    -\u003eget();\n```\n\n### Get specific town ID\nLet us suppose we needed to obtain all gas stations in A Coruña (city). To be able to filter by town in the `gasStations` endpoint, we will first need to retrieve the ID of the town.\n\n```php\nuse Flerex\\SpainGas\\Dtos\\Town;\nuse Flerex\\SpainGas\\Enums\\Province;\nuse Flerex\\SpainGas\\GasApi;\n\n$towns = GasApi::towns()\n    -\u003eprovince(Province::A_CORUNHA())\n    -\u003eget();\n    \n$townId = array_filter($towns, fn(Town $town) =\u003e stripos($town-\u003ename, 'Coruña') !== false)[0];\n\n// Everything up to this point could be done once and then be replaced with the obtained ID to avoid unnecessary API calls. \n\n$stations = GasApi::gasStations()\n    -\u003etown($townId)\n    -\u003eget();\n```\n\n### Get the price ranking\nPrice rankings are used to categorize the price of some fuel in a gas station comparing it to their competitors. The algorithm used by the API is unknown.\n\nUnfortunately, rankings are only available in the `locateGasStations` endpoints.\n\nIn the following example we are going to retrieve the cheapest self-service gas stations.\n\n```php\nuse Flerex\\SpainGas\\Dtos\\GasStationLocation;\nuse Flerex\\SpainGas\\Enums\\Rank;\nuse Flerex\\SpainGas\\Enums\\Fuel;\nuse Flerex\\SpainGas\\Enums\\ServiceType;\nuse Flerex\\SpainGas\\GasApi;\n\n$stations = GasApi::locateGasStations()\n    -\u003eserviceType(ServiceType::SELF_SERVICE())\n    -\u003efuel(Fuel::DIESEL_A())\n    -\u003eget();\n\n$cheapest = array_filter($stations, fn(GasStationLocation $station) =\u003e $station-\u003erank-\u003eequals(Rank::CHEAP()));\n```\n**NOTE:** We need to specify a fuel so that rankings are provided in return.\n\n## Changelog\nChangelog can be found in [releases](https://github.com/flerex/spain-gas/releases).\n\n## Copyright and License\n\n[Spain Gas](https://github.com/flerex/spain-gas) was written by [Flerex](https://flerex.dev) and is released under the\n[MIT License](LICENSE).\n\n© Flerex 2020\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFlerex%2Fspain-gas","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FFlerex%2Fspain-gas","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFlerex%2Fspain-gas/lists"}