Skip to content

Commit 9e1e496

Browse files
committed
feat: changed SyncClient to Client
1 parent d3c352b commit 9e1e496

File tree

6 files changed

+21
-21
lines changed

6 files changed

+21
-21
lines changed

scrapegraph-py/examples/feedback_credits_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
from scrapegraph_py import SyncClient
1+
from scrapegraph_py import Client
22
from scrapegraph_py.logger import sgai_logger
33

44
sgai_logger.set_logging(level="INFO")
55

66
# Initialize the client
7-
sgai_client = SyncClient(api_key="your-api-key-here")
7+
sgai_client = Client(api_key="your-api-key-here")
88

99
# Example request_id (replace with an actual request_id from a previous request)
1010
request_id = "your-request-id-here"

scrapegraph-py/examples/smartscraper_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
from scrapegraph_py import SyncClient
1+
from scrapegraph_py import Client
22
from scrapegraph_py.logger import sgai_logger
33

44
sgai_logger.set_logging(level="INFO")
55

66
# Initialize the client with explicit API key
7-
sgai_client = SyncClient(api_key="your-api-key-here")
7+
sgai_client = Client(api_key="your-api-key-here")
88

99
# SmartScraper request
1010
response = sgai_client.smartscraper(

scrapegraph-py/examples/smartscraper_schema_example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from pydantic import BaseModel, Field
22

3-
from scrapegraph_py import SyncClient
3+
from scrapegraph_py import Client
44

55

66
# Define a Pydantic model for the output schema
@@ -11,7 +11,7 @@ class WebpageSchema(BaseModel):
1111

1212

1313
# Initialize the client
14-
sgai_client = SyncClient(api_key="your-api-key-here")
14+
sgai_client = Client(api_key="your-api-key-here")
1515

1616
# SmartScraper request with output schema
1717
response = sgai_client.smartscraper(
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from .async_client import AsyncClient
2-
from .client import SyncClient
2+
from .client import Client
33

4-
__all__ = ["SyncClient", "AsyncClient"]
4+
__all__ = ["Client", "AsyncClient"]

scrapegraph-py/scrapegraph_py/client.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Sync client implementation goes here
1+
# Client implementation goes here
22
from typing import Any, Optional
33

44
import requests
@@ -17,7 +17,7 @@
1717
from scrapegraph_py.utils.helpers import handle_sync_response, validate_api_key
1818

1919

20-
class SyncClient:
20+
class Client:
2121
@classmethod
2222
def from_env(
2323
cls,
@@ -26,7 +26,7 @@ def from_env(
2626
max_retries: int = 3,
2727
retry_delay: float = 1.0,
2828
):
29-
"""Initialize SyncClient using API key from environment variable.
29+
"""Initialize Client using API key from environment variable.
3030
3131
Args:
3232
verify_ssl: Whether to verify SSL certificates
@@ -55,7 +55,7 @@ def __init__(
5555
max_retries: int = 3,
5656
retry_delay: float = 1.0,
5757
):
58-
"""Initialize SyncClient with configurable parameters.
58+
"""Initialize Client with configurable parameters.
5959
6060
Args:
6161
api_key: API key for authentication. If None, will try to load from environment
@@ -64,7 +64,7 @@ def __init__(
6464
max_retries: Maximum number of retry attempts
6565
retry_delay: Delay between retries in seconds
6666
"""
67-
logger.info("🔑 Initializing SyncClient")
67+
logger.info("🔑 Initializing Client")
6868

6969
# Try to get API key from environment if not provided
7070
if api_key is None:
@@ -107,7 +107,7 @@ def __init__(
107107
if not verify_ssl:
108108
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
109109

110-
logger.info("✅ SyncClient initialized successfully")
110+
logger.info("✅ Client initialized successfully")
111111

112112
def _make_request(self, method: str, url: str, **kwargs) -> Any:
113113
"""Make HTTP request with error handling."""
@@ -211,7 +211,7 @@ def submit_feedback(
211211

212212
def close(self):
213213
"""Close the session to free up resources"""
214-
logger.info("🔒 Closing SyncClient session")
214+
logger.info("🔒 Closing Client session")
215215
self.session.close()
216216
logger.debug("✅ Session closed successfully")
217217

scrapegraph-py/tests/test_client.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import pytest
44
import responses
55

6-
from scrapegraph_py.client import SyncClient
6+
from scrapegraph_py.client import Client
77
from tests.utils import generate_mock_api_key
88

99

@@ -30,7 +30,7 @@ def test_smartscraper(mock_api_key):
3030
},
3131
)
3232

33-
with SyncClient(api_key=mock_api_key) as client:
33+
with Client(api_key=mock_api_key) as client:
3434
response = client.smartscraper(
3535
website_url="https://example.com", user_prompt="Describe this page."
3636
)
@@ -49,7 +49,7 @@ def test_get_smartscraper(mock_api_key, mock_uuid):
4949
},
5050
)
5151

52-
with SyncClient(api_key=mock_api_key) as client:
52+
with Client(api_key=mock_api_key) as client:
5353
response = client.get_smartscraper(mock_uuid)
5454
assert response["status"] == "completed"
5555
assert response["request_id"] == mock_uuid
@@ -63,7 +63,7 @@ def test_get_credits(mock_api_key):
6363
json={"remaining_credits": 100, "total_credits_used": 50},
6464
)
6565

66-
with SyncClient(api_key=mock_api_key) as client:
66+
with Client(api_key=mock_api_key) as client:
6767
response = client.get_credits()
6868
assert response["remaining_credits"] == 100
6969
assert response["total_credits_used"] == 50
@@ -77,7 +77,7 @@ def test_submit_feedback(mock_api_key):
7777
json={"status": "success"},
7878
)
7979

80-
with SyncClient(api_key=mock_api_key) as client:
80+
with Client(api_key=mock_api_key) as client:
8181
response = client.submit_feedback(
8282
request_id=str(uuid4()), rating=5, feedback_text="Great service!"
8383
)
@@ -92,7 +92,7 @@ def test_network_error(mock_api_key):
9292
body=ConnectionError("Network error"),
9393
)
9494

95-
with SyncClient(api_key=mock_api_key) as client:
95+
with Client(api_key=mock_api_key) as client:
9696
with pytest.raises(ConnectionError):
9797
client.smartscraper(
9898
website_url="https://example.com", user_prompt="Describe this page."

0 commit comments

Comments
 (0)