Skip to main content

A Python wrapper for the Brønnøysund Register Centre (Brreg) API.

Project description

🔥 Brreg Wrapper

PyPI version License: MIT Python Version

Tired of wrestling with raw API calls to the Brønnøysund Register Centre (Brreg)? brreg-wrapper is here to simplify your life! This sleek, asynchronous Python library provides an intuitive interface to access crucial Norwegian business information with ease.

Get details on main entities (enheter) and sub-entities (underenheter), perform searches, and integrate Norwegian business data into your applications effortlessly.

✨ Core Features

  • Asynchronous: Built with asyncio and httpx for modern, non-blocking I/O.
  • Type Hinted: Fully type-hinted for better developer experience and static analysis.
  • Pydantic Models: Uses Pydantic models for robust data validation and easy object access (where applicable).
  • Context Management: Supports async with for automatic HTTP client cleanup.
  • Comprehensive API Coverage: Wraps numerous endpoints from the official Brreg API.
  • Minimal Dependencies: Relies primarily on httpx and pydantic.

🚀 Installation

Get started in seconds:

pip install brreg-wrapper
# Or using uv:
uv add brreg-wrapper

💡 Usage Example

Here's a taste of how easy it is to fetch data:

import asyncio
import json
from brreg_wrapper import BrregClient

async def main():
    # The client automatically handles HTTP sessions
    async with BrregClient() as client:
        org_nr = "923609016" # Example: Equinor ASA

        print(f"🔍 Fetching details for organization number: {org_nr}")
        try:
            # get_enhet returns a Pydantic model (Enhet or SlettetEnhet)
            entity_model = await client.get_enhet(org_nr)
            print("\n--- Entity Details (as Pydantic Model) ---")
            print(entity_model) # You can work with the model object directly

            # To serialize to JSON, convert the model to a JSON-compatible dictionary first
            # using mode='json'. This handles types like dates correctly.
            print("\n--- Entity Details (as JSON) ---")
            entity_dict = entity_model.model_dump(mode='json', by_alias=True, exclude_none=True)
            print(json.dumps(entity_dict, indent=2, ensure_ascii=False))

            # Similarly for sub-entities (get_underenhet returns Underenhet or SlettetUnderenhet)
            # sub_entity_model = await client.get_underenhet("some_sub_org_nr")
            # sub_entity_dict = sub_entity_model.model_dump(mode='json', by_alias=True, exclude_none=True)
            # print(json.dumps(sub_entity_dict, indent=2, ensure_ascii=False))

        except Exception as e:
            print(f"\n💥 Oops! An error occurred: {e}")

    # Note: Methods like get_enhet and get_underenhet return Pydantic models.
    # Use the .model_dump(mode='json', ...) method on the returned object to get a
    # dictionary with JSON-compatible types (like dates converted to strings)
    # if you need to serialize the data.

        print("\n✅ Done!")

if __name__ == "__main__":
    asyncio.run(main())

🤝 Contributing

Contributions are welcome! If you have ideas for improvements or find a bug, please open an issue or submit a pull request on the GitHub repository.

📜 License

This project is licensed under the MIT License - see the LICENSE file for details.

⚠️ Issues?

Having trouble? Found a bug? Feel free to open an issue on the GitHub repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

brreg_wrapper-0.1.8.tar.gz (21.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

brreg_wrapper-0.1.8-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file brreg_wrapper-0.1.8.tar.gz.

File metadata

  • Download URL: brreg_wrapper-0.1.8.tar.gz
  • Upload date:
  • Size: 21.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for brreg_wrapper-0.1.8.tar.gz
Algorithm Hash digest
SHA256 c70320d8ce1b6a2afbeb2f0ffee605dd42bffcb2c5c84ebd0eb4b610fde15b44
MD5 6f10900dc01ace1793eae11a84d8c412
BLAKE2b-256 32004b84c1dfd032872faaa173e08faa2ae598f4179d758180e5793d95fe5d27

See more details on using hashes here.

Provenance

The following attestation bundles were made for brreg_wrapper-0.1.8.tar.gz:

Publisher: publish-to-pypi.yml on sondreal/brreg-wrapper

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file brreg_wrapper-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: brreg_wrapper-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 16.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for brreg_wrapper-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 a85faf6e6e47ee2f0d9c83a4fde0b4ac902bff822751e3833d2f4a77e8e0873a
MD5 8b7cf2fa71b0d3ba4abc65dc1f2f64fb
BLAKE2b-256 85872e0ab796ee9b9371af7028d391ba6edd995eab16733332e3cd596f31d5ed

See more details on using hashes here.

Provenance

The following attestation bundles were made for brreg_wrapper-0.1.8-py3-none-any.whl:

Publisher: publish-to-pypi.yml on sondreal/brreg-wrapper

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page