The SearchBlox REST-API enables the indexing and searching of custom content using simple HTTP POST and GET actions. The REST-API can add and delete documents from Custom, HTTP and File Collections only.

SearchBlox REST-API provides methods for working with standard and custom collections by means of REST requests with JSON payloads. Index, delete, clear and check the status of custom collections, or create new custom collections using REST-API. Individual documents can also be added or deleted in HTTP and file collections.

# **SearchBlox Development Environment**

The SearchBlox Development Environment otherwise known as **API Explorer** is a simple browser-based tool designed to help developers use the SearchBlox REST-API with minimal effort. This tool is part of the SearchBlox deployment and can be accessed here: [https://localhost:8443/api](🔗). SearchBlox's API Explorer supports REST-JSON API.

POSTMAN is another external third-party tool that can be used with Searchblox JSON API. The settings for POSTMAN API can be found at the end of this documentation. For more details on the POSTMAN API tool, refer to [https://www.getpostman.com](🔗).

# **Index**

## Index URL

REST-JSON API https://localhost:8443/rest/v2/api/add

## Method

POST

## Media Type

REST-JSON API application/json

## Headers

SB-PKEY LmfxTTDSeYxHTntJMHuhwRrGVICMaVN/wl/zPuQ3LtQDNRMnng5GpKIkgt0q1rCC/h6wDA==

## Document Syntax

REST-JSON API



## Document Description

JSON keyAttributeValue
apikey
API key from https://localhost:8443/console?page=admin&tab=license.
documentcolnameName of the custom collection.
documentLocationValue of file location (URL or file path)
documenturlURL value to be returned with search results.
documentuidAssigned unique identifier for a document (the URL is used as uid when unassigned).
documenttitleTitle value of search results.

keywordsKeyword value of document.

contentContent of document.

descriptionDescription of search result.

lastmodifiedDate in format 07 May 2015 06:19:42 GMT.

sizeSize value.

alphaText value for sorting.

contenttypeType of content value (HTML, PDF, etc.,).

urllenlength
meta
meta fields to be updated

## Response Codes

JSON

codeDescription
100Document indexed successfully
101Document indexing failed
501Collection not found
502Invalid Document URL/Location

# **Update Meta Data**

## updatemetadata URL

REST-JSON API https://localhost:8443/rest/v2/api/updatemetadata

## Method

POST

## Media Type

REST-JSON API application/json

## Headers

SB-PKEY LmfxTTDSeYxHTntJMHuhwRrGVICMaVN/wl/zPuQ3LtQDNRMnng5GpKIkgt0q1rCC/h6wDA==

## Document Syntax

REST-JSON API



## Document Description

JSON AttributeDescription
apikeyAPI key from https://localhost:8443/console?page=admin&tab=license.
colnameName of the collection
urlURL value to be returned with search results.
meta fieldscustom fields

## Response Codes

CodeDescription
7000Meta Data updated successfully
7001Meta Data update failed
601API key is not found/invalid
7003Document not found

# **Delete**

This is to delete documents only in a custom collection

## Delete URL

REST-JSON API https://localhost:8443/rest/v2/api/delete

## Method

POST

## Media Type

REST-JSON API application/json

## Headers

SB-PKEY LmfxTTDSeYxHTntJMHuhwRrGVICMaVN/wl/zPuQ3LtQDNRMnng5GpKIkgt0q1rCC/h6wDA==

## Document Syntax

REST-JSON API



# Document Description

JSON keyAttributeValue
apikey
API key from https://localhost:8443/console?page=admin&tab=license.
documentcolnameName of the custom collection.
documentuidValue of unique identifier (file location or URL).

## Response Codes

JSON

Column Title
Column Title
2001Document Deleted Successfully
2002Document requested for deletion does not exist.
501Invalid Collection Name

# **Document Status**

## Status URL

REST-JSON API https://localhost:8443/rest/v2/api/status

## Method

POST

## Media Type

REST-JSON API application/json

## Headers

SB-PKEY LmfxTTDSeYxHTntJMHuhwRrGVICMaVN/wl/zPuQ3LtQDNRMnng5GpKIkgt0q1rCC/h6wDA==

## Document Syntax

REST-JSON API



## Document Description

JSON TagAttributeValue
apikey
API key from https://localhost:8443/console?page=admin&tab=license.
documentcolnameName of the custom collection.
documentuidValue of unique identifier (URL or file location)

## Response Codes

JSON

Column Title
Column Title
301Document not found

# **Clear Collection**

## Clear URL

REST-JSON API https://localhost:8443/rest/v2/api/clear

## Method

POST

## Media Type

REST-JSON API application/json

## Headers

SB-PKEY LmfxTTDSeYxHTntJMHuhwRrGVICMaVN/wl/zPuQ3LtQDNRMnng5GpKIkgt0q1rCC/h6wDA==

## Document Syntax

REST-JSON API



## Document Description

JSON TagAttributeValue
apikey
API key from https://localhost:8443/console?page=admin&tab=license.
documentcolnameName of the custom collection.

## Response

JSON

Column Title
Column Title
400Collection has been cleared successfully
501Collection not found

# **Add collection**

You can add a new custom collection through REST-API using JSON payload using the details provided here.

## Add Collection URL

REST-JSON API https://localhost:8443/rest/v2/api/coladd

## Method

POST

## Media Type

REST-JSON API application/json

## Headers

SB-PKEY LmfxTTDSeYxHTntJMHuhwRrGVICMaVN/wl/zPuQ3LtQDNRMnng5GpKIkgt0q1rCC/h6wDA==

## Document Syntax

REST-JSON API



## Document Description

JSON KeyAttributeValue
documentcolnameName of the custom collection.

languageLanguage of the collection specified in standard two letter code. https://developer.searchblox.com/docs/supported-languages

coltypeType of collection.
publicpublicCollection access type either true or false. If "true", then access type is "public". If "false", then access type is "private"
encryptencryptCollection encryption either true or false.

## Response Codes

JSON

Column Title
Column Title
900Custom collection with name \<colname\> has been created
400Failed creating custom collection

# **Delete Collection**

You can delete existing custom collections through REST-API using JSON payload using the details given here.

## Delete Collection URL

REST-JSON API https://localhost:8443/rest/v2/api/coldelete

## Method

POST

## Media Type

REST-JSON API application/json

## Headers

SB-PKEY LmfxTTDSeYxHTntJMHuhwRrGVICMaVN/wl/zPuQ3LtQDNRMnng5GpKIkgt0q1rCC/h6wDA==

## Document Syntax

REST-JSON API



## Document Description

JSON TagAttributeValue
apikey
API key from https://localhost:8443/console?page=admin&tab=license.
documentcolnameName of the custom collection.

## Response

JSON

Column Title
Column Title
800Custom collection with name \<colname\> has been deleted.
501Collection does not exist

# **Add/Update Document**

You can add documents to an HTTP collection or File collection through REST-API using JSON payload using the details given here.

## Add/update Document URL

REST-JSON API https://localhost:8443/rest/v2/api/docadd

## Method

POST

## Media Type

REST-JSON API application/json

## Headers

SB-PKEY LmfxTTDSeYxHTntJMHuhwRrGVICMaVN/wl/zPuQ3LtQDNRMnng5GpKIkgt0q1rCC/h6wDA==

## Document Syntax

REST-JSON API



## Document Description

JSON TagAttributeValue
searchbloxapikeyAPI key from https://localhost:8443/console?page=admin&tab=license.
documentcolnameName of the Http or file collection.
documentlocationValue of file location (URL or file location)

## Response

JSON

Column Title
Column Title
1001Document has been added/updated successfully
1002Document add/update failed
501Collection not found

# **Delete Document**

You can delete documents from an HTTP collection or File collection through REST-API from the Delete Document tab in API, using the JSON code given in the following Document Syntax section.

## Delete Document URL

REST-JSON API https://localhost:8443/rest/v2/api/docdelete

## Method

POST

## Media Type

REST-JSON API application/json

## Headers

SB-PKEY LmfxTTDSeYxHTntJMHuhwRrGVICMaVN/wl/zPuQ3LtQDNRMnng5GpKIkgt0q1rCC/h6wDA==

## Document Syntax

REST-JSON API



## Document Description

JSON TagAttributeValue
documentcolnameName of the HTTP or file collection.
documentlocationValue of file location (URL or file location)

## Response

JSON

Column Title
Column Title
2001Document Deleted Successfully
502Invalid Document Location
501Collection not found

# **Response Codes**

## Document Syntax



## Status Code Description

Column Title
Column Title
100Document indexed successfully
101Document indexing failed
2001Document Deleted Successfully
2002Document delete failed.
301Document Not Found
400Collection has been cleared successfully
401Clearing collection failed
501Collection not found
501Invalid Request
502Invalid Document Location
503Specified collection is not a CUSTOM collection.
506Invalid Document UID
800Custom collection with name <colname> has been deleted.
900Custom collection with name <colname> has been created
1001Document Added Successfully
1002Document Couldn't Be Reached
2001Document Deleted Successfully
2002Specified collection is not a custom collection.

# **Settings in POSTMAN API**

Postman API is a third-party tool that can be used with SearchBlox API. The prerequisite settings that are required to work with SearchBlox API are as follows:

  1. URL to be given for each API function as mentioned under each function in the preceding documentation.

  2. Method to be selected is POST for all functions.

  3. Header to be added is Content-Type, which has to be given as a header. The value for the header for JSON API is application/json. This could be also done by selecting the dropdown JSON as required.

  4. Header parameter to be added is SB-PKEY. Value can be found in the Admin Users List for Super Admin and Admin users.

The screenshots JSON API on settings and result are given here. Select raw to view the status code for JSON API. ##JSON API POSTMAN settings

1011