hyper-sdk


Namehyper-sdk JSON
Version 0.3.3 PyPI version JSON
download
home_pageNone
SummaryHyper Solutions Python SDK
upload_time2024-11-20 09:43:16
maintainerNone
docs_urlNone
authorNone
requires_python>=3.6
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Hyper Solutions SDK for Python

## Installation

To use the Hyper Solutions SDK in your Python project, you need to install it using the following command:

```
pip install hyper-sdk
```

## Usage

### Creating a Session

To start using the SDK, you need to create a new `Session` instance by providing your API key:

```python
from hyper_sdk import Session

session = Session(api_key="your-api-key")
```

You can also optionally set a JWT key and a custom HTTP client:

```python
from hyper_sdk import Session

session = Session(api_key="your-api-key", jwt_key="your-jwt-key", client=custom_http_client)
```

## Akamai

The Akamai package provides functions for interacting with Akamai Bot Manager, including generating sensor data, parsing script path, parsing pixel challenges, and handling sec-cpt challenges.

### Generating Sensor Data

To generate sensor data required for generating valid Akamai cookies, use the `generate_sensor_data` method:

```python
from hyper_sdk import SensorInput

sensor_input = SensorInput(
    page_url="https://example.com/",
    user_agent="your-user-agent",
    abck="your-abck-cookie",
    bmsz="your-bmsz-cookie",
    version="2.0"
)
sensor_data = session.generate_sensor_data(sensor_input)
```

### Parsing Script Path

To parse the Akamai Bot Manager script path from the given HTML code, use the `parse_script_path` function from the `script_path` module:

```python
from hyper_sdk.akamai.script_path import parse_script_path

script_path = parse_script_path(html_source)
```

### Handling Sec-Cpt Challenges

The Akamai package provides functions for handling sec-cpt challenges:

- `SecCptChallenge.parse`: Parses a sec-cpt challenge from an HTML source.
- `generate_sec_cpt_payload`: Generates a sec-cpt payload using the provided sec-cpt cookie.
- `sleep`: Sleeps for the duration specified in the sec-cpt challenge.

Example usage:

```python
from hyper_sdk.akamai.sec_cpt import SecCptChallenge

challenge = SecCptChallenge.parse(html_source)
payload = challenge.generate_sec_cpt_payload(sec_cpt_cookie)
challenge.sleep()
```

### Validating Cookies

The Akamai package provides functions for validating cookies:

- `is_cookie_valid`: Determines if the provided `_abck` cookie value is valid based on the given request count.
- `is_cookie_invalidated`: Determines if the current session requires more sensors to be sent.

Example usage:

```python
from hyper_sdk.akamai.stop_signal import is_cookie_valid, is_cookie_invalidated

is_valid = is_cookie_valid(abck_cookie, request_count)
is_invalidated = is_cookie_invalidated(abck_cookie)
```

### Generating Pixel Data

To generate pixel data, use the `generate_pixel_data` method:

```python
from hyper_sdk import PixelInput

pixel_input = PixelInput(
    user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36",
    html_var="your-html-var",
    script_var="your-script-var"
)
pixel_data = session.generate_pixel_data(pixel_input)
```

### Parsing Pixel Challenges

The Akamai package provides functions for parsing pixel challenges:

- `parse_pixel_html_var`: Parses the required pixel challenge variable from the given HTML code.
- `parse_pixel_script_url`: Parses the script URL of the pixel challenge script and the URL to post a generated payload to from the given HTML code.
- `parse_pixel_script_var`: Parses the dynamic value from the pixel script.

Example usage:

```python
from hyper_sdk.akamai.pixel import parse_pixel_html_var, parse_pixel_script_url, parse_pixel_script_var

html_var = parse_pixel_html_var(html_source)
script_url, post_url = parse_pixel_script_url(html_source)
script_var = parse_pixel_script_var(script_source)
```


## Incapsula

The Incapsula package provides functions for interacting with Imperva Incapsula, including generating Reese84 sensor data, UTMVC cookies, and parsing UTMVC script paths.

### Generating Reese84 Sensor

To generate sensor data required for generating valid Reese84 cookies, use the `generate_reese84_sensor` method:

```python
sensor_data = session.generate_reese84_sensor(site="example.com", user_agent="your-user-agent")
```

### Generating UTMVC Cookie

To generate the UTMVC cookie using the Hyper Solutions API, use the `generate_utmvc_cookie` method:

```python
from hyper_sdk import UtmvcInput

utmvc_input = UtmvcInput(
    user_agent="your-user-agent",
    session_ids=["session-id-1", "session-id-2"],
    script="your-script"
)
utmvc_cookie = session.generate_utmvc_cookie(utmvc_input)
```

### Parsing UTMVC Script Path

To parse the UTMVC script path from a given script content, use the `parse_utmvc_script_path` function from the `utmvc` module:

```python
from hyper_sdk.incapsula.utmvc import parse_utmvc_script_path

script_path = parse_utmvc_script_path(script_content)
```

### Generating UTMVC Submit Path

To generate a unique UTMVC submit path with a random query parameter, use the `get_utmvc_submit_path` function from the `utmvc` module:

```python
from hyper_sdk.incapsula.utmvc import get_utmvc_submit_path

submit_path = get_utmvc_submit_path()
```

## Kasada

The Kasada package provides functions for interacting with Kasada Bot Manager, including parsing script path.

### Generating Payload Data (CT)

To generate payload data required for generating valid `x-kpsdk-ct` tokens, use the `generate_kasada_payload` function:

```python
payload, headers = hyper_session.generate_kasada_payload(hyper_sdk.KasadaPayloadInput(
    user_agent=USER_AGENT,
    ips_link=ips_link,
    script=ips_script,
    language="en-US"
))
# Use payload and headers for the next request
```

### Generating Pow Data (CD)

To generate POW data (`x-kpsdk-cd`) tokens, use the `generate_kasada_pow` function:

```python
cd = hyper_session.generate_kasada_pow(hyper_sdk.KasadaPowInput(
    st=st,
    work_time=None
))
# Use cd as the x-kpsdk-cd header in the next request
```

### Parsing Script Path

To parse the Kasada script path from the given blocked page (status code 429) HTML code, use the `parse_script_path` function:

```python
from hyper_sdk.kasada import parse_script_path

script_path = parse_script_path(html_content)
# script_path will look like: /ips.js?...
```

## DataDome

The DataDome package provides functions for interacting with DataDome Bot Manager, including parsing device link URLs
for interstitial and slider challenges.

### Generating Interstitial Payload

To generate payload data required for solving interstitial challenges, use the `generate_interstitial_payload` function:

```python
payload = hyper_session.generate_interstitial_payload(hyper_sdk.DataDomeInterstitialInput(
    user_agent=USER_AGENT,
    device_link=device_check_link,
    html=html_content
))
# Use the payload to POST to https://geo.captcha-delivery.com/interstitial/
```

### Generating Slider Payload

To solve DataDome Slider challenges, use the `generate_slider_payload` function:

```python
payload = hyper_session.generate_slider_payload(hyper_sdk.DataDomeSliderInput(
    user_agent=USER_AGENT,
    device_link=device_check_link,
    html=html_content,
    puzzle=base64_encoded_puzzle,
    piece=base64_encoded_piece
))
# Create a GET request to the payload URL
```

### Parsing Interstitial DeviceLink URL

To parse the Interstitial DeviceLink URL from the HTML code, use the `parse_interstitial_device_check_link` function:

```python
from hyper_sdk.datadome import parse_interstitial_device_check_link

device_link = parse_interstitial_device_check_link(html_content, datadome_cookie, referer)
# device_link will look like: https://geo.captcha-delivery.com/interstitial/?...
```

### Parsing Slider DeviceLink URL

To parse the Slider DeviceLink URL from the HTML code, use the `parse_slider_device_check_link` function:

```python
from hyper_sdk.datadome import parse_slider_device_check_link

device_link = parse_slider_device_check_link(html_content, datadome_cookie, referer)
# device_link will look like: https://geo.captcha-delivery.com/captcha/?...
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "hyper-sdk",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": null,
    "keywords": null,
    "author": null,
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/a7/6b/cef4123fb90af41e3af70decebdaf5208e500dc441ba7aaca30f223d83b1/hyper_sdk-0.3.3.tar.gz",
    "platform": null,
    "description": "# Hyper Solutions SDK for Python\r\n\r\n## Installation\r\n\r\nTo use the Hyper Solutions SDK in your Python project, you need to install it using the following command:\r\n\r\n```\r\npip install hyper-sdk\r\n```\r\n\r\n## Usage\r\n\r\n### Creating a Session\r\n\r\nTo start using the SDK, you need to create a new `Session` instance by providing your API key:\r\n\r\n```python\r\nfrom hyper_sdk import Session\r\n\r\nsession = Session(api_key=\"your-api-key\")\r\n```\r\n\r\nYou can also optionally set a JWT key and a custom HTTP client:\r\n\r\n```python\r\nfrom hyper_sdk import Session\r\n\r\nsession = Session(api_key=\"your-api-key\", jwt_key=\"your-jwt-key\", client=custom_http_client)\r\n```\r\n\r\n## Akamai\r\n\r\nThe Akamai package provides functions for interacting with Akamai Bot Manager, including generating sensor data, parsing script path, parsing pixel challenges, and handling sec-cpt challenges.\r\n\r\n### Generating Sensor Data\r\n\r\nTo generate sensor data required for generating valid Akamai cookies, use the `generate_sensor_data` method:\r\n\r\n```python\r\nfrom hyper_sdk import SensorInput\r\n\r\nsensor_input = SensorInput(\r\n    page_url=\"https://example.com/\",\r\n    user_agent=\"your-user-agent\",\r\n    abck=\"your-abck-cookie\",\r\n    bmsz=\"your-bmsz-cookie\",\r\n    version=\"2.0\"\r\n)\r\nsensor_data = session.generate_sensor_data(sensor_input)\r\n```\r\n\r\n### Parsing Script Path\r\n\r\nTo parse the Akamai Bot Manager script path from the given HTML code, use the `parse_script_path` function from the `script_path` module:\r\n\r\n```python\r\nfrom hyper_sdk.akamai.script_path import parse_script_path\r\n\r\nscript_path = parse_script_path(html_source)\r\n```\r\n\r\n### Handling Sec-Cpt Challenges\r\n\r\nThe Akamai package provides functions for handling sec-cpt challenges:\r\n\r\n- `SecCptChallenge.parse`: Parses a sec-cpt challenge from an HTML source.\r\n- `generate_sec_cpt_payload`: Generates a sec-cpt payload using the provided sec-cpt cookie.\r\n- `sleep`: Sleeps for the duration specified in the sec-cpt challenge.\r\n\r\nExample usage:\r\n\r\n```python\r\nfrom hyper_sdk.akamai.sec_cpt import SecCptChallenge\r\n\r\nchallenge = SecCptChallenge.parse(html_source)\r\npayload = challenge.generate_sec_cpt_payload(sec_cpt_cookie)\r\nchallenge.sleep()\r\n```\r\n\r\n### Validating Cookies\r\n\r\nThe Akamai package provides functions for validating cookies:\r\n\r\n- `is_cookie_valid`: Determines if the provided `_abck` cookie value is valid based on the given request count.\r\n- `is_cookie_invalidated`: Determines if the current session requires more sensors to be sent.\r\n\r\nExample usage:\r\n\r\n```python\r\nfrom hyper_sdk.akamai.stop_signal import is_cookie_valid, is_cookie_invalidated\r\n\r\nis_valid = is_cookie_valid(abck_cookie, request_count)\r\nis_invalidated = is_cookie_invalidated(abck_cookie)\r\n```\r\n\r\n### Generating Pixel Data\r\n\r\nTo generate pixel data, use the `generate_pixel_data` method:\r\n\r\n```python\r\nfrom hyper_sdk import PixelInput\r\n\r\npixel_input = PixelInput(\r\n    user_agent=\"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.82 Safari/537.36\",\r\n    html_var=\"your-html-var\",\r\n    script_var=\"your-script-var\"\r\n)\r\npixel_data = session.generate_pixel_data(pixel_input)\r\n```\r\n\r\n### Parsing Pixel Challenges\r\n\r\nThe Akamai package provides functions for parsing pixel challenges:\r\n\r\n- `parse_pixel_html_var`: Parses the required pixel challenge variable from the given HTML code.\r\n- `parse_pixel_script_url`: Parses the script URL of the pixel challenge script and the URL to post a generated payload to from the given HTML code.\r\n- `parse_pixel_script_var`: Parses the dynamic value from the pixel script.\r\n\r\nExample usage:\r\n\r\n```python\r\nfrom hyper_sdk.akamai.pixel import parse_pixel_html_var, parse_pixel_script_url, parse_pixel_script_var\r\n\r\nhtml_var = parse_pixel_html_var(html_source)\r\nscript_url, post_url = parse_pixel_script_url(html_source)\r\nscript_var = parse_pixel_script_var(script_source)\r\n```\r\n\r\n\r\n## Incapsula\r\n\r\nThe Incapsula package provides functions for interacting with Imperva Incapsula, including generating Reese84 sensor data, UTMVC cookies, and parsing UTMVC script paths.\r\n\r\n### Generating Reese84 Sensor\r\n\r\nTo generate sensor data required for generating valid Reese84 cookies, use the `generate_reese84_sensor` method:\r\n\r\n```python\r\nsensor_data = session.generate_reese84_sensor(site=\"example.com\", user_agent=\"your-user-agent\")\r\n```\r\n\r\n### Generating UTMVC Cookie\r\n\r\nTo generate the UTMVC cookie using the Hyper Solutions API, use the `generate_utmvc_cookie` method:\r\n\r\n```python\r\nfrom hyper_sdk import UtmvcInput\r\n\r\nutmvc_input = UtmvcInput(\r\n    user_agent=\"your-user-agent\",\r\n    session_ids=[\"session-id-1\", \"session-id-2\"],\r\n    script=\"your-script\"\r\n)\r\nutmvc_cookie = session.generate_utmvc_cookie(utmvc_input)\r\n```\r\n\r\n### Parsing UTMVC Script Path\r\n\r\nTo parse the UTMVC script path from a given script content, use the `parse_utmvc_script_path` function from the `utmvc` module:\r\n\r\n```python\r\nfrom hyper_sdk.incapsula.utmvc import parse_utmvc_script_path\r\n\r\nscript_path = parse_utmvc_script_path(script_content)\r\n```\r\n\r\n### Generating UTMVC Submit Path\r\n\r\nTo generate a unique UTMVC submit path with a random query parameter, use the `get_utmvc_submit_path` function from the `utmvc` module:\r\n\r\n```python\r\nfrom hyper_sdk.incapsula.utmvc import get_utmvc_submit_path\r\n\r\nsubmit_path = get_utmvc_submit_path()\r\n```\r\n\r\n## Kasada\r\n\r\nThe Kasada package provides functions for interacting with Kasada Bot Manager, including parsing script path.\r\n\r\n### Generating Payload Data (CT)\r\n\r\nTo generate payload data required for generating valid `x-kpsdk-ct` tokens, use the `generate_kasada_payload` function:\r\n\r\n```python\r\npayload, headers = hyper_session.generate_kasada_payload(hyper_sdk.KasadaPayloadInput(\r\n    user_agent=USER_AGENT,\r\n    ips_link=ips_link,\r\n    script=ips_script,\r\n    language=\"en-US\"\r\n))\r\n# Use payload and headers for the next request\r\n```\r\n\r\n### Generating Pow Data (CD)\r\n\r\nTo generate POW data (`x-kpsdk-cd`) tokens, use the `generate_kasada_pow` function:\r\n\r\n```python\r\ncd = hyper_session.generate_kasada_pow(hyper_sdk.KasadaPowInput(\r\n    st=st,\r\n    work_time=None\r\n))\r\n# Use cd as the x-kpsdk-cd header in the next request\r\n```\r\n\r\n### Parsing Script Path\r\n\r\nTo parse the Kasada script path from the given blocked page (status code 429) HTML code, use the `parse_script_path` function:\r\n\r\n```python\r\nfrom hyper_sdk.kasada import parse_script_path\r\n\r\nscript_path = parse_script_path(html_content)\r\n# script_path will look like: /ips.js?...\r\n```\r\n\r\n## DataDome\r\n\r\nThe DataDome package provides functions for interacting with DataDome Bot Manager, including parsing device link URLs\r\nfor interstitial and slider challenges.\r\n\r\n### Generating Interstitial Payload\r\n\r\nTo generate payload data required for solving interstitial challenges, use the `generate_interstitial_payload` function:\r\n\r\n```python\r\npayload = hyper_session.generate_interstitial_payload(hyper_sdk.DataDomeInterstitialInput(\r\n    user_agent=USER_AGENT,\r\n    device_link=device_check_link,\r\n    html=html_content\r\n))\r\n# Use the payload to POST to https://geo.captcha-delivery.com/interstitial/\r\n```\r\n\r\n### Generating Slider Payload\r\n\r\nTo solve DataDome Slider challenges, use the `generate_slider_payload` function:\r\n\r\n```python\r\npayload = hyper_session.generate_slider_payload(hyper_sdk.DataDomeSliderInput(\r\n    user_agent=USER_AGENT,\r\n    device_link=device_check_link,\r\n    html=html_content,\r\n    puzzle=base64_encoded_puzzle,\r\n    piece=base64_encoded_piece\r\n))\r\n# Create a GET request to the payload URL\r\n```\r\n\r\n### Parsing Interstitial DeviceLink URL\r\n\r\nTo parse the Interstitial DeviceLink URL from the HTML code, use the `parse_interstitial_device_check_link` function:\r\n\r\n```python\r\nfrom hyper_sdk.datadome import parse_interstitial_device_check_link\r\n\r\ndevice_link = parse_interstitial_device_check_link(html_content, datadome_cookie, referer)\r\n# device_link will look like: https://geo.captcha-delivery.com/interstitial/?...\r\n```\r\n\r\n### Parsing Slider DeviceLink URL\r\n\r\nTo parse the Slider DeviceLink URL from the HTML code, use the `parse_slider_device_check_link` function:\r\n\r\n```python\r\nfrom hyper_sdk.datadome import parse_slider_device_check_link\r\n\r\ndevice_link = parse_slider_device_check_link(html_content, datadome_cookie, referer)\r\n# device_link will look like: https://geo.captcha-delivery.com/captcha/?...\r\n```\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Hyper Solutions Python SDK",
    "version": "0.3.3",
    "project_urls": {
        "homepage": "https://github.com/Hyper-Solutions/hyper-sdk-py"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b3a804349e8949a3c1dbf9018987a330b88fda588bbe1139b8cc7da25dcbb457",
                "md5": "f0b2f584acb28be9b4c683853ce6e267",
                "sha256": "ba973d2784de31bc563ef3f0bd2aef9efd7336e560877338a2540f4f13a61cad"
            },
            "downloads": -1,
            "filename": "hyper_sdk-0.3.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f0b2f584acb28be9b4c683853ce6e267",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 16034,
            "upload_time": "2024-11-20T09:43:13",
            "upload_time_iso_8601": "2024-11-20T09:43:13.590323Z",
            "url": "https://files.pythonhosted.org/packages/b3/a8/04349e8949a3c1dbf9018987a330b88fda588bbe1139b8cc7da25dcbb457/hyper_sdk-0.3.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "a76bcef4123fb90af41e3af70decebdaf5208e500dc441ba7aaca30f223d83b1",
                "md5": "c39ca6d15b92cbc55f8818735dc285ff",
                "sha256": "ce23e77ee8b209808b4cd2900cb39ce1882f562e64f163ad8fd8f5a81c49c5c0"
            },
            "downloads": -1,
            "filename": "hyper_sdk-0.3.3.tar.gz",
            "has_sig": false,
            "md5_digest": "c39ca6d15b92cbc55f8818735dc285ff",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 14255,
            "upload_time": "2024-11-20T09:43:16",
            "upload_time_iso_8601": "2024-11-20T09:43:16.726944Z",
            "url": "https://files.pythonhosted.org/packages/a7/6b/cef4123fb90af41e3af70decebdaf5208e500dc441ba7aaca30f223d83b1/hyper_sdk-0.3.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-11-20 09:43:16",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Hyper-Solutions",
    "github_project": "hyper-sdk-py",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "hyper-sdk"
}
        
Elapsed time: 0.35691s