Upload data via API

This API is only available for selected users.

To add documents to a Data+Search node, you can call the following endpoint

https://stack-intext.onrender.com/index_data_api

This endpoint requires the following variables:

  1. flow_id: the id displayed on the url of your flow.

  2. node_id: the id of the node where to upload the data source (e.g. 'dataemb-0').

  3. org: your organization name.

Additionally, the request needs to be signed with the API key. The body must be a List of dictionaries with two keys:

  • 'title': the title of the data source.

  • 'text': the text of the data source.

Two data sources can have the same title and will be considered part of the same source. Example of usage:

Using Python

import requests

const FLOW_ID = ''
const NODE_ID = ''
const ORG_ID = ''
const PRIVATE_API_KEY = ''

# API endpoint URL
url = f"https://stack-intext.onrender.com/index_data_api?flow_id={FLOW_ID}&node_id={NODE_ID}&org={ORG_ID}"

# Request data
headers = {
    "Authorization": f"Bearer {PRIVATE_API_KEY}",
}

# Make the API request
data = [{'title': 'file 1', 'text': 'hello'}, {'title': 'file 2', 'text': 'hello'}]

response = requests.post(url, json=data, headers=headers)

# Check the response
if response.status_code == 200:
    print("API request successful")
else:
    print("API request failed:", response.text)

Using Javascript

Make sure to install the node-fetch library before running this code by executing the command npm install node-fetch.

const fetch = require('node-fetch');

const FLOW_ID = '';
const NODE_ID = '';
const ORG_ID = '';
const PRIVATE_API_KEY = '';

// API endpoint URL
const url = `https://stack-intext.onrender.com/index_data_api?flow_id=${FLOW_ID}&node_id=${NODE_ID}&org=${ORG_ID}`;

// Request data
const headers = {
  Authorization: `Bearer ${PRIVATE_API_KEY}`
};

// Make the API request
const data = [
  { title: 'file 1', text: 'hello' },
  { title: 'file 2', text: 'hello' }
];

fetch(url, {
  method: 'POST',
  headers,
  body: JSON.stringify(data)
})
  .then(response => {
    // Check the response
    if (response.status === 200) {
      console.log('API request successful');
    } else {
      console.log('API request failed:', response.statusText);
    }
  })
  .catch(error => {
    console.error('API request failed:', error);
  });

Last updated