Skip to content
This repository was archived by the owner on Mar 22, 2022. It is now read-only.

Commit 663090c

Browse files
committed
Initial commit
0 parents  commit 663090c

23 files changed

+1064
-0
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# EditorConfig helps developers define and maintain consistent
2+
# coding styles between different editors and IDEs
3+
# editorconfig.org
4+
5+
[*]
6+
end_of_line = lf
7+
charset = utf-8
8+
trim_trailing_whitespace = true
9+
insert_final_newline = true

.gitignore

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Byte-compiled / optimized / DLL files
2+
.pytest_cache/
3+
__pycache__/
4+
*$py.class
5+
6+
# Distribution / packaging
7+
*.egg-info/
8+
build/
9+
dist/
10+
11+
# OS generated files
12+
.idea
13+
14+
# Unit test / coverage reports
15+
htmlcov/
16+
.coverage

.travis.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
language: python
2+
python:
3+
- "3.4"
4+
- "3.5"
5+
- "3.6"
6+
install:
7+
- 'pip install pipenv'
8+
- 'pipenv sync'
9+
- 'pip install mock pytest pytest-mock pytest-cov coveralls'
10+
script:
11+
- 'pipenv run pytest'
12+
after_success:
13+
- 'coveralls'

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) [2018] [Ruud Schroën]
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.

Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
init:
2+
pip install pipenv
3+
pipenv install --dev
4+
5+
test:
6+
pipenv run pytest

Pipfile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[[source]]
2+
url = "https://pypi.org/simple"
3+
verify_ssl = true
4+
name = "pypi"
5+
6+
[packages]
7+
requests = "*"
8+
9+
[dev-packages]
10+
mock = "*"
11+
pytest = "*"
12+
pytest-mock = "*"
13+
pytest-cov = "*"

Pipfile.lock

Lines changed: 179 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# postcodeapi
2+
3+
`postcodeapi` is a tiny Python wrapper around the Postcode API V2.
4+
5+
## Installation and usage
6+
7+
### Installation
8+
9+
*postcodeapi* can be installed by running `pip install postcodeapi`.
10+
11+
### Usage
12+
13+
Here is an example of how to use the API client. First you initialize a client with your API key, after that you use
14+
one of the four getter methods to fetch the data you need. They all return the actual JSON response converted to a
15+
Python dictionary.
16+
17+
```python
18+
# Import the PostcodeAPIClient
19+
from postcodeapi.client import PostcodeAPIClient
20+
21+
# Initialize a client with your API key
22+
client = PostcodeAPIClient(api_key="YOUR_API_KEY")
23+
24+
# Fetch a list of addresses (for a given postal_code and number)
25+
# The postal_code and number parameters are optional
26+
# The number parameter only works together with postal_code
27+
data = client.get_all_addresses(postal_code="5038EA", number=19)
28+
addresses = data["_embedded"]["addresses"] # List of addresses
29+
30+
# Fetch a single address
31+
address = client.get_address(address_id="0855200000046355")
32+
33+
# Fetch a list of postal codes (within a specific area)
34+
# The area parameter is optional
35+
data = client.get_all_postal_codes(area="5038")
36+
postal_codes = data['_embedded']['postcodes'] # List of postal codes
37+
38+
# Fetch a single postal code
39+
postal_code = client.get_postal_code("5038EA")
40+
```
41+
42+
## Documentation
43+
For more information about the data that is returned, please refer to the [official API documentation](https://www.postcodeapi.nu/docs/). It is written in Dutch.
44+
45+
## Running tests
46+
To run the tests, make sure you have the dev dependencies installed, and run `pytest` in the root of the project.
47+
48+
## Issues
49+
If you have any issues with the API wrapper, please post them [here](https://github.com/infoklik/postcodeapi/issues). If you have issues with the actual API,
50+
please post them in the [official issue tracker](https://github.com/postcodeapi/postcodeapi/issues) of Postcode API.

postcodeapi/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)