ukfuelfinder 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ukfuelfinder/__init__.py +47 -0
- ukfuelfinder/auth.py +111 -0
- ukfuelfinder/cache.py +70 -0
- ukfuelfinder/client.py +257 -0
- ukfuelfinder/config.py +62 -0
- ukfuelfinder/exceptions.py +83 -0
- ukfuelfinder/http_client.py +116 -0
- ukfuelfinder/models.py +154 -0
- ukfuelfinder/rate_limiter.py +72 -0
- ukfuelfinder/services/__init__.py +1 -0
- ukfuelfinder/services/forecourt_service.py +108 -0
- ukfuelfinder/services/price_service.py +72 -0
- ukfuelfinder-1.0.0.dist-info/METADATA +233 -0
- ukfuelfinder-1.0.0.dist-info/RECORD +17 -0
- ukfuelfinder-1.0.0.dist-info/WHEEL +5 -0
- ukfuelfinder-1.0.0.dist-info/licenses/LICENSE +21 -0
- ukfuelfinder-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,233 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ukfuelfinder
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Python library for accessing the UK Government Fuel Finder API
|
|
5
|
+
Home-page: https://github.com/mretallack/ukfuelfinder
|
|
6
|
+
Author: Mark Retallack
|
|
7
|
+
Author-email: Mark Retallack <mark@retallack.org.uk>
|
|
8
|
+
License: MIT
|
|
9
|
+
Project-URL: Homepage, https://github.com/mretallack/ukfuelfinder
|
|
10
|
+
Project-URL: Documentation, https://github.com/mretallack/ukfuelfinder/blob/main/README.md
|
|
11
|
+
Project-URL: Repository, https://github.com/mretallack/ukfuelfinder
|
|
12
|
+
Project-URL: Issues, https://github.com/mretallack/ukfuelfinder/issues
|
|
13
|
+
Keywords: fuel,prices,uk,government,api,petrol,diesel
|
|
14
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
15
|
+
Classifier: Intended Audience :: Developers
|
|
16
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
17
|
+
Classifier: Programming Language :: Python :: 3
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Requires-Python: >=3.8
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: requests>=2.31.0
|
|
27
|
+
Requires-Dist: python-dateutil>=2.8.0
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
30
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
31
|
+
Requires-Dist: responses>=0.23.0; extra == "dev"
|
|
32
|
+
Requires-Dist: vcrpy>=4.2.0; extra == "dev"
|
|
33
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
34
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
35
|
+
Requires-Dist: flake8>=6.0.0; extra == "dev"
|
|
36
|
+
Dynamic: author
|
|
37
|
+
Dynamic: home-page
|
|
38
|
+
Dynamic: license-file
|
|
39
|
+
Dynamic: requires-python
|
|
40
|
+
|
|
41
|
+
# UK Fuel Finder Python Library
|
|
42
|
+
|
|
43
|
+
[](https://opensource.org/licenses/MIT)
|
|
44
|
+
[](https://www.python.org/downloads/)
|
|
45
|
+
|
|
46
|
+
Python library for accessing the UK Government Fuel Finder API.
|
|
47
|
+
|
|
48
|
+
## Features
|
|
49
|
+
|
|
50
|
+
- **OAuth 2.0 Authentication** - Automatic token management with refresh support
|
|
51
|
+
- **Comprehensive Data Access** - Fuel prices and forecourt information
|
|
52
|
+
- **Built-in Caching** - Reduces API calls with configurable TTL
|
|
53
|
+
- **Rate Limiting** - Automatic retry with exponential backoff
|
|
54
|
+
- **Type Hints** - Full type annotations for better IDE support
|
|
55
|
+
- **Extensive Error Handling** - Clear exceptions for all error cases
|
|
56
|
+
- **Batch Pagination** - Automatic handling of 500-record batches
|
|
57
|
+
- **Incremental Updates** - Fetch only changed data since a specific date
|
|
58
|
+
|
|
59
|
+
## Installation
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
pip install ukfuelfinder
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Quick Start
|
|
66
|
+
|
|
67
|
+
```python
|
|
68
|
+
from ukfuelfinder import FuelFinderClient
|
|
69
|
+
|
|
70
|
+
# Initialize client
|
|
71
|
+
client = FuelFinderClient(
|
|
72
|
+
client_id="your_client_id",
|
|
73
|
+
client_secret="your_client_secret",
|
|
74
|
+
environment="production" # or "test"
|
|
75
|
+
)
|
|
76
|
+
|
|
77
|
+
# Get all fuel prices
|
|
78
|
+
prices = client.get_all_pfs_prices()
|
|
79
|
+
|
|
80
|
+
# Search for stations near a location (returns list of (distance, PFSInfo) tuples)
|
|
81
|
+
nearby = client.search_by_location(latitude=51.5074, longitude=-0.1278, radius_km=5.0)
|
|
82
|
+
for distance, station in nearby:
|
|
83
|
+
print(f"{distance:.2f}km - {station.trading_name}")
|
|
84
|
+
|
|
85
|
+
# Get prices for specific fuel type
|
|
86
|
+
unleaded_prices = client.get_prices_by_fuel_type("unleaded")
|
|
87
|
+
|
|
88
|
+
# Get forecourt information
|
|
89
|
+
forecourts = client.get_all_pfs_info()
|
|
90
|
+
|
|
91
|
+
# Get incremental updates since yesterday
|
|
92
|
+
from datetime import datetime, timedelta
|
|
93
|
+
yesterday = (datetime.now() - timedelta(days=1)).strftime("%Y-%m-%d")
|
|
94
|
+
updated_prices = client.get_incremental_price_updates(yesterday)
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Environment Variables
|
|
98
|
+
|
|
99
|
+
Set credentials via environment variables:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
export FUEL_FINDER_CLIENT_ID="your_client_id"
|
|
103
|
+
export FUEL_FINDER_CLIENT_SECRET="your_client_secret"
|
|
104
|
+
export FUEL_FINDER_ENVIRONMENT="production"
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Then initialize without parameters:
|
|
108
|
+
|
|
109
|
+
```python
|
|
110
|
+
client = FuelFinderClient()
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Documentation
|
|
114
|
+
|
|
115
|
+
- [Quick Start Guide](docs/quickstart.md)
|
|
116
|
+
- [API Reference](docs/api_reference.md)
|
|
117
|
+
- [Authentication](docs/authentication.md)
|
|
118
|
+
- [Caching Guide](docs/caching.md)
|
|
119
|
+
- [Rate Limiting](docs/rate_limiting.md)
|
|
120
|
+
- [Error Handling](docs/error_handling.md)
|
|
121
|
+
|
|
122
|
+
## Requirements
|
|
123
|
+
|
|
124
|
+
- Python 3.8+
|
|
125
|
+
- Valid Fuel Finder API credentials from [developer.fuel-finder.service.gov.uk](https://www.developer.fuel-finder.service.gov.uk)
|
|
126
|
+
|
|
127
|
+
## API Coverage
|
|
128
|
+
|
|
129
|
+
This library provides access to all Information Recipient API endpoints:
|
|
130
|
+
|
|
131
|
+
- **Authentication**
|
|
132
|
+
- Generate OAuth access token
|
|
133
|
+
- Refresh access token
|
|
134
|
+
|
|
135
|
+
- **Fuel Prices**
|
|
136
|
+
- Fetch all PFS fuel prices (full or incremental)
|
|
137
|
+
|
|
138
|
+
- **Forecourt Information**
|
|
139
|
+
- Fetch all PFS information (500 per batch)
|
|
140
|
+
- Fetch incremental PFS information updates
|
|
141
|
+
|
|
142
|
+
## Examples
|
|
143
|
+
|
|
144
|
+
See the [examples/](examples/) directory for complete working examples:
|
|
145
|
+
|
|
146
|
+
- `basic_usage.py` - Simple getting started example
|
|
147
|
+
- `error_handling.py` - Comprehensive error handling
|
|
148
|
+
- `fetch_fuel_prices.py` - Fetch all fuel prices and save to JSON
|
|
149
|
+
- `fetch_all_sites.py` - Fetch all forecourt sites and save to JSON
|
|
150
|
+
- `location_search.py` - Search for stations near a location
|
|
151
|
+
|
|
152
|
+
## Development
|
|
153
|
+
|
|
154
|
+
### Setup
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
git clone https://github.com/mretallack/ukfuelfinder.git
|
|
158
|
+
cd ukfuelfinder
|
|
159
|
+
pip install -e .[dev]
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Running Tests
|
|
163
|
+
|
|
164
|
+
```bash
|
|
165
|
+
pytest
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Code Quality
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
black ukfuelfinder tests
|
|
172
|
+
mypy ukfuelfinder
|
|
173
|
+
flake8 ukfuelfinder
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## Future Enhancements
|
|
177
|
+
|
|
178
|
+
Potential features for future development:
|
|
179
|
+
|
|
180
|
+
### Smart Fuel Recommendations
|
|
181
|
+
- **Cost-optimized routing** - Calculate total fuel cost including detour distance based on vehicle consumption
|
|
182
|
+
- **Cheapest fuel finder** - Find the most economical option considering current location, fuel prices, and distance
|
|
183
|
+
- **Route integration** - Suggest fuel stops along planned routes with minimal detour
|
|
184
|
+
|
|
185
|
+
### Price Intelligence
|
|
186
|
+
- **Price alerts** - Notify users when prices drop below a threshold in their area
|
|
187
|
+
- **Price forecasting** - Predict price trends based on historical data
|
|
188
|
+
- **Price comparison** - Compare prices across brands, regions, and fuel types
|
|
189
|
+
|
|
190
|
+
### Advanced Filtering
|
|
191
|
+
- **Multi-criteria search** - Filter by amenities (car wash, shop, 24-hour, EV charging)
|
|
192
|
+
- **Brand preferences** - Filter by preferred fuel brands or loyalty programs
|
|
193
|
+
- **Fuel type availability** - Find stations with specific fuel types (HVO, E10, premium diesel)
|
|
194
|
+
|
|
195
|
+
### Journey Planning
|
|
196
|
+
- **Fuel range calculator** - Estimate remaining range and suggest refuel points
|
|
197
|
+
- **Multi-stop optimization** - Plan optimal fuel stops for long journeys
|
|
198
|
+
- **Emergency fuel finder** - Quick search for nearest station when running low
|
|
199
|
+
|
|
200
|
+
### Data Analytics
|
|
201
|
+
- **Spending tracking** - Monitor fuel expenses over time
|
|
202
|
+
- **Savings calculator** - Calculate savings from using cheapest stations
|
|
203
|
+
- **Regional price analysis** - Compare average prices across different areas
|
|
204
|
+
|
|
205
|
+
### Integration Features
|
|
206
|
+
- **Navigation app integration** - Direct routing to selected stations
|
|
207
|
+
- **Calendar integration** - Schedule reminders for regular refueling
|
|
208
|
+
- **Vehicle integration** - Sync with vehicle telematics for automatic consumption data
|
|
209
|
+
|
|
210
|
+
Contributions implementing these features are welcome! See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
211
|
+
|
|
212
|
+
## Contributing
|
|
213
|
+
|
|
214
|
+
Contributions are welcome! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
|
|
215
|
+
|
|
216
|
+
## License
|
|
217
|
+
|
|
218
|
+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
|
|
219
|
+
|
|
220
|
+
## Acknowledgments
|
|
221
|
+
|
|
222
|
+
- Data provided by the UK Government Fuel Finder service
|
|
223
|
+
- API documentation: [developer.fuel-finder.service.gov.uk](https://www.developer.fuel-finder.service.gov.uk)
|
|
224
|
+
- Content available under [Open Government Licence v3.0](https://www.nationalarchives.gov.uk/doc/open-government-licence/version/3/)
|
|
225
|
+
|
|
226
|
+
## Support
|
|
227
|
+
|
|
228
|
+
- **Issues**: [GitHub Issues](https://github.com/mretallack/ukfuelfinder/issues)
|
|
229
|
+
- **API Support**: [Contact Fuel Finder Team](https://www.developer.fuel-finder.service.gov.uk/contact-us)
|
|
230
|
+
|
|
231
|
+
## Changelog
|
|
232
|
+
|
|
233
|
+
See [CHANGELOG.md](CHANGELOG.md) for version history.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
ukfuelfinder/__init__.py,sha256=4mBkb1BS8xueCspJnmWZxZm01Wa3bLLSz2uTS41fr2U,934
|
|
2
|
+
ukfuelfinder/auth.py,sha256=6AmtMYx-pVCn8mPYLK6Yoe5VvqEXXh8glLNbwuol51M,3898
|
|
3
|
+
ukfuelfinder/cache.py,sha256=1ykMcoeN7IpF06rzckO2vwpJ--KhUQBj5H4ZB9vrSV4,2137
|
|
4
|
+
ukfuelfinder/client.py,sha256=nM_w6SRCnFBU5tkzrJsifhpuqLoLts7axcpi04KNStc,8371
|
|
5
|
+
ukfuelfinder/config.py,sha256=yMGhA_QdrLr7jHJUlSaC4YrQCvh54Ar8egwsQXWn7FQ,1957
|
|
6
|
+
ukfuelfinder/exceptions.py,sha256=WQiGGmTmKmAiDETmB4lpz2Z_DpaibsBOeu9pc8sbYwA,1498
|
|
7
|
+
ukfuelfinder/http_client.py,sha256=SHolFT_jK9chW6V5_6OzxxvP3rmhQKnH_u89_qcL2jg,3985
|
|
8
|
+
ukfuelfinder/models.py,sha256=YWmoLjL3KtLJPLI0JirZe6y_3L5eKPCVrjknHfqSIPo,4999
|
|
9
|
+
ukfuelfinder/rate_limiter.py,sha256=NYzmBg-nROBfGlmn8VjTKnQVstvEmTql8QlLKS3CCFE,2444
|
|
10
|
+
ukfuelfinder/services/__init__.py,sha256=ujoAV7UmaaNJ_QkjbDZLUxsZzf8h57vr__p_HipVECc,39
|
|
11
|
+
ukfuelfinder/services/forecourt_service.py,sha256=7BuCtq9qn09Ag8-vO10S506RWjCQ-rQYQBOxfmVHrl0,3440
|
|
12
|
+
ukfuelfinder/services/price_service.py,sha256=bu8XVEBONC6nRAjBQy9Ap96O79QekJDz947LIs51xik,2523
|
|
13
|
+
ukfuelfinder-1.0.0.dist-info/licenses/LICENSE,sha256=aQgSJtjyyzMWO0tnA-Knf0cTfXueFg3slv94MUzPG5M,1071
|
|
14
|
+
ukfuelfinder-1.0.0.dist-info/METADATA,sha256=lBMaKm3zV49WQTo_TkwHuusSrSOdoYNB0wzvS2Ipwj8,7899
|
|
15
|
+
ukfuelfinder-1.0.0.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
|
|
16
|
+
ukfuelfinder-1.0.0.dist-info/top_level.txt,sha256=ht_7huZLUphB5LbYIUu-Fax1YSmalproqtvOwnHkdXs,13
|
|
17
|
+
ukfuelfinder-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mark Retallack
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ukfuelfinder
|