# Python

## Installation

```bash
python -m pip install crapsolver-python==0.0.8
```

***

## Example

```python
from crapsolver_python import Crapsolver, Captcha, Sitekey, User

if __name__ == "__main__":
    solver = Crapsolver("example")
    our_id = "user:123456"
    sitekey = "b2b02ab5-7dae-4d6f-830e-7b55634c888b"

    user: User = solver.get_user(our_id) # get info about ourselves to know if we can create a task
    assert user.balance > 0, "Balance needs to be greater than zero"

    print(f"Balance: ${user.balance}\nThreads: {user.used_threads}/{user.max_threads}\nTotal Solved: {user.solved_hcaptcha}")

    if user.used_threads < user.max_threads:
        sitekey_info: Sitekey = solver.check_sitekey(sitekey) # get info about the sitekey to know if its enabled

        if sitekey_info.enabled:

            captcha: Captcha = solver.solve(
                domain=sitekey_info.domain,
                sitekey=sitekey,
                proxy="http://username:password@ip:port",
                text_free_entry=True,
                turbo=True,
                turbo_st=3500,
            ) # create a task and get the captcha pass token

            print(captcha.token[:32], captcha.user_agent, captcha.req[:32], sep=" | ")
```

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://crapsolver.gitbook.io/readme/packages/python.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
