Skip to main content

Inserting Data Through REST API Call

To add data to your HoppySearch index using a REST API call, follow these steps:

Step 1: Get the API Endpoint

Get API Endpoint

Step 2: Obtain the API Key with "Write" Access:

  • Open the desired index.
  • In the "Access Management" Tab, navigate to the "API Keys" section.
  • Copy a "write" API key for authentication purposes.

Option API Key

Step 3: Make the API Call:

  • Employ your preferred API client (e.g., cURL, Postman, or a programming language) to initiate a POST request to the acquired API endpoint.
  • Api endpoint: yourEndpoint/v1/index
  • Set the following request header:
    • Key: "Authorization"
    • Value: Your API key
  • In the request body, furnish your data in JSON format. Below is an example structure:
{
"documents": [
{
"Id": 12,
"ProductId": "B001M1L12M",
"UserId": "A27KQ4QYY0O334",
"ProfileName": "R. Strom",
"HelpfulnessNumerator": 0,
"HelpfulnessDenominator": 0,
"Score": 5,
"Time": 1258502400,
"Summary": "super black does the job",
"Text": "As with the Americolor red, red, super black works exceptionally well."
},
// Add more records as needed...
],
"config": {
"type": "append"
}
}
  • Ensure you specify the operation type in the "config" section:
    • For a complete replacement of existing data, set "type" to "replace" (which will clear all previously existing data).
    • To append new data to existing records, set "type" to "append" (this will add to existing data if any is present).

Step 4: Send the Request

  • Execute the API call utilizing your chosen tool or programming language.

By following these straightforward steps, you can seamlessly insert data into your HoppySearch index via a REST API call. Remember to replace the example data with your actual dataset for a successful data insertion process.


To simplify the process further, you can access our Swagger documentation and Postman collection:

How to Get Swagger Documentation and Postman Collection:

  • Visit the HoppySearch Indices page.

  • Select the desired index.

  • Click on the swagger icon to obtain the Swagger documentation. Option API Key

  • Click on the Postman icon to access the Postman collection. Option API Key