# API Reference ## Client ```python class Client(api_key=None, timeout=30, retry=True) ``` The main client class for interacting with the API. **Parameters:** - `api_key` (str): Your API key for authentication - `timeout` (int): Request timeout in seconds - `retry` (bool): Enable automatic retries on failure ### Methods #### get(endpoint, params=None) Perform a GET request. **Parameters:** - `endpoint` (str): API endpoint path - `params` (dict): Query parameters **Returns:** Response object **Raises:** APIError if the API returns an error ```python response = client.get('/users/123') ``` #### post(endpoint, data=None) Perform a POST request. **Parameters:** - `endpoint` (str): API endpoint path - `data` (dict): Request body data **Returns:** Response object ```python data = {'name': 'John', 'email': 'john@example.com'} response = client.post('/users', data=data) ``` #### put(endpoint, data=None) Perform a PUT request. **Parameters:** - `endpoint` (str): API endpoint path - `data` (dict): Request body data **Returns:** Response object ```python updates = {'name': 'Jane'} response = client.put('/users/123', data=updates) ``` #### delete(endpoint) Perform a DELETE request. **Parameters:** - `endpoint` (str): API endpoint path **Returns:** Response object ```python response = client.delete('/users/123') ``` ## Response Represents an API response. **Attributes:** - `status_code` (int): HTTP status code - `data` (dict): Response body data - `headers` (dict): Response headers ### Methods #### json() Parse response as JSON. **Returns:** Parsed JSON data ## Exceptions ### APIError Raised when the API returns an error. ### NetworkError Raised when a network error occurs. ### AuthenticationError Raised when authentication fails. ### RateLimitError Raised when rate limit is exceeded. ## Constants ### API_BASE_URL The base URL for API requests. ```python API_BASE_URL = 'https://api.example.com' ``` ### API_VERSION The current API version. ```python API_VERSION = 'v1' ``` ## Examples ### Initialization ```python from your_package import Client client = Client(api_key='your-key') ``` ### Get a resource ```python response = client.get('/users/123') if response.status_code == 200: print(response.data) ``` ### Create a resource ```python data = {'name': 'John', 'email': 'john@example.com'} response = client.post('/users', data=data) ``` ### Error handling ```python try: response = client.get('/users/123') except APIError as e: print(f"Error: {e}") ```