Skip to content

Fix: Update to use new API for BANES#5600

Open
trvrnrth wants to merge 7 commits intomampfes:masterfrom
trvrnrth:bathnes-gov-uk-new-api
Open

Fix: Update to use new API for BANES#5600
trvrnrth wants to merge 7 commits intomampfes:masterfrom
trvrnrth:bathnes-gov-uk-new-api

Conversation

@trvrnrth
Copy link
Contributor

Updates the Bath & North East Somerset source to use a new API as the old one is no longer available.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Bath & North East Somerset (bathnes.gov.uk) waste collection source to use the council’s newer API endpoints after the previous API became unavailable.

Changes:

  • Switched collection lookups to the new api.bathnes.gov.uk BinsAPI v2 “CollectionSummary” endpoint.
  • Updated address search to use the new api.bathnes.gov.uk AddressesAPI v2 endpoint and adjusted UPRN resolution logic.
  • Updated waste type mapping/test case data to align with the new API’s featureType values.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Bath & North East Somerset (bathnes.gov.uk) waste-collection source to use the council’s newer api.bathnes.gov.uk endpoints now that the legacy API is unavailable.

Changes:

  • Switched bin schedule retrieval to the new CollectionSummary/{uprn} API endpoint.
  • Added address search via the new Addresses API and updated UPRN resolution logic accordingly.
  • Introduced basic argument sanitization/validation and updated waste-type mapping to match the new API’s featureType values.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

trvrnrth and others added 2 commits March 14, 2026 22:41
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the Bath & North East Somerset Council source implementation to use the newer api.bathnes.gov.uk endpoints now that the previous bins API is no longer available.

Changes:

  • Switched collection lookups to BinsAPI/v2/BartecFeaturesandSchedules/CollectionSummary/{uprn}.
  • Added address search via AddressesAPI/v2/search/{postcode}/150/true and argument sanitization/validation.
  • Updated waste type mappings and refreshed example test cases.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

r = requests.get(url, timeout=REQUEST_TIMEOUT)
r.raise_for_status()
if r.text.strip() == "":
raise Exception(f"Empty response from API for url: {url}")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other sources raise Exception more commonly than RuntimeError and including the url was actually a previous co-pilot suggestion which I agree with for parity with raise_for_status. Given the context of the log the data here is not sensitive.

Comment on lines 102 to 106
raise SourceArgumentNotFoundWithSuggestions(
"housenameornumber",
self._housenameornumber,
[a["payment_Address"] for a in addresses],
[a["payment_Address"].split("|")[1] for a in addresses],
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is acceptable as-is. We cannot realistically account for fundamental changes to the API.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants