# Book Title Generator

[Try Demo](https://api.market/store/capix/title)

### Endpoints <a href="#endpoints" id="endpoints"></a>

`POST https://prod.api.market/v1/capix/title/generate/booktitle/v1/`

**Description**

This endpoint generates a title based on the provided description and mode. It is part of the Capix API version 2.

**Headers**

* x-api-market-key: (string) A required header for authentication. Replace `API_KEY` with your actual API key.
* `Content-Type`: (string) This should be set to `application/json` to indicate that the request body contains JSON data.

**Request Body**

The request body should be a JSON object with the following fields:

* `mode`: (string) The mode in which the title should be generated. Example values include `Formal`, `Casual`, etc.
* `description`: (string) A brief description that will be used to generate the title.

**Example Request Body**

```json
{
  "mode": "Formal",
  "description": "let us dive"
}
```

**Error Handling**

If the request is invalid or the token is missing/incorrect, the server will respond with an appropriate HTTP status code and a message indicating the error.

**Example Error Responses**

* `401 Unauthorized`

  ```json
  {
    "error": "Invalid token."
  }
  ```
* `400 Bad Request`

  ```json
  {
    "error": "Invalid request body."
  }
  ```

**Notes**

* Ensure that the `token` header contains a valid API key.
* The `mode` field should be one of the accepted values. Check the API documentation or contact support if you are unsure about the valid modes.
* The `description` field should be a concise and meaningful string to get the best results from the title generation.

### Code Examples <a href="#code-examples" id="code-examples"></a>

{% tabs %}
{% tab title="CURL" %}

```bash
curl -X 'POST' \
  'https://prod.api.market/api/v1/capix/title/generate/booktitle/v1/' \
  -H 'accept: application/json' \
  -H 'x-api-market-key: API_KEY' \
  -H 'Content-Type: application/x-www-form-urlencoded' \
  -d 'description=let%20us%20dive&mode=Formal'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests

headers = {
    'accept': 'application/json',
    'x-api-market-key': 'API_KEY',
    'Content-Type': 'application/x-www-form-urlencoded',
}

data = {
    'description': 'let us dive',
    'mode': 'Formal',
}

response = requests.post('https://prod.api.market/api/v1/capix/title/generate/booktitle/v1/', headers=headers, data=data)
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://prod.api.market/api/v1/capix/title/generate/booktitle/v1/');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'accept: application/json',
    'x-api-market-key: API_KEY',
    'Content-Type: application/x-www-form-urlencoded',
]);
curl_setopt($ch, CURLOPT_POSTFIELDS, 'description=let%20us%20dive&mode=Formal');

$response = curl_exec($ch);

curl_close($ch);
```

{% endtab %}

{% tab title="NodeJs" %}

```javascript
import axios from 'axios';

const response = await axios.post(
  'https://prod.api.market/api/v1/capix/title/generate/booktitle/v1/',
  new URLSearchParams({
    'description': 'let us dive',
    'mode': 'Formal'
  }),
  {
    headers: {
      'accept': 'application/json',
      'x-api-market-key': 'API_KEY'
    }
  }
);
```

{% endtab %}

{% tab title="Javascript" %}

```javascript
fetch('https://prod.api.market/api/v1/capix/title/generate/booktitle/v1/', {
  method: 'POST',
  headers: {
    'accept': 'application/json',
    'x-api-market-key': 'API_KEY'
  },
  body: new URLSearchParams({
    'description': 'let us dive',
    'mode': 'Formal'
  })
});
```

{% endtab %}
{% endtabs %}

**It returns response like this**

```json
{
    "titles":[
        "Journey of Echoes",
        " Whispered Reflections",
        " Depths Unveiled"
    ]
}
```


---

# 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.api.market/api-product-docs/capix-ai/book-title-generator.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.
