Skip to content

Commit b283dfa

Browse files
committed
fix(pypi): rename pacakge name
1 parent 0557fd0 commit b283dfa

File tree

13 files changed

+78
-63
lines changed

13 files changed

+78
-63
lines changed

README.md

Lines changed: 61 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,96 @@
1-
GetFreeProxy Python client
2-
=================================
1+
GetFreeProxy Python client
2+
===========================
33

4-
Install
5-
-------
4+
This is a small, typed Python client for the GetFreeProxy API (https://developer.getfreeproxy.com).
5+
6+
About the API
7+
-------------
8+
The GetFreeProxy API exposes a simple endpoint to fetch public proxy servers:
9+
10+
- GET /v1/proxies — returns a JSON array of proxy objects. Optional query parameters include `country`, `protocol`, and `page`.
11+
12+
Each proxy object contains fields such as `ip`, `port`, `protocol`, `proxyUrl`, `countryCode`, `anonymity`, `uptime`, and timestamps like `lastAliveAt`.
13+
14+
Key behaviours of this client
15+
----------------------------
16+
- Minimal runtime dependency (`httpx`).
17+
- Synchronous `Client` and asynchronous `AsyncClient` classes with simple `query(...)` methods.
18+
- Returns a list of `Proxy` dataclasses (fields mapped to Pythonic names, e.g. `country_code`).
19+
- Raises typed exceptions on errors: `APIError`, `InvalidAPIKey`, `NetworkError`, `TimeoutError`, `ParseError`.
20+
21+
Installation
22+
------------
23+
24+
Install from PyPI (when published) or locally in editable mode during development:
625

726
```bash
8-
pip install .
27+
pip install freeproxy-python
28+
# or local editable install for development:
29+
pip install -e .[dev]
930
```
1031

11-
Usage (sync)
12-
------------
32+
Quick examples
33+
--------------
34+
35+
Sync example:
1336

1437
```py
15-
from getfreeproxy import FreeProxyClient
38+
from freeproxy import Client
1639

17-
client = FreeProxyClient(api_key="YOUR_API_KEY")
40+
client = Client(api_key="YOUR_API_KEY")
1841
proxies = client.query(country="US", protocol="https")
1942
for p in proxies:
20-
print(p.proxy_url)
43+
print(p.to_url())
2144
client.close()
2245
```
2346

24-
Usage (async)
25-
-------------
47+
Async example:
2648

2749
```py
2850
import asyncio
29-
from getfreeproxy import AsyncFreeProxyClient
51+
from freeproxy import AsyncClient
3052

3153
async def main():
32-
client = AsyncFreeProxyClient(api_key="YOUR_API_KEY")
54+
client = AsyncClient(api_key="YOUR_API_KEY")
3355
proxies = await client.query(country="US")
3456
for p in proxies:
35-
print(p.proxy_url)
57+
print(p.to_url())
3658
await client.aclose()
3759

3860
asyncio.run(main())
3961
```
4062

41-
Tests
42-
-----
63+
Authentication
64+
--------------
65+
Provide your API key to the client constructor. The client sends `Authorization: Bearer <API_KEY>` in requests.
4366

44-
Install dev dependencies and run tests:
67+
Query parameters
68+
----------------
69+
- `country`: ISO 3166-1 alpha-2 country code (e.g. `US`).
70+
- `protocol`: proxy protocol filter like `http`, `https`, `socks5`.
71+
- `page`: pagination page index (integer).
4572

46-
```bash
47-
pip install -e .[dev]
48-
pytest -q
49-
```
50-
51-
Publishing
52-
----------
73+
Errors and exceptions
74+
---------------------
75+
- `APIError` is raised for non-2xx HTTP responses. The message attempts to surface the API `error` field when present, otherwise it falls back to the response body.
76+
- `InvalidAPIKey` is a subclass used when the API returns HTTP 401.
77+
- `NetworkError` and `TimeoutError` wrap transport-level failures.
5378

54-
This repository uses a GitHub Actions workflow to publish to PyPI when a tag matching `vX.Y.Z` is pushed.
79+
Notes and limitations
80+
---------------------
81+
- This client intentionally keeps runtime dependencies minimal and does not implement automatic retries. It also does not stream responses — responses are small (up to ~10 proxies per request).
5582

56-
Preparation (one-time):
57-
- Create a PyPI API token at https://pypi.org/ (Account > API tokens).
58-
- Add the token to GitHub repository secrets as `PYPI_API_TOKEN` (Repository Settings > Secrets).
59-
60-
Release steps (recommended via CI):
61-
62-
1. Bump `version` in `pyproject.toml` to the new release version (for example `0.0.2`).
63-
2. Create a signed or annotated tag and push it:
83+
Testing
84+
-------
85+
Run the test suite locally with:
6486

6587
```bash
66-
git tag -a v0.0.2 -m "Release v0.0.2"
67-
git push origin v0.0.2
88+
pip install -e .[dev]
89+
pytest -q
6890
```
6991

70-
When the tag is pushed, GitHub Actions will run `.github/workflows/release.yml` and publish the built distributions to PyPI using the `PYPI_API_TOKEN` secret.
71-
72-
You can also build and upload locally (useful for dry-run checks):
92+
License
93+
-------
94+
MIT
7395

74-
```bash
75-
python -m pip install --upgrade build twine
76-
python -m build
77-
python -m twine check dist/*
78-
# then upload (will require PyPI credentials or token):
79-
python -m twine upload dist/*
80-
```
8196

freeproxy/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from ._version import __version__
2+
from .models import Proxy
3+
from .client import Client
4+
from .async_client import AsyncClient
5+
6+
__all__ = ["__version__", "Proxy", "Client", "AsyncClient"]
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ def extract_error_message(body_text: str, json_body: Optional[Dict] = None) -> s
1515
return str(json_body.get("error"))
1616
if "message" in json_body:
1717
return str(json_body.get("message"))
18-
# fallback to first string-like field
1918
for k in ("detail", "code"):
2019
if k in json_body:
2120
return str(json_body.get(k))

freeproxy/_version.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
__version__ = "1.0.0"
2+
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from ._utils import build_headers, extract_error_message
77

88

9-
class AsyncFreeProxyClient:
9+
class AsyncClient:
1010
def __init__(self, api_key: str, *, base_url: str = "https://api.getfreeproxy.com", timeout: float = 30.0, user_agent: Optional[str] = None, session: Optional[httpx.AsyncClient] = None):
1111
self.api_key = api_key
1212
self.base_url = base_url.rstrip("/")
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from ._utils import build_headers, extract_error_message
77

88

9-
class FreeProxyClient:
9+
class Client:
1010
def __init__(self, api_key: str, *, base_url: str = "https://api.getfreeproxy.com", timeout: float = 30.0, user_agent: Optional[str] = None, session: Optional[httpx.Client] = None):
1111
self.api_key = api_key
1212
self.base_url = base_url.rstrip("/")

getfreeproxy/__init__.py

Lines changed: 0 additions & 6 deletions
This file was deleted.

getfreeproxy/_version.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)