REST API

The Web Services module provides a REST API for searching, storing and updating documents in a data store.

To add the Web Services module to your application, ensure that this dependency is referenced in your Maven project (pom.xml):

<!-- Web services module -->
<dependency>
    <groupId>twigkit</groupId>
    <artifactId>twigkit.webservices</artifactId>
    <version>${project.parent.version}</version>
</dependency>

Check out these pages for more details about specific REST APIs:

REST API URL format

A REST API URL is made up of these components:

host-name/REST-method/platform?query-string

The platform configuration name is the same platform configuration reference that you would use in your search page as a reference to an Appkit platform tag, for example, conf="platforms.gsa". So, if you were running an Appkit app locally, you would use a URL like:

http://localhost:8080/twigkit/api/core/services/platform/search/platforms.gsa

Example

This GET request submits a search query, given by HTTP query parameters, to the given platform.

http://localhost:8080/twigkit/api/core/services/platform/search/platforms.gsa?q=mydocument

In response to this request, Appkit would return an Appkit response object (with associated query, hits,results and facets) as XML.

Choosing a data format

All REST resources support both XML and JSON response formats, with XML being the default. To request a JSON response, the "Accept" header of the HTTP request for a particular REST resource should be set to "application/json". For example:

GET /twigkit/api/social/myrequest HTTP/1.1
Accept: application/json
...