> ## Documentation Index
> Fetch the complete documentation index at: https://doc.lucidworks.com/llms.txt
> Use this file to discover all available pages before exploring further.

# REST API examples

> Frontend development

export const LwTemplate = ({title = "Key questions to get you started", icon = "sparkles", cta = "Powered by Agent Studio", linkHref = "https://lucidworks.com/demo/?utm_source=docs&utm_medium=referral&utm_campaign=docs_cta_ai"}) => {
  const [isLoaded, setIsLoaded] = useState(false);
  useEffect(() => {
    const timer = setTimeout(() => {
      setIsLoaded(true);
    }, 500);
    return () => clearTimeout(timer);
  }, []);
  return <div className="lw-template-container">
      <Card title={title} icon={icon}>
        {isLoaded && <span dangerouslySetInnerHTML={{
    __html: `<lw-template id="a029c1a9-28be-427e-b0e1-5d918920246a"></lw-template
            >`
  }} />}
        <Link href={linkHref} className="agent-studio-link text-left text-gray-600 gap-2 dark:text-gray-400 text-sm font-medium flex flex-row items-center hover:text-primary dark:hover:text-primary-light group-hover:text-primary group-hover:dark:text-primary-light">Powered by Lucidworks Agent Studio</Link>
      </Card>
    </div>;
};

[localhost link]: http://localhost:3000/docs/lucidworks-search/09-developer-documentation/frontend-development/api-examples-frontend

[mintlify link]: https://doc.lucidworks.com/docs/lucidworks-search/09-developer-documentation/frontend-development/api-examples-frontend

[old doc.lw link]: https://doc.lucidworks.com/managed-fusion/5.9/ewzmy0

This document provides examples of queries and calls that may be useful for frontend development of your application.

<LwTemplate />

## Prerequisites

Before working with the Lucidworks Search API, ensure that you have specified API [permissions](/docs/lucidworks-search/08-administration/access-control/permissions) or [roles](/docs/lucidworks-search/08-administration/access-control/roles) to allow access to the API.

## Simple queries

### Send signals to Lucidworks Search from frontend applications

The Signals API stores signals as JSON for indexing into a signals collection. See [Signals API](/api-reference/signal-indexing-api/index-an-event-signal) for more information.

**REQUEST**

```sh wrap  theme={"dark"}
https://EXAMPLE_COMPANY.lucidworks.cloud/api/signals/COLLECTION_NAME
```

<Note>
  Replace `EXAMPLE_COMPANY` with the name provided by your Lucidworks representative.
</Note>

**ENDPOINTS**

|                               |                                       |   |
| ----------------------------- | ------------------------------------- | - |
| **POST**                      |                                       |   |
| **/signals/COLLECTION\_NAME** | Send one or more signals for indexing |   |

**PARAMETERS**

|              |            |                                                                                                                                                                                   |
| ------------ | ---------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `commit`     | `optional` | The `commit` parameter can potentially cause resource problems if your application has a high signal volume, or if it sends all signals as individual POST requests in real-time. |
| `collection` | `required` | Collection ID                                                                                                                                                                     |
| `params`     | `optional` | Configuration parameters  For more information, see [Parallel Bulk Loader](/docs/lucidworks-search/09-developer-documentation/config-specs/jobs/parallel-bulk-loader).            |

**EXAMPLE**

```sh wrap  expandable  theme={"dark"}
curl \
 -u USERNAME:PASSWORD -X POST -H 'Content-type:application/json' -d @- \
https://EXAMPLE_COMPANY.lucidworks.cloud/api/signals/docs?commit=true \
<<EOF
[{
    "params": {
      "query": "Televisiones Panasonic  50 pulgadas",
      "filterQueries": ["cat00000", "abcat0100000", "abcat0101000", "abcat0101001"],
      "docId": "2125233"
    },
    "type": "click",
    "timestamp": "2011-09-01T23:44:52.53Z"
  },
  {
    "params": {
      "query": "Sharp",
      "filterQueries": ["cat00000", "abcat0100000", "abcat0101000", "abcat0101001"],
      "docId": "2009324"
    },
    "type": "click",
    "timestamp": "2011-09-05T12:25:37.42Z"
  }
]
EOF
```

### Send queries to Lucidworks Search using the Query Profile

**REQUEST**

```sh wrap  theme={"dark"}
https://EXAMPLE_COMPANY.lucidworks.cloud/api/apps/APP_NAME/query/QUERY_PROFILE?QUERY
```

**ENDPOINTS**

|                               |                                       |   |
| ----------------------------- | ------------------------------------- | - |
| **POST**                      |                                       |   |
| **/signals/COLLECTION\_NAME** | Send one or more signals for indexing |   |

**PARAMETERS**

|        |            |                                                                |
| ------ | ---------- | -------------------------------------------------------------- |
| `rows` | `optional` | The number of documents (results) to return                    |
| `wt`   | `required` | The response format. For example, XML, JSON, CSV               |
| `fl`   | `optional` | The list of fields to return for each document in the response |

**EXAMPLE**

```sh wrap  theme={"dark"}
https://EXAMPLE_COMPANY.lucidworks.cloud/api/apps/Movies/query/Movies_main?q=star&fq=genres_ss:(“Sci-Fi”)&rows=5
```

## Complex queries

### Call the query profiles assigned to a zone

The Render API is part of the [Templating API](/api-reference/templates-controller/get-template-information). It is the main way to ingest the content of templates and their contained zones, which will further drive the search experience. Templates/zones data cannot be incorporated with the [Query Profile](/api-reference/query-profiles-crud-api/get-the-service-status) or [Query Pipelines](/api-reference/query-pipelines-api/get-all-query-pipelines)APIs.

You can create templates in the Lucidworks Search UI, specifying trigger criteria for each template, such as search terms or filters. You can then add zones to these templates, choosing a query profile to be queried for each zone along with other configurable data. When you query the Render API, Lucidworks Search determines which template’s trigger criteria is satisfied by the query and calls the query profiles designated by the zones in the triggered template, passing the original query on to each query profile. The results from each query profile are returned alongside the zone configuration in the final response.

For example, a web frontend can consume this API to drive a search results page. It will inspect the list of returned zones, using each zone’s configuration to decide how to display each query profile result in the UI. This allows you to manage the search experience with the Lucidworks Search UI, using the template trigger criteria and zone configuration along with different query profiles to define what content should be shown based on the search context.

Templates and zones have both a "staging" and "live" (or "published") version. The staging parameter present on all Render API endpoints determines the version of the content that will be used. Modifications to the templating content only show in the "staging" view until you publish the content.

The Render API works similarly to the Query API in that it supports all of the same ways of providing a query, and the responses for each zone are the same structure. However, there are four differences:

* You do not need to specify a query profile in your request
* The endpoint paths are different
* The Render API determines which template to trigger based on the query terms, filters, and the templates' configurations
* The provided query is issued against one or more query profiles (one for each zone in the triggered template), and the response from each query profile is included in the Render API response.

See [Query Profile API](/api-reference/query-profiles-crud-api/get-the-service-status) for more information.

**REQUEST**

```sh wrap  theme={"dark"}
https://EXAMPLE_COMPANY.lucidworks.cloud/api/templating/render/APP_NAME
```

<Tip>
  See [Templating API](/api-reference/templates-controller/get-template-information) for more supported parameters.
</Tip>

**ENDPOINTS**

|                               |                                                                                                                                                                                                                                                                                                                                              |   |
| ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | - |
| **GET**                       |                                                                                                                                                                                                                                                                                                                                              |   |
| **/render/APP\_NAME**         | Retrieve and render the template for the given navigation state. By default will only trigger published versions of templates, specify staging=true to instead trigger staging versions of templates.                                                                                                                                        |   |
| **/renderId/TEMPLATE\_ID**    | Retrieve and render the template with the specified id. All provided query params will be passed on to each query profile invoked during the rendering.                                                                                                                                                                                      |   |
| **POST**                      |                                                                                                                                                                                                                                                                                                                                              |   |
| **/render/APP\_NAME**         | Retrieve and render the template for the given navigation state. By default will only trigger published versions of templates, specify staging=true to instead trigger staging versions of templates.                                                                                                                                        |   |
| **/renderDSL/APP\_NAME**      | Retrieve and render the template for the given navigation state. By default will only trigger published versions of templates, specify staging=true to instead trigger staging versions of templates. The provided DSL request object + any additional request parameters are passed through to each query profile when rendering each zone. |   |
| **/renderId/TEMPLATE\_ID**    | Retrieve and render the template with the specified id. All provided query params will be passed on to each query profile invoked during rendering.                                                                                                                                                                                          |   |
| **/renderIdDSL/TEMPLATE\_ID** | Retrieve and render the template with the specified id, passing the provided DSL request to each query profile invoked during rendering.                                                                                                                                                                                                     |   |

**EXAMPLE**
The example query specifies `some query` as the query terms and is restricted to only return templates of the `landing` type. It will retrieve the template with trigger criteria that is satisfied by the query terms `some query`.

By specifying `staging=true`, it will only consider the current "staging" version of the templating content, which are templates/zones that haven’t been published yet. Omitting the staging param would return only the published versions of templates/zones.

```sh wrap  theme={"dark"}
GET https://EXAMPLE_COMPANY.lucidworks.cloud/api/templating/render/APP_NAME?q=QUERY&templateTypes=landing&staging=true
```
