Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ repurposed = client.ai.repurpose_url(
```python
Fopost(
api_key="fp_...", # or FOPOST_API_KEY
base_url="https://api.fopost.com/api/v1", # override for a dev server
base_url="https://api.fopost.com/v1", # override for a dev server
timeout=30.0, # seconds, or an httpx.Timeout
max_retries=3, # total attempts on a 429
http_client=my_httpx_client, # bring your own transport
Expand Down Expand Up @@ -200,7 +200,7 @@ running API:

```bash
export FOPOST_API_KEY=fp_...
export FOPOST_BASE_URL=http://localhost:8080/api/v1
export FOPOST_BASE_URL=http://localhost:8080/v1
python examples/create_post.py "Hello from the Python SDK" --publish
```

Expand Down
2 changes: 1 addition & 1 deletion examples/create_post.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Point it at a local dev API:

export FOPOST_API_KEY=fp_...
export FOPOST_BASE_URL=http://localhost:8080/api/v1
export FOPOST_BASE_URL=http://localhost:8080/v1
python examples/create_post.py "Hello from the Python SDK"

Without --publish it stops at a draft, so you can run it against a real
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "fopost"
version = "0.1.2"
version = "0.1.3"
description = "Official Python SDK for the FoPost API. Schedule and publish to +30 social platforms from your code."
readme = "README.md"
license = "MIT"
Expand Down
2 changes: 1 addition & 1 deletion src/fopost/_http.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

from .errors import FopostError, RateLimitError, error_from_response

DEFAULT_BASE_URL = "https://api.fopost.com/api/v1"
DEFAULT_BASE_URL = "https://api.fopost.com/v1"
DEFAULT_TIMEOUT = 30.0
DEFAULT_MAX_RETRIES = 3
MAX_RETRY_WAIT = 60.0
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from fopost import Fopost

BASE_URL = "https://api.test.fopost.com/api/v1"
BASE_URL = "https://api.test.fopost.com/v1"
API_KEY = "osk_test_key"


Expand Down
19 changes: 17 additions & 2 deletions tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,28 @@ def test_the_api_key_falls_back_to_the_environment(monkeypatch: pytest.MonkeyPat
assert client._http.api_key == "osk_from_env"


def test_the_default_base_url_includes_the_api_version() -> None:
assert DEFAULT_BASE_URL == "https://api.fopost.com/api/v1"
def test_the_default_base_url_is_the_documented_v1_path() -> None:
assert DEFAULT_BASE_URL == "https://api.fopost.com/v1"
assert "/api/v1" not in DEFAULT_BASE_URL

with Fopost(api_key=API_KEY) as client:
assert client.base_url == DEFAULT_BASE_URL


@respx.mock
def test_requests_go_to_v1_and_never_to_the_404_api_v1_path() -> None:
route = respx.get("https://api.fopost.com/v1/workspaces").mock(
return_value=httpx.Response(200, json={"data": []})
)

with Fopost(api_key=API_KEY) as client:
client.workspaces.list()

url = str(route.calls.last.request.url)
assert url.startswith("https://api.fopost.com/v1/")
assert "/api/v1/" not in url


def test_a_trailing_slash_on_the_base_url_does_not_double_up() -> None:
with Fopost(api_key=API_KEY, base_url=f"{BASE_URL}/") as client:
assert client.base_url == BASE_URL
Expand Down
Loading