# Python

In Python, we'll be using the `requests` library to send HTTP requests. Here's how you can use the book search API with Python:

First, make sure you import the necessary library at the top of your file:

```python
import requests
import os
import json
```

Then, you can use the following code to make the API request:

```python
def search_book(query):
    url = "https://api.promptjoy.com/api/mVMCpq"
    headers = {
        'Content-Type': 'application/json',
        'x-api-key': os.getenv('PROMPTJOY_API_KEY')
    }
    data = {
        'query': query
    }
    response = requests.post(url, headers=headers, data=json.dumps(data))

    if response.status_code == 200:
        return response.json()
    else:
        raise Exception(f"Request failed with status {response.status_code}")

```

\
You can call this function with the search term as follows:

```python
search_result = search_book("your_search_term")
print(search_result)

```

Replace `"your_search_term"` with the book you're searching for. This function will return a dictionary of the search results.

This example uses the `requests` library, which is a popular choice for making HTTP requests in Python. If you haven't installed it yet, you can do so with `pip install requests`.

Remember to handle exceptions and errors as needed in your actual application code.

Note: In this example, the API key is retrieved from environment variables for security reasons. Ensure that you've set the `PROMPTJOY_API_KEY` environment variable in your environment where this code will be executed.

\
\ <br>


---

# 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://docs.promptjoy.com/api/api-usage/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.
