geocodio-library-python 0.1.0__tar.gz

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.
Files changed (34) hide show
  1. geocodio_library_python-0.1.0/.github/workflows/ci.yml +49 -0
  2. geocodio_library_python-0.1.0/.github/workflows/publish.yml +79 -0
  3. geocodio_library_python-0.1.0/.github/workflows/test-act-event-ci.json +9 -0
  4. geocodio_library_python-0.1.0/.github/workflows/test-act-event-publish.json +9 -0
  5. geocodio_library_python-0.1.0/.gitignore +80 -0
  6. geocodio_library_python-0.1.0/CHANGELOG.md +36 -0
  7. geocodio_library_python-0.1.0/LICENSE +21 -0
  8. geocodio_library_python-0.1.0/PKG-INFO +230 -0
  9. geocodio_library_python-0.1.0/README.md +195 -0
  10. geocodio_library_python-0.1.0/pyproject.toml +56 -0
  11. geocodio_library_python-0.1.0/requirements-dev.txt +9 -0
  12. geocodio_library_python-0.1.0/setup.cfg +17 -0
  13. geocodio_library_python-0.1.0/smoke.py +40 -0
  14. geocodio_library_python-0.1.0/smoke_lists.py +104 -0
  15. geocodio_library_python-0.1.0/src/geocodio/__init__.py +9 -0
  16. geocodio_library_python-0.1.0/src/geocodio/_version.py +3 -0
  17. geocodio_library_python-0.1.0/src/geocodio/client.py +583 -0
  18. geocodio_library_python-0.1.0/src/geocodio/exceptions.py +72 -0
  19. geocodio_library_python-0.1.0/src/geocodio/models.py +400 -0
  20. geocodio_library_python-0.1.0/test_pypi_release.py +65 -0
  21. geocodio_library_python-0.1.0/tests/__init__.py +3 -0
  22. geocodio_library_python-0.1.0/tests/conftest.py +32 -0
  23. geocodio_library_python-0.1.0/tests/e2e/test_api.py +680 -0
  24. geocodio_library_python-0.1.0/tests/e2e/test_batch_reverse.py +109 -0
  25. geocodio_library_python-0.1.0/tests/e2e/test_lists_api.py +208 -0
  26. geocodio_library_python-0.1.0/tests/test_workflows.py +138 -0
  27. geocodio_library_python-0.1.0/tests/unit/test_client.py +332 -0
  28. geocodio_library_python-0.1.0/tests/unit/test_errors.py +28 -0
  29. geocodio_library_python-0.1.0/tests/unit/test_exceptions.py +54 -0
  30. geocodio_library_python-0.1.0/tests/unit/test_geocode.py +501 -0
  31. geocodio_library_python-0.1.0/tests/unit/test_geocoding.py +133 -0
  32. geocodio_library_python-0.1.0/tests/unit/test_models.py +364 -0
  33. geocodio_library_python-0.1.0/tests/unit/test_reverse.py +257 -0
  34. geocodio_library_python-0.1.0/uv.lock +481 -0
@@ -0,0 +1,49 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ branches: [main]
8
+ workflow_dispatch:
9
+
10
+ jobs:
11
+ test-and-lint:
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ - uses: actions/checkout@v4
16
+
17
+ - name: Install uv
18
+ uses: astral-sh/setup-uv@v5
19
+
20
+ - name: "Set up Python"
21
+ uses: actions/setup-python@v5
22
+ with:
23
+ python-version: "3.11"
24
+ # python-version-file: "pyproject.toml"
25
+
26
+ - name: Install dependencies
27
+ run: |
28
+ uv sync
29
+ uv pip install .
30
+ uv pip install .[dev]
31
+
32
+ - name: Run unit tests
33
+ run: |
34
+ uv run pytest tests/unit/
35
+
36
+ - name: Run e2e tests
37
+ env:
38
+ GEOCODIO_API_KEY: ${{ secrets.GEOCODIO_API_KEY }}
39
+ run: |
40
+ if [ -n "$GEOCODIO_API_KEY" ]; then
41
+ echo "Running e2e tests with API key"
42
+ uv run pytest tests/e2e/ -v
43
+ else
44
+ echo "No API key provided, skipping e2e tests"
45
+ fi
46
+
47
+ - name: Lint with flake8
48
+ run: |
49
+ uv run flake8 src/ --ignore=E501
@@ -0,0 +1,79 @@
1
+ name: Publish to PyPI
2
+
3
+ on:
4
+ release:
5
+ types: [published]
6
+ push:
7
+ branches:
8
+ - main
9
+ - hotfix/*
10
+ - release/*
11
+ workflow_dispatch:
12
+ inputs:
13
+ version:
14
+ description: 'Version to publish (e.g., 1.0.0)'
15
+ required: true
16
+ default: '1.0.0'
17
+ publish_to:
18
+ description: 'Where to publish'
19
+ required: true
20
+ default: 'testpypi'
21
+ type: choice
22
+ options:
23
+ - testpypi
24
+ - pypi
25
+
26
+ jobs:
27
+ publish:
28
+ runs-on: ubuntu-latest
29
+
30
+ steps:
31
+ - uses: actions/checkout@v4
32
+
33
+ - name: Install uv
34
+ uses: astral-sh/setup-uv@v5
35
+
36
+ - name: Set up Python
37
+ uses: actions/setup-python@v5
38
+ with:
39
+ python-version: "3.11"
40
+
41
+ - name: Install dependencies
42
+ run: |
43
+ uv sync
44
+ uv pip install build twine
45
+
46
+ - name: Update version
47
+ if: github.event.inputs.version
48
+ run: |
49
+ # Update version in pyproject.toml
50
+ sed -i 's/^version = ".*"/version = "${{ github.event.inputs.version }}"/' pyproject.toml
51
+
52
+ - name: Build package
53
+ run: |
54
+ uv run python -m build
55
+
56
+ - name: Publish to PyPI (on release)
57
+ if: github.event_name == 'release'
58
+ env:
59
+ TWINE_USERNAME: __token__
60
+ TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
61
+ run: |
62
+ uv run twine upload --verbose dist/*
63
+
64
+ - name: Publish to TestPyPI (manual)
65
+ if: github.event.inputs.publish_to == 'testpypi'
66
+ env:
67
+ TWINE_USERNAME: __token__
68
+ TWINE_PASSWORD: ${{ secrets.TEST_PYPI_API_TOKEN }}
69
+ TWINE_REPOSITORY_URL: https://test.pypi.org/legacy/
70
+ run: |
71
+ uv run twine upload --verbose dist/*
72
+
73
+ - name: Publish to PyPI (manual)
74
+ if: github.event.inputs.publish_to == 'pypi'
75
+ env:
76
+ TWINE_USERNAME: __token__
77
+ TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
78
+ run: |
79
+ uv run twine upload --verbose dist/*
@@ -0,0 +1,9 @@
1
+ {
2
+ "event": "workflow_dispatch",
3
+ "workflow": "publish.yml",
4
+ "ref": "refs/heads/feature/ci-pipeline-tasks",
5
+ "inputs": {
6
+ "version": "0.0.1",
7
+ "publish_to": "testpypi"
8
+ }
9
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "event": "workflow_dispatch",
3
+ "workflow": "publish.yml",
4
+ "ref": "refs/heads/feature/ci-pipeline-tasks",
5
+ "inputs": {
6
+ "version": "0.0.1",
7
+ "publish_to": "testpypi"
8
+ }
9
+ }
@@ -0,0 +1,80 @@
1
+ # macOS system files
2
+ .DS_Store
3
+
4
+ # Python
5
+ __pycache__/
6
+ *.py[cod]
7
+ *$py.class
8
+ *.so
9
+ .Python
10
+ build/
11
+ develop-eggs/
12
+ dist/
13
+ downloads/
14
+ eggs/
15
+ .eggs/
16
+ lib/
17
+ lib64/
18
+ parts/
19
+ sdist/
20
+ var/
21
+ wheels/
22
+ *.egg-info/
23
+ .installed.cfg
24
+ *.egg
25
+
26
+ # Virtual Environment
27
+ venv/
28
+ env/
29
+ ENV/
30
+
31
+ # IDE
32
+ .idea/
33
+ .vscode/
34
+ .cursor/
35
+ *.swp
36
+ *.swo
37
+
38
+ # Unit test / coverage reports
39
+ htmlcov/
40
+ .tox/
41
+ .coverage
42
+ .coverage.*
43
+ .cache
44
+ nosetests.xml
45
+ coverage.xml
46
+ *.cover
47
+ .hypothesis/
48
+
49
+ # Byte-compiled / optimized / DLL files
50
+ __pycache__/
51
+ *.py[cod]
52
+ *$py.class
53
+
54
+ # Distribution / packaging
55
+ dist/
56
+ build/
57
+ *.egg-info/
58
+
59
+ # Virtual environments
60
+ .venv/
61
+ venv/
62
+ ENV/
63
+
64
+ # IDE specific files
65
+ .idea/
66
+ .vscode/
67
+ .cursor/
68
+ *.swp
69
+ *.swo
70
+
71
+ # Testing
72
+ .coverage
73
+ htmlcov/
74
+ .pytest_cache/
75
+
76
+ # Environment variables
77
+ .env
78
+
79
+ # Documentation
80
+ docs/_build/
@@ -0,0 +1,36 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.1.0] - 2025-08-08
11
+
12
+ ### Added
13
+ - Initial release of the official Python client for the Geocodio API
14
+ - Forward geocoding for single addresses and batch operations (up to 10,000 addresses)
15
+ - Reverse geocoding for single coordinates and batch operations
16
+ - List API support for managing large batch jobs
17
+ - Field appending capabilities (census data, timezone, congressional districts, etc.)
18
+ - Comprehensive error handling with structured exception hierarchy
19
+ - Full test coverage with unit and end-to-end tests
20
+ - Support for Geocodio Enterprise API via hostname parameter
21
+ - Modern async-capable HTTP client using httpx
22
+ - Type hints and dataclass models for better IDE support
23
+ - GitHub Actions CI/CD pipeline for automated testing and publishing
24
+
25
+ ## Release Process
26
+
27
+ When ready to release:
28
+ 1. Update the version in `pyproject.toml`
29
+ 2. Move all "Unreleased" items to a new version section with date
30
+ 3. Commit with message: `chore: prepare release vX.Y.Z`
31
+ 4. Tag the release: `git tag vX.Y.Z`
32
+ 5. Push tags: `git push --tags`
33
+ 6. GitHub Actions will automatically publish to PyPI
34
+
35
+ [Unreleased]: https://github.com/Geocodio/geocodio-library-python/compare/v0.1.0...HEAD
36
+ [0.1.0]: https://github.com/Geocodio/geocodio-library-python/releases/tag/v0.1.0
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) Dotsquare LLC <hello@geocod.io>
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
13
+ all 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
21
+ THE SOFTWARE.
@@ -0,0 +1,230 @@
1
+ Metadata-Version: 2.4
2
+ Name: geocodio-library-python
3
+ Version: 0.1.0
4
+ Summary: A Python client for the Geocodio API
5
+ Project-URL: Homepage, https://www.geocod.io
6
+ Project-URL: Documentation, https://www.geocod.io/docs/?python
7
+ Project-URL: Repository, https://github.com/geocodio/geocodio-library-python
8
+ Project-URL: Issues, https://github.com/geocodio/geocodio-library-python/issues
9
+ License-Expression: MIT
10
+ License-File: LICENSE
11
+ Classifier: Development Status :: 5 - Production/Stable
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
20
+ Classifier: Topic :: Scientific/Engineering :: GIS
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Requires-Python: >=3.11
23
+ Requires-Dist: httpx>=0.24.0
24
+ Provides-Extra: dev
25
+ Requires-Dist: black>=23.0.0; extra == 'dev'
26
+ Requires-Dist: flake8>=6.0.0; extra == 'dev'
27
+ Requires-Dist: isort>=5.12.0; extra == 'dev'
28
+ Requires-Dist: mypy>=1.0.0; extra == 'dev'
29
+ Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
30
+ Requires-Dist: pytest-httpx>=0.27.0; extra == 'dev'
31
+ Requires-Dist: pytest-mock>=3.10.0; extra == 'dev'
32
+ Requires-Dist: pytest>=7.0.0; extra == 'dev'
33
+ Requires-Dist: python-dotenv>=1.0.0; extra == 'dev'
34
+ Description-Content-Type: text/markdown
35
+
36
+ # geocodio
37
+
38
+ The official Python client for the Geocodio API.
39
+
40
+ Features
41
+ --------
42
+
43
+ - Forward geocoding of single addresses or in batches (up to 10,000 lookups).
44
+ - Reverse geocoding of coordinates (single or batch).
45
+ - Append additional data fields (e.g. congressional districts, timezone, census data).
46
+ - Automatic parsing of address components.
47
+ - Simple exception handling for authentication, data, and server errors.
48
+
49
+ Installation
50
+ ------------
51
+
52
+ Install via pip:
53
+
54
+ pip install geocodio-library-python
55
+
56
+ Development Installation
57
+ -----------------------
58
+
59
+ 1. Clone the repository:
60
+ ```bash
61
+ git clone https://github.com/geocodio/geocodio-library-python.git
62
+ cd geocodio-library-python
63
+ ```
64
+
65
+ 2. Create and activate a virtual environment:
66
+ ```bash
67
+ python -m venv venv
68
+ source venv/bin/activate # On Windows: venv\Scripts\activate
69
+ ```
70
+
71
+ 3. Install development dependencies:
72
+ ```bash
73
+ pip install -e .
74
+ pip install -r requirements-dev.txt
75
+ ```
76
+
77
+ Usage
78
+ -----
79
+
80
+ ### Geocoding
81
+
82
+ ```python
83
+ from geocodio import GeocodioClient
84
+
85
+ # Initialize the client with your API key
86
+ client = GeocodioClient("YOUR_API_KEY")
87
+
88
+ # Single forward geocode
89
+ response = client.geocode("1600 Pennsylvania Ave, Washington, DC")
90
+ print(response.results[0].formatted_address)
91
+
92
+ # Batch forward geocode
93
+ addresses = [
94
+ "1600 Pennsylvania Ave, Washington, DC",
95
+ "1 Infinite Loop, Cupertino, CA"
96
+ ]
97
+ batch_response = client.geocode(addresses)
98
+ for result in batch_response.results:
99
+ print(result.formatted_address)
100
+
101
+ # Single reverse geocode
102
+ rev = client.reverse("38.9002898,-76.9990361")
103
+ print(rev.results[0].formatted_address)
104
+
105
+ # Append additional fields
106
+ data = client.geocode(
107
+ "1600 Pennsylvania Ave, Washington, DC",
108
+ fields=["cd", "timezone"]
109
+ )
110
+ print(data.results[0].fields.timezone.name if data.results[0].fields.timezone else "No timezone data")
111
+ ```
112
+
113
+ ### List API
114
+
115
+ The List API allows you to manage lists of addresses or coordinates for batch processing.
116
+
117
+ ```python
118
+ from geocodio import GeocodioClient
119
+
120
+ # Initialize the client with your API key
121
+ client = GeocodioClient("YOUR_API_KEY")
122
+
123
+ # Get all lists
124
+ lists = client.get_lists()
125
+ print(f"Found {len(lists.data)} lists")
126
+
127
+ # Create a new list from a file
128
+ with open("addresses.csv", "rb") as f:
129
+ new_list = client.create_list(
130
+ file=f,
131
+ filename="addresses.csv",
132
+ direction="forward"
133
+ )
134
+ print(f"Created list: {new_list.id}")
135
+
136
+ # Get a specific list
137
+ list_details = client.get_list(new_list.id)
138
+ print(f"List status: {list_details.status}")
139
+
140
+ # Download a completed list
141
+ if list_details.status and list_details.status.get("state") == "COMPLETED":
142
+ file_content = client.download(new_list.id, "downloaded_results.csv")
143
+ print("List downloaded successfully")
144
+
145
+ # Delete a list
146
+ client.delete_list(new_list.id)
147
+ ```
148
+
149
+ Error Handling
150
+ --------------
151
+
152
+ ```python
153
+ from geocodio import GeocodioClient
154
+ from geocodio.exceptions import AuthenticationError, InvalidRequestError
155
+
156
+ try:
157
+ client = GeocodioClient("INVALID_API_KEY")
158
+ response = client.geocode("1600 Pennsylvania Ave, Washington, DC")
159
+ except AuthenticationError as e:
160
+ print(f"Authentication failed: {e}")
161
+
162
+ try:
163
+ client = GeocodioClient("YOUR_API_KEY")
164
+ response = client.geocode("") # Empty address
165
+ except InvalidRequestError as e:
166
+ print(f"Invalid request: {e}")
167
+ ```
168
+
169
+ Geocodio Enterprise
170
+ -------------------
171
+
172
+ To use this library with Geocodio Enterprise, pass `api.enterprise.geocod.io` as the `hostname` parameter when initializing the client:
173
+
174
+ ```python
175
+ from geocodio import GeocodioClient
176
+
177
+ # Initialize client for Geocodio Enterprise
178
+ client = GeocodioClient(
179
+ "YOUR_API_KEY",
180
+ hostname="api.enterprise.geocod.io"
181
+ )
182
+
183
+ # All methods work the same as with the standard API
184
+ response = client.geocode("1600 Pennsylvania Ave, Washington, DC")
185
+ print(response.results[0].formatted_address)
186
+ ```
187
+
188
+ Documentation
189
+ -------------
190
+
191
+ Full documentation is available at <https://www.geocod.io/docs/?python>.
192
+
193
+ Contributing
194
+ ------------
195
+
196
+ Contributions are welcome! Please open issues and pull requests on GitHub.
197
+
198
+ Issues: <https://github.com/geocodio/geocodio-library-python/issues>
199
+
200
+ License
201
+ -------
202
+
203
+ This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
204
+
205
+ CI & Publishing
206
+ ---------------
207
+
208
+ - CI runs unit tests and linting on every push. E2E tests run if `GEOCODIO_API_KEY` is set as a secret.
209
+ - PyPI publishing workflow supports both TestPyPI and PyPI. See `.github/workflows/publish.yml`.
210
+ - Use `test_pypi_release.py` for local packaging and dry-run upload.
211
+
212
+ ### Testing GitHub Actions Workflows
213
+
214
+ The project includes tests for GitHub Actions workflows using `act` for local development:
215
+
216
+ ```bash
217
+ # Test all workflows (requires act and Docker)
218
+ pytest tests/test_workflows.py
219
+
220
+ # Test specific workflow
221
+ pytest tests/test_workflows.py::test_ci_workflow
222
+ pytest tests/test_workflows.py::test_publish_workflow
223
+ ```
224
+
225
+ **Prerequisites:**
226
+ - Install [act](https://github.com/nektos/act) for local GitHub Actions testing
227
+ - Docker must be running
228
+ - For publish workflow tests: Set `TEST_PYPI_API_TOKEN` environment variable
229
+
230
+ **Note:** Workflow tests are automatically skipped in CI environments.