{"id":24678303,"url":"https://github.com/firstclasspostcodes/firstclasspostcodes-python","last_synced_at":"2025-03-21T18:23:30.542Z","repository":{"id":54849777,"uuid":"235073610","full_name":"firstclasspostcodes/firstclasspostcodes-python","owner":"firstclasspostcodes","description":"🐍 Python library for the Firstclasspostcodes API","archived":false,"fork":false,"pushed_at":"2021-01-25T15:05:02.000Z","size":58,"stargazers_count":0,"open_issues_count":7,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-26T13:16:34.137Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","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/firstclasspostcodes.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":"2020-01-20T10:17:47.000Z","updated_at":"2020-09-23T10:37:58.000Z","dependencies_parsed_at":"2022-08-14T04:40:48.922Z","dependency_job_id":null,"html_url":"https://github.com/firstclasspostcodes/firstclasspostcodes-python","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firstclasspostcodes%2Ffirstclasspostcodes-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firstclasspostcodes%2Ffirstclasspostcodes-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firstclasspostcodes%2Ffirstclasspostcodes-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/firstclasspostcodes%2Ffirstclasspostcodes-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/firstclasspostcodes","download_url":"https://codeload.github.com/firstclasspostcodes/firstclasspostcodes-python/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244845397,"owners_count":20519954,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2025-01-26T13:16:35.739Z","updated_at":"2025-03-21T18:23:30.509Z","avatar_url":"https://github.com/firstclasspostcodes.png","language":"Python","readme":"![Cover](/.github/images/cover.png)\n\n# Firstclasspostcodes\nThe Firstclasspostcodes Python library provides convenient access to the Firstclasspostcodes API from applications written in the Python language. It includes pre-defined methods and helpers to help you easily integrate the library into any application.\n\nThe library also provides other features. For example:\n\n* Easy configuration path for fast setup and use.\n* Helpers for listing and formatting addresses.\n* Built-in methods for easily interacting with the Firstclasspostcodes API.\n\n## Documentation\nSee [Python API docs](https://docs.firstclasspostcodes.com/python/getting-started) for detailed usage and examples.\n\n## Installation\nYou don't need this source code unless you want to modify the package. If you just want to use the package, just run:\n\n```\npip install --upgrade stripe\n```\n\nInstall from source with:\n\n```\npython setup.py install\n```\n\n## Requirements\n\n* Python 3.5+ (PyPy supported)\n* An API key from [https://firstclasspostcodes.com](https://firstclasspostcodes.com)\n\n## Usage\nThe library needs to be configured with your API key, which is available on the [dashboard](https://dashboard.firstclasspostcodes.com).\n\n```python\nfrom firstclasspostcodes import Client\n\nclient = Client(api_key='3454tyrgdfsew23')\n\n# retrieve a postcode\nresponse = client.get_postcode('AB30 1FR')\n\nprint(response['postcode'])\n```\n\n## Configuration\nThe library can be configured with several options depending on the requirements of your setup:\n\n```python\nfrom firstclasspostcodes import Client\n\nclient = Client(\n    # The API Key to be used when sending requests to the \n    # Firstclasspostcodes API\n    api_key='3454tyrgdfsew23',\n\n    # The host to send API requests to. This is typically changed\n    # to use the mock service for testing purposes\n    host=\"api.firstclasspostcodes.com\",\n\n    # The default content type is json, but can be changed to \"geo+json\"\n    # to return responses as GeoJSON content type\n    content = \"json\",\n\n    # Typically, always HTTPS, but useful to change for testing\n    # purposes\n    protocol = \"https\",\n\n    # The base path is \"/data\", but useful to change for testing\n    # purposes\n    base_path = \"/data\",\n\n    # The default request timeout for the library.\n    timeout=30,\n)\n```\n\n## Events\nYou can subscribe to events using an initialized client, passing a lambda as a handeler:\n\n```python\nfrom firstclasspostcodes import Client\n\nclient = Client(api_key='wqrtythfgdvcs')\n\nclient.on('request', lambda **args : print(args))\n```\n\n| Event name | Description |\n|:-----|:-----|\n| `request` | Triggered before a request is sent. The request object to be sent is passed to the event handler. |\n| `response` | Triggered with the parsed JSON response body upon a successful reques. |\n| `error` | Triggered with a client error when the request fails. |\n| `operation:{name}` | Triggered by an operation with the parameter object. |\n\n**Note:** `{name}` is replaced with the operation name of the method, as defined inside the OpenAPI specification.\n\n## Integration / Testing\nWe provide a mock service of our API as a docker container [available here](https://github.com/firstclasspostcodes/firstclasspostcodes-mock). Once the container is running, the library can be easily configured to use it:\n\n```python\nfrom firstclasspostcodes import Client\nfrom urllib.parse import urlparse\n\nMOCK_API_KEY = \"111111111111\"\n\nuri = urlparse(\"http://localhost:3000\")\n\nclient = Client(\n    api_key=MOCK_API_KEY,\n    protocol=uri.scheme,\n    host=uri.netloc,\n    base_path=uri.path,\n)\n\nclient.get_postcode('AB30 1FR')\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirstclasspostcodes%2Ffirstclasspostcodes-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffirstclasspostcodes%2Ffirstclasspostcodes-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffirstclasspostcodes%2Ffirstclasspostcodes-python/lists"}