|
| 1 | +API Reference |
| 2 | +============= |
| 3 | + |
| 4 | +.. note:: |
| 5 | + This is a minimal API reference. Comprehensive API documentation with detailed |
| 6 | + descriptions, examples, and advanced usage will be added in the next update. |
| 7 | + |
| 8 | +Top-Level Functions |
| 9 | +------------------- |
| 10 | + |
| 11 | +.. code-block:: python |
| 12 | +
|
| 13 | + import httpmorph |
| 14 | +
|
| 15 | + # Simple HTTP methods |
| 16 | + response = httpmorph.get(url, **kwargs) |
| 17 | + response = httpmorph.post(url, **kwargs) |
| 18 | + response = httpmorph.put(url, **kwargs) |
| 19 | + response = httpmorph.delete(url, **kwargs) |
| 20 | + response = httpmorph.head(url, **kwargs) |
| 21 | + response = httpmorph.options(url, **kwargs) |
| 22 | + response = httpmorph.patch(url, **kwargs) |
| 23 | +
|
| 24 | +Client Class |
| 25 | +------------ |
| 26 | + |
| 27 | +.. code-block:: python |
| 28 | +
|
| 29 | + import httpmorph |
| 30 | +
|
| 31 | + # Create a client |
| 32 | + client = httpmorph.Client(http2=False, timeout=30) |
| 33 | +
|
| 34 | + # Make requests |
| 35 | + response = client.get(url, **kwargs) |
| 36 | + response = client.post(url, **kwargs) |
| 37 | + # ... other HTTP methods |
| 38 | +
|
| 39 | +**Constructor Parameters:** |
| 40 | + |
| 41 | +* ``http2`` (bool): Enable HTTP/2 support. Default: ``False`` |
| 42 | +* ``timeout`` (int): Default timeout in seconds. Default: ``30`` |
| 43 | + |
| 44 | +Session Class |
| 45 | +------------- |
| 46 | + |
| 47 | +.. code-block:: python |
| 48 | +
|
| 49 | + import httpmorph |
| 50 | +
|
| 51 | + # Create a session |
| 52 | + session = httpmorph.Session(browser='chrome', http2=False) |
| 53 | +
|
| 54 | + # Use as context manager |
| 55 | + with httpmorph.Session(browser='chrome') as session: |
| 56 | + response = session.get(url) |
| 57 | +
|
| 58 | +**Constructor Parameters:** |
| 59 | + |
| 60 | +* ``browser`` (str): Browser to mimic. Options: ``'chrome'``, ``'firefox'``, ``'safari'``, ``'edge'``, ``'random'``. Default: ``'chrome'`` |
| 61 | +* ``http2`` (bool): Enable HTTP/2 support. Default: ``False`` |
| 62 | + |
| 63 | +**Attributes:** |
| 64 | + |
| 65 | +* ``cookie_jar``: Cookie storage for the session |
| 66 | + |
| 67 | +Response Class |
| 68 | +-------------- |
| 69 | + |
| 70 | +All requests return a ``Response`` object: |
| 71 | + |
| 72 | +.. code-block:: python |
| 73 | +
|
| 74 | + response = httpmorph.get('https://example.com') |
| 75 | +
|
| 76 | +**Attributes:** |
| 77 | + |
| 78 | +Basic Response Information |
| 79 | +~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 80 | + |
| 81 | +* ``status_code`` (int): HTTP status code |
| 82 | +* ``body`` (bytes): Response body |
| 83 | +* ``headers`` (dict): Response headers |
| 84 | +* ``history`` (list): Redirect history |
| 85 | + |
| 86 | +Timing Information |
| 87 | +~~~~~~~~~~~~~~~~~~ |
| 88 | + |
| 89 | +* ``total_time_us`` (int): Total request time in microseconds |
| 90 | +* ``first_byte_time_us`` (int): Time to first byte in microseconds |
| 91 | +* ``connect_time_us`` (int): Connection establishment time in microseconds |
| 92 | +* ``tls_time_us`` (int): TLS handshake time in microseconds (HTTPS only) |
| 93 | + |
| 94 | +TLS Information |
| 95 | +~~~~~~~~~~~~~~~ |
| 96 | + |
| 97 | +* ``tls_version`` (str): TLS version (e.g., ``"TLSv1.3"``) |
| 98 | +* ``tls_cipher`` (str): Cipher suite name |
| 99 | +* ``ja3_fingerprint`` (str): JA3 TLS fingerprint |
| 100 | + |
| 101 | +HTTP Version Information |
| 102 | +~~~~~~~~~~~~~~~~~~~~~~~~ |
| 103 | + |
| 104 | +* ``http_version`` (str): HTTP protocol version (e.g., ``"1.1"`` or ``"2.0"``) |
| 105 | + |
| 106 | +Common Request Parameters |
| 107 | +------------------------- |
| 108 | + |
| 109 | +Most request methods accept these common parameters: |
| 110 | + |
| 111 | +.. code-block:: python |
| 112 | +
|
| 113 | + response = httpmorph.get( |
| 114 | + url, |
| 115 | + headers=None, # Dict of HTTP headers |
| 116 | + params=None, # Dict of URL parameters |
| 117 | + json=None, # Dict to send as JSON body |
| 118 | + data=None, # String/bytes to send as body |
| 119 | + timeout=30, # Request timeout in seconds |
| 120 | + http2=None, # Override HTTP/2 setting |
| 121 | + follow_redirects=True, # Follow HTTP redirects |
| 122 | + ) |
| 123 | +
|
| 124 | +Full API Documentation |
| 125 | +---------------------- |
| 126 | + |
| 127 | +Comprehensive API documentation including: |
| 128 | + |
| 129 | +* Detailed method signatures |
| 130 | +* Parameter descriptions and types |
| 131 | +* Return value specifications |
| 132 | +* Exception handling |
| 133 | +* Advanced configuration options |
| 134 | +* Internal APIs |
| 135 | + |
| 136 | +...will be available in the next update. |
| 137 | + |
| 138 | +For now, please refer to: |
| 139 | + |
| 140 | +* The source code in ``src/httpmorph/`` |
| 141 | +* Examples in the ``examples/`` directory |
| 142 | +* Type hints in the code |
| 143 | +* The project README |
0 commit comments