# Introduction

Introduction and Purpose

<div align="center" data-full-width="false"><figure><img src="https://2504884376-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2XvM20D6UGNsIleTYXFU%2Fuploads%2FJYR53dBhHzn77gOqtfrw%2F968abea1-778c-43cf-85f9-a80455ac6661.jpg?alt=media&amp;token=f26eb660-d29d-4094-b265-3b0e1f991362" alt=""><figcaption><p>Mindplug - Make it smart</p></figcaption></figure></div>

Mindplug is the simplest no-code solution for generating and managing semantic data for your application. At its core, it allows applications to store data based on context and retrieve data based on meaning.

Mindplug is crafted by the team at Exper Labs. We innovate and deliver cool products to showcase the advancement of technology and allow people from around the world to be inspired from its use cases.

With over 1.15 Trillion Megabytes of data being created every single day around the world, finding the correct information easily and efficiently is becoming harder and harder. The relevancy of search results fades as more noise is presented across the internet. The faded accuracy is further amplified through unverified data which often proves to be biased.

As consumers of this data, we must efficiently parse through different resources to identify the most accurate answers. This is easier said than done as going through long threads, pages of documents, and endless YouTube videos slows our learning towards the right things. Most our time is spent filtering through the endless content to identify the most relevant results, identifying specific sections and further breaking down the content for our better understanding.

With the latest AI breakthroughs, the new technology could now be leveraged to help us better filter through our increasing amount of content for our personal and business needs. AI efficiently deciphers the meaning of text or the words being spoken in a video. We leverage that at Mindplug to create the simplest interface between artificial intelligence and our everyday lives.

***

### What is [Mindplug](https://mindplug.io)? 🤔

Mindplug is an API service allowing integration of semantic search in any application within minutes. It provides a high level interface to generating and managing embeddings easily through combining different technologies.&#x20;

Mindplug is an essential service for people looking to move fast with cutting edge technology. Currently hosted plans are able to support small to medium sized organizations. We're working on hosted enterprise plans that will soon be released in the future.

For those who want extra control of their data and like working at the low-level, we also allow the users to bring their own API keys for the services we use. This way, Mindplug can be used as an interface to interact with user's existing data.

Mindplug provides a pre-built frontend dashboard for the API that can be used to generate and manage embeddings. This is best for those looking for a no-code solution for their data. We're working on integrations between Mindplug and [ExperAI](https://experai.com), our chatbot application.

To maximize the use cases, Mindplug allows users to embed data from multiple file types including PDF, Web, Docs and even YouTube videos. We take care of all the technical details to provide the best quality embeddings and the most relevant results to your search query.

Our vision is to inspire people from around the world to be fascinated through this technology. To support this, we've kept our pricing plans fairly lenient with abilities to store up to 300 vectors for free. With our pre-processing, this is enough storage for a 30 page pdf document. We believe this is enough storage for anybody to get started with semantic search on any data.

A very minor list of use-cases for using the Mindplug API include:&#x20;

1. Long-term memory for conversational chat bots
2. Searching books and manuals by meaning of query
3. Searching customer databases
4. Quickly parsing through information in videos
5. Creating conversational chatbots for any website instantly.
6. Generating long-term friends which develop personality over time.
7. Generating AI customer support bots for your website


# How does it work?

Integration and Fetching Data

<figure><img src="https://2504884376-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F2XvM20D6UGNsIleTYXFU%2Fuploads%2F6b6X5GQdcqfXAy1rOiH1%2F9469c761-63cc-4b04-887e-5fc2fe5cdc82.jpg?alt=media&amp;token=3064ebc1-b62e-4341-8b3c-9c40d7d6687c" alt=""><figcaption><p>Inner workings of Mindplug</p></figcaption></figure>

Mindplug is built using OpenAI to generate embeddings, and Pinecone, to store the embedding data. To allow for efficient data storage, these technologies are combined with Supabase to keep track of the stored objects. Supabase stores the vector ids which allows Mindplug to effciently retrieve vectors from any collection. A deeper use case is these ids will allow Mindplug to do easily export out vector data from any collection.&#x20;

Mindplug is designed with transparency and data ownership on mind. We do not take control of your data, but rather help you interface with it. You can export out your data at any time easily soon in the future.&#x20;

Storing plain text is a simple process which uses OpenAI to generate embeddings, Pinecone to store them and Supabase to track them. For interfacing with data from different sources such as PDFs and webpages, the data must first be converted into plain text.

For converting PDFs into plain text, Langchain's PDF interface is utilized to return all text on each page of the PDF. For webpages, we use playwright to crawl and extract the data. These methods efficient and scalable.

Before generating embeddings for this data, it is first chunked or split into smaller objects. To ensure each object keeps full context of the text being embedding, recursive splitting from Langchain is used. This type of splitting has shown to generate best results overall through different contexts. By default, the chunk size is 1024 for all sources. This size has shown to preserve the best context for differ sources.

Our goal is to allow everyone around the world to experience the power of embeddings. Thus we provide free storage for the starting plan. Given the 1024 chunk size, this is easily enough for anyone to embed a few websites and articles.

Why 1024? On some websites, the information is sparse and spread out on the page. Generating more detailed vectors on such data results in loss of meaning of data. The same is true for plain text and pdf data. The broad context is well suited for a large amount of use cases while the narrow context storage is only best for specific use cases only. The narrow context storage works best on a small set of data which is pre-processed for a specific use case. In the future, maybe we will explore use cases for dynamic sizing of data at 256, 512 chunk size.

Using this chunked data, model 'text-embedding-ada-002' from OpenAI is used to chunk the embeddings into a vector size of 1536. These embeddings are then uploaded to Pinecone with an auto generated unique id for each of the embedding object. After uploading, these embeddings are then stored in Supabase.

All these process happens in the backend of Mindplug, which is available as an API to the public. The snippets of the sudo-code for each endpoint are provided in the docs for a better user understanding of data.

### Minimizing costs for storing data 🪙

Mindplug uses Pinecone. How do we minimize costs to provide the best user experience?&#x20;

Pinecone is a vector database that charges per index. An index is a type of storage that supports different projects. Each project can further be sub-divided by namespaces. The projects run on a server called a pod. There are different tiers for the pods, optimized for different use cases. In our case, we optimize for storage, using S1 pods, given the users may upload an arbitrary amount of data.&#x20;

On this S1 pod, Mindplug automatically creates an index called Mindplug. The projects and collections in your account are living in a shared space in this S1 pod, divided by the namespaces for each specific user. This allows Mindplug to utilize the most of amount of space per index, avoiding the creation of additional pods thus charges.

Pinecone automatically encrypts data for its embeddings. Please see Pinecone's security policy on how your embedding data is treated: <https://www.pinecone.io/security/>. Although this is the case, the data lives in a shared space for different users. This data is not utilized for any other purpose other than to complete the user API requests.


# JavaScript SDK

Mindplug is the easiest solution to creating and managing embeddings. Add long term memory to your LLMs, perform semantic data analysis and easily filter data based on metadata. Connect your app to external web sources using our smart endpoint.

### <mark style="color:purple;">Install Mindplug</mark>

NPM:

```
npm install mindplug
```

yarn:

```
yarn add mindplug
```

### <mark style="color:purple;">Initialize Mindplug</mark>

Obtain an API key from [Mindplug](https://mindplug.io/) dashboard.

```
import Mindplug from 'mindplug';
const mindplug = new Mindplug({mindplugKey: <SAMPLE KEY>});
```

If you don't yet have access, please [book an onboarding call](https://calendly.com/cheraamritpal/30min).

### <mark style="color:purple;">Store Data</mark>

**All storage of data requires a db and a collection.**

Store text. Requires content

```
mindplug.store({
  db: "first database",
  collection: "any collection",
  content: "hello, sample text to store",
});
```

Store PDF file. Requires an object of type File under 50MB

```
mindplug.storePDF({
  db: "first database",
  collection: "any collection",
  file: <SAMPLE FILE>
});
```

Store webpage. Requires the webpage url

```
mindplug.storeWeb({
  db: "first database",
  collection: "any collection",
  url: "https://mindplug.io"
});
```

Store audio. Requires a MP3 or WAV file under 20MB

```
// must pass an openaiKey to constructor
mindplug.storeAudio({
  db: "first database",
  collection: "any collection",
  file: <SAMPLE FILE> 
});
```

**Storing - Advanced Techniques**

A `metadata` of type JSON and a `chunkSize` of type number may also be passed to each storage function. Metadata is used to easily filter for data. Chunk size is used to split large data into smaller batches. By default the data is split in about 1024 character chunks.

```
mindplug.store({
  db: "first database",
  collection: "any collection",
  content: "hello, sample text to store",
  metadata: {
    purpose: "to learn"
  },
  chunkSize: 512
});
```

###

### <mark style="color:purple;">Query Data</mark>

Semantic search. Search stored data by meaning of text.

```
mindplug.query({
  db: "first database",
  collection: "any collection",
  search: "What fruit is in the fridge?"
});
```

Query by vector ids.

```
mindplug.queryByIds({
  db: "first database",
  collection: "any collection",
  vectorIds: ["ID-1", "ID-2"]
});
```

Query by collection. Returns the recent 10 vectors from the collection.

```
mindplug.queryByCollection({
  db: "first database",
  collection: "any collection"
});
```

**Query - Advanced Techniques**

By default, mindplug returns the 3 best matches for the searched data. You can change this by passing a `count` parameter. You can also filter the stored data based on metadata by passing in a `metadataFilters` parameter.

```
mindplug.query({
  db: "first database",
  collection: "any collection",
  search: "What are the benefits of Solana blockchain?",
  metadataFilters: {
    genre: ["technology", "blockchain"]
  },
  count: 1
});
```

For more information on using metadataFilters, please see our API [documentation](https://docs.mindplug.io/api/query/using-metadata-filters)

####

### <mark style="color:purple;">Delete data</mark>

Delete by vector ids.

```
mindplug.deleteByIds({
  db: "first database",
  collection: "any collection",
  vectorIds: ["ID-1", "ID-2"]
});
```

Delete by upload id. Upload id is returned every time new data is stored

```
mindplug.deleteByUploadId({
  db: "first database",
  collection: "any collection",
  uploadId: "UPLOAD-ID"
});
```

Delete collection. Also deletes all vectors stored within.

```
mindplug.deleteCollection({
  db: "first database",
  collection: "any collection"
});
```

Delete project. Also deletes all collections and vectors stored within.

```
mindplug.deleteProject({
  db: "first database"
});
```

####

### <mark style="color:purple;">List data</mark>

List Collections.

```
mindplug.listCollections({
  db: "first database"
});
```

List projects.

```
mindplug.listProjects();
```

### <mark style="color:purple;">Smart Google Search</mark>

Google search from select sources.

```
mindplug.searchWeb({
  search: "How to cook pasta?"
});
```

You can easily manage all your data in the Mindplug dashboard.

### <mark style="color:purple;">Smart - Parsing Webpage</mark>

Get all text from a webpage given its URL.

```
mindplug.parseWebpage({
  url: "https://mindplug.io"
});
```

Returns all text on the webpage.


# API

Mindplug API Key

Mindplug follows a REST API architecture which can be universally used in any language for any application.

Using the raw API ensures the fastest updates for new and existing endpoints. All the endpoints are listed in this documentation and use axios for making the call requests to Mindplug servers.

The documentation architecture:

## Setup

[**API Setup - Base**](/api/api-setup-text)

* Base instance for axios used to interact with text storage and web.

[**API Setup - PDFs**](/api/api-setup-pdfs)

* Base instance for axios used to interact with PDF files

[**API Setup - Audio**](/api/api-setup-audio)

* Base instance for axios used to interact with audio

## Storing Data

[**Store basic text**](/api/storing-data)

* Store basic text content given a string value.

[**Store PDF files**](/api/store-pdf)

* To store files, you need a form instance for axios to pass formData.

[**Store webpage**](/api/store-web)

* Pass in a URL for mindplug to crawl and read.

## Query Data

[**Query - semantic search**](/api/query)

* To semantic search on stored data. Seach by meaning of text.

[**Query by vector ids**](/api/query-by-ids)

* Search specific vectors by their ids

[**Query by collection**](/api/query-by-collection)

* Returns the recent 10 vectors from a given collection

## Delete Data

[**Delete by vector ids**](/api/delete-by-ids)

* Delete specific data based on vector ids

[**Delete collection**](/api/delete-collection)

* Delete an entire collection, including all stored vectors within.

[**Delete Project**](/api/delete-project)

* Delete an entire project, including all collections and vectors within.

## List Data

[**List projects**](/api/list-projects)

* List all the projects you have on Mindplug

[**List collections**](/api/list-collections)

* List all the collections you have on Mindplug

## Smart

[**Web search**](/api/search-web)

* Returns the top 3 google results from select resources

###


# API Setup - Text

Required for Mindplug API access

### Base Instance

In this setup, we will use [axios](https://www.npmjs.com/package/axios) which is an industry standard package for making API calls.

It is recommended to create a base instance of axios which utilizes your mindplug key in one file. This makes it easier to manage for the future. The file can be stored anywhere within the src directory.&#x20;

{% code title="src/mindplugAPI.ts" overflow="wrap" lineNumbers="true" %}

```javascript
// Axios instance with mindplug auth
import axios from 'axios';

const mindplug = axios.create({
    baseURL: "https://connect.mindplug.io/api",
    headers: {
        "Content-Type": "application/json",
        "Authorization": "Bearer <MINDPLUG_KEY>"
    }
});

 export default mindplug; 
```

{% endcode %}


# API Setup - Audio

### Base Instance

This instance is the exact same as the text instance. Mindplug requires you to perform audio transcription on the client side and does not handle it server side. To perform transcription, the easiest method is to use Whisper from OpenAI. It takes in an audio file and returns a text string of all the audio content.

The steps for creating an audio transcription from audio files are outlined in the subpage.

{% code title="src/mindplugAPI.ts" overflow="wrap" lineNumbers="true" %}

```javascript
// Axios instance with mindplug auth
import axios from 'axios';

const mindplug = axios.create({
    baseURL: "https://connect.mindplug.io/api",
    headers: {
        "Content-Type": "application/json",
        "Authorization": "Bearer <MINDPLUG_KEY>"
    }
});

 export default mindplug; 
```

{% endcode %}


# Performing Transcription

## 1. Setup OpenAI Key

It's base to generate a base instance for OpenAI using the secret key. To do this, create a file named openai.ts and copy the following code within it:

<pre class="language-typescript"><code class="lang-typescript"><strong>import Bottleneck from 'bottleneck';
</strong>import { Configuration, OpenAIApi } from 'openai';

class CustomFormData extends FormData {
  getHeaders() {
      return {}
  }
}

// helps with rate limits
export const limiterOpenai = new Bottleneck({
  maxConcurrent: 1,
  minTime: 50
});

const configuration = new Configuration({
  apiKey: process.env.NEXT_PUBLIC_OPENAI_API_KEY,
  formDataCtor: CustomFormData
});

const openai = new OpenAIApi(configuration);

export default openai;
</code></pre>

## 2. Generate Transcription

Generating the transcription is now is as a one-liner 😄

```typescript
const response = await openai.createTranscription(file, 'whisper-1', undefined, 'json', 1, 'en');
```

The file here is the audio file to create the transcription for. There are multiple ways to read the file, on web you can simply have an input and set type to file as:

```typescript

const onChangeHandler = async (event) => {
    const file: File = event.target.files[0];
    setFile(file);
};

 
<input accept=".mp3,.wav" onChange={onChangeHandler} type="file" />
```


# API Setup - PDFs

Setup PDF upload to Mindplug

### Base Instance

In this setup, we will use [axios](https://www.npmjs.com/package/axios) which is an industry standard package for making API calls.

It is recommended to create a base instance of axios which utilizes your mindplug key in one file. This makes it easier to manage for the future. The file can be stored anywhere within the src directory.&#x20;

This instance is the same as the Text instance with only difference being in the headers.

{% code title="src/mindplugAPI.ts" overflow="wrap" lineNumbers="true" %}

```javascript
// Axios instance with mindplug auth
import axios from 'axios';

const mindplug = axios.create({
    baseURL: "https://connect.mindplug.io/api",
    headers: {
        "Content-Type": "multipart/form-data",
        "Authorization": "Bearer <MINDPLUG_KEY>"
    }
});

 export default mindplug; 
```

{% endcode %}


# Storing Data

### Prerequisites

Requires a user auth token. See the [API Auth](/api/api-setup-text) section.

### Storing data - API

For now Mindplug handles the storing of text data only. You can store data given the following parameters:&#x20;

1. Database name: `db`
2. A collection name: `collection`
3. An text string to generate embedding for: `content`
4. `Metadata` which is any arbitrary object for the content
5. OPTIONAL: `chunkSize`
   1. Defaults to 1024. Represents the amount of characters stored per embedding. If you give content size of 1300 characters, this will make 2 embeddings of 1k and 300 characters respectively.

Mindplug uses recursive chunking to chunk the string content. Thus the `chunkSize` will vary slightly across different embeddings.&#x20;

For any project or collection that does not already exist, it will be auto created for the user without any additional work.

{% code lineNumbers="true" %}

```javascript
import mindplug from "@/src/mindplugAPI"; // base instance

mindplug.post("/data/store", {
    db: "walmart",
    collection: "office supplies",
    content: "Premium eraser: an eraser that works on both pen and pencil and leaves no crumbs",
    metadata: {
        lastStock: "June 2023",
        totalItems: 123
    }
});
```

{% endcode %}

An upload id and a list of stored vector IDs are returned for later use.

### Sample Response

```json
{
    "data": {
        "success": true,
        "vectorIds": [
            "8ad610a8-9dc8-4e3c-bae4-0e10146fd43a"
        ],
        "uploadId": "ea209649-8f38-40e0-9b84-0cdb1809db6c"
    }
}
```


# Store PDF

Store PDF files

### Prerequisites

Requires a user auth token. See the [API Auth](/api/store-pdf) section for PDFs

### Storing data - API

For now Mindplug handles the storing of text data only. You can store data given the following parameters:&#x20;

1. Database name: `db`
2. A collection name: `collection`
3. A file to store: `file`
4. Optional `metadata` which is any arbitrary object for the content
5. Optional: `chunkSize`
   1. Defaults to 1024. Represents the amount of characters stored per embedding. If you give content size of 1300 characters, this will make 2 embeddings of 1k and 300 characters respectively.
6. A parameter for `type` of document.

Mindplug uses recursive chunking to chunk the string content. Thus the `chunkSize` will vary slightly across different embeddings.&#x20;

For any project or collection that does not already exist, it will be auto created for the user without any additional work.

{% code lineNumbers="true" %}

```javascript
import mindplugFile from "@/src/mindplugAPI"; // base instance

async function storePDF(data) {
    const form = new FormData();
    form.append('db', 'walmart');
    form.append('collection', 'Office Supplies');
    form.append('type', 'pdf');
    form.append('file', data.file);
    form.append('metadata', JSON.stringify(data.metadata)); // optional
    form.append('chunksize', data.chunkSize.toString()); // optional
    return mindplugFile.post('/data/store/file', form)
        .then(res => res.data).catch(err => err.response.data);
 }

const file = [stored file object];
storePDF({ file });

```

{% endcode %}

An upload id and a list of stored vector IDs are returned for later use.

### Sample Response

```json
{
    "data": {
        "success": true,
        "vectorIds": [
            "8ad610a8-9dc8-4e3c-bae4-0e10146fd43a"
        ],
        "uploadId": "ea209649-8f38-40e0-9b84-0cdb1809db6c"
    }
}
```


# Store Web

### Prerequisites

Requires a user auth token. See the [API Auth](/api/api-setup-text) section.

### Storing data - API

For now Mindplug handles the storing of text data only. You can store data given the following parameters:&#x20;

1. Database name: `db`
2. A collection name: `collection`
3. A webpage url to crawl and store: `url`
4. `metadata` which is any arbitrary object for the content
5. OPTIONAL: `chunkSize`
   1. Defaults to 1024. Represents the amount of characters stored per embedding. If you give content size of 1300 characters, this will make 2 embeddings of 1k and 300 characters respectively.

Mindplug uses recursive chunking to chunk the string content. Thus the `chunkSize` will vary slightly across different embeddings.&#x20;

For any project or collection that does not already exist, it will be auto created for the user without any additional work.

{% code lineNumbers="true" %}

```javascript
import mindplug from "@/src/mindplugAPI"; // base instance

mindplug.post("/data/store/webpage", {
    db: "walmart",
    collection: "office supplies",
    url: "mindplug.io",
    metadata: {
        lastStock: "June 2023",
        totalItems: 123
    }
});
```

{% endcode %}

An upload id and a list of stored vector IDs are returned for later use.

### Sample Response

```json
{
    "data": {
        "success": true,
        "vectorIds": [
            "8ad610a8-9dc8-4e3c-bae4-0e10146fd43a"
        ],
        "uploadId": "ea209649-8f38-40e0-9b84-0cdb1809db6c"
    }
}
```


# Query Data

### Prerequisites

Requires a user auth token. See the [API Auth](/api/api-setup-text) section.

### Querying data - API

This endpoint retrieves the stored data based on the meaning of the query. The endpoins requires:

1. Database name: `db`
2. A collection name: `collection`
3. An text string to search about: `search`
4. optional `count`: the number of matches to return. Defaults to 3
5. optional `metadataFilters`: to further filter data by metadata. Please see subpage

{% code overflow="wrap" lineNumbers="true" %}

```javascript
import mindplug from "@/src/mindplugAPI"; // base instance

mindplug.post("/data/query", {
    db: "walmart",
    collection: "office supplies",
    search: "an eraser with no crumbs",
    count: 1
});
```

{% endcode %}

### Sample Response

Returns a list of matching responses.

```json
{
    "data": [
        {
            "id": "4334eb12-f57d-4b67-8b13-1f62d7cf5791",
            "score": 0.893768728,
            "values": [],
            "metadata": {
                "content": "Premium eraser: an eraser that works on both pen and pencil and leaves no crumbs",
                "lastStock": "June 2023",
                "totalItems": 123
            }
        }
    ]
}
```


# Using Metadata Filters

### Supported metadata types

You can associate a metadata payload with each vector in an index, as key-value pairs in a JSON object where keys are strings and values are one of:

* String
* Number (integer or floating point, gets converted to a 64 bit floating point)
* Booleans (true, false)
* List of String

The metadata filters can be combined with AND and OR:

* `$eq` - Equal to *(number, string, boolean)*
* `$ne` - Not equal to *(number, string, boolean)*
* `$gt` - Greater than *(number)*
* `$gte` - Greater than or equal to *(number)*
* `$lt` - Less than *(number)*
* `$lte` - Less than or equal to *(number)*
* `$in` - In array *(string or number)*
* `$nin` - Not in array *(string or number)*

#### Using arrays of strings as metadata values or as metadata filters

A vector with metadata payload...

```json
{ "genre": ["comedy", "documentary"] }
```

...means the `"genre"` takes on both values.

For example, queries with the following filters will match the vector:

```json
{"genre":"comedy"}

{"genre": {"$in":["documentary","action"]}}

{"$and": [{"genre": "comedy"}, {"genre":"documentary"}]}
```

Queries with the following filter will **not** match the vector:

```json
{ "$and": [{ "genre": "comedy" }, { "genre": "drama" }] }
```

And queries with the following filters will **not** match the vector because they are invalid. They will result in a query compilation error:

```
# INVALID QUERY:
{"genre": ["comedy", "documentary"]}
```

```
# INVALID QUERY:
{"genre": {"$eq": ["comedy", "documentary"]}}
```

#### More example filter expressions

A comedy, documentary, or drama:

```json
{
  "genre": { "$in": ["comedy", "documentary", "drama"] }
}
```

A drama from 2020:

```json
{
  "genre": { "$eq": "drama" },
  "year": { "$gte": 2020 }
}
```

A drama from 2020 (equivalent to the previous example):

```json
{
  "$and": [{ "genre": { "$eq": "drama" } }, { "year": { "$gte": 2020 } }]
}
```

A drama or a movie from 2020:

```json
{
  "$or": [{ "genre": { "$eq": "drama" } }, { "year": { "$gte": 2020 } }]
}
```


# Query By Ids

### Prerequisites

Requires a user auth token. See the [API Auth](/api/api-setup-text) section.

### Getting vectors

Fetches data on specific vectors given vector ids.

```typescript
import mindplug from "@/src/mindplugAPI"; // base instance

mindplug.post("/data/vectors", {
    "db": "walmart",
    "collection": "OfficeSupplies",
    "vectorIds": ["22dd234c-340f-4c85-b784-47645bcdf07a",  "c8c47178-cba5-4795-a6ef-67fd4eda70fa"]
});
```

Returns the vector data related to the given vectors

```json
{
    "data": [
        {
            "id": "0b1a591b-bf13-4c3a-a667-81c9da5bf75f",
            "metadata": {
                "content": "Premium eraser: an erases that works on both pen and pencil and leaves no crumbs",
                "description": "Premium eraser: an erases that works on both pen and pencil and leaves no crumbs",
                "id": 1234335
            }
        }
    ]
}
```


# Query by collection

### Prerequisites

Requires a user auth token. See the [API Auth](/api/api-setup-text) section.

### Deleting Collection

Deletes all embedding vectors from the collection. The endpoins requires:

1. Database name: `db`
2. A collection name: `collection`

```typescript
import mindplug from "@/src/mindplugAPI"; // base instance

mindplug.post("/collection/vectors", {
    db: "walmart",
    collection: "office supplies"
});
```

Returns a list of top 10 vectors from the collection

```json
{
    "data": [
        {
            "id": "94d75718-c00a-468f-825c-4181925447e6",
            "metadata": {
                "content": "Premium eraser: an erases that works on both pen and pencil and leaves no crumbs",
                "description": "Premium eraser: an erases that works on both pen and pencil and leaves no crumbs",
                "id": 1234335
            }
        }
    ],
    "count": 2
}

```


# Delete By Ids

### Prerequisites

Requires a user auth token. See the [API Auth](/api/api-setup-text) section.

### Deleting Data

Deletes all vectors associated with provided vector Ids.

{% code overflow="wrap" lineNumbers="true" %}

```javascript
import mindplug from "@/src/mindplugAPI"; // base instance

mindplug.post("/data/delete", {
    "db": "walmart",
    "collection": "OfficeSupplies",
    "vectorIds": ["8ad610a8-9dc8-4e3c-bae4-0e10146fd43a"]
});
```

{% endcode %}

*Once the data is deleted, there is no way for Mindplug to restore the deleted data.*

### Sample Response

```json
{
    success: "true"
}
```


# Delete By Upload Id

### Prerequisites

Requires a user auth token. See the [API Auth](/api/api-setup-text) section.

### Deleting Data

Deletes all vectors associated with a single upload id. This useful when you store data at different points in time. If you want to delete all contents of a website, or a pdf and there are multiple sources, this is the best method.

{% code overflow="wrap" lineNumbers="true" %}

```javascript
import mindplug from "@/src/mindplugAPI"; // base instance

mindplug.post("/data/deleteupload", {
    "db": "walmart",
    "collection": "OfficeSupplies",
    "uploadId": "ea209649-8f38-40e0-9b84-0cdb1809db6c"
});
```

{% endcode %}

*Once the data is deleted, there is no way for Mindplug to restore the deleted data.*

### Sample Response

```json
{
    success: "true"
}
```


# Delete Collection

### Prerequisites

Requires a user auth token. See the [API Auth](/api/api-setup-text) section.

### Deleting Collection

Deletes all embedding vectors from the collection. The endpoins requires:

1. Database name: `db`
2. A collection name: `collection`

{% code overflow="wrap" lineNumbers="true" %}

```javascript
import mindplug from "@/src/mindplugAPI"; // base instance

mindplug.post("/collection/delete", {
    db: "walmart",
    collection: "office supplies"
});
```

{% endcode %}

### Sample Response

```json
{
    "data": {
        "success": true
    }
}
```


# Delete Project

### Prerequisites

Requires a user auth token. See the [API Auth](/api/api-setup-text) section.

### Deleting Project

Deletes the project and all associated collections.

{% code overflow="wrap" lineNumbers="true" %}

```javascript
import mindplug from "@/src/mindplugAPI"; // base instance

mindplug.post("/db/delete", {
    db: "walmart",
});
```

{% endcode %}

*Once the database is deleted, there is no way for Mindplug to restore the deleted data. Possibly users may keep a copy of data in a separate db just in-case.*&#x20;

### Sample Response

```json
{
    success: "true"
}
```


# List Projects

### Prerequisites

Requires a user auth token. See the [API Auth](/api/api-setup-text) section.

### Listing Projects

Lists all the databases created by the user.

{% code overflow="wrap" lineNumbers="true" %}

```javascript
import mindplug from "@/src/mindplugAPI"; // base instance

mindplug.post("/db/list", {});
```

{% endcode %}

### Sample Response

```json
{
    "success": true,
    "projects": [
        {
            "projectName": "walmart",
            "lastUpdated": "2023-07-16T18:00:27.601+00:00",
            "totalVectors": 5,
            "collectionCount": 1
        }
    ]
}
```


# List Collections

Lists all the collections the user has

### Prerequisites

Requires a user auth token. See the [API Auth](/api/api-setup-text) section.

### Listing Collections

Takes in a name of the database `db` and returns a list of all collections in that db.

{% code overflow="wrap" lineNumbers="true" %}

```javascript
import mindplug from "@/src/mindplugAPI"; // base instance

mindplug.post("/collection/list", {
    db: "walmart",
});
```

{% endcode %}

*Note the collections are automatically created when you add new data to the database.*

### Sample Response

```json
{
    "data": [
        {
            "collection": "OfficeSupplies",
            "totalVectors": 0,
            "collectionId": "591ed632-cf38-403e-8e63-be87999d4115"
        }
    ],
    "count": 1
}
```


# Search Web

Google search based on search query

### Prerequisites

Requires a user auth token. See the [API Auth](/api/api-setup-text) section.

### Searching Data

Requires 1 parameter: `search`

Mindplug offers a smart endpoint which will be expanded in the future. For now it provides basic google search from select sources.

```typescript
import mindplug from "@/src/mindplugAPI"; // base instance

mindplug.post("/smart/web", {
    search: "What are the best use cases of blockchain?"
});
```

Returns 3 matching results for the search query, including an `image`, `url`, `title` and `description` for the returned sources.

### Sample Response

```json
[
    {
        "image": "https://miro.medium.com/v2/resize:fit:1200/1*kT6_ISaSXPAHQErpA1nf4w.png",
        "title": "Learn about alternative use cases for crypto | @blockchain",
        "url": "https://medium.com/blockchain/6-crypto-use-cases-we-love-9c032755d4a6",
        "description": "Nov 24, 2022 <b>...</b> 1. Charity ... As the popularity of <b>crypto</b> has grown, so has the desire to donate it. With charitable organizations starting to accept&nbsp;...",
        "isVideo": false
    },
    {
        "image": "https://miro.medium.com/v2/resize:fit:960/1*s4mjd-QOqAmN7V8lXgI4hA.jpeg",
        "title": "Building it Better: A Simple Guide to Blockchain Use Cases | by ...",
        "url": "https://medium.com/blockchain-at-berkeley/building-it-better-a-simple-guide-to-blockchain-use-cases-de494a8f5b60",
        "description": "Feb 5, 2018 <b>...</b> Criteria to Consider When Deciding on a <b>Blockchain Use Case</b> &middot; 1. Database &middot; 2. Transactors &middot; 3. Trust &middot; 4. Disintermediation &middot; 5. Transaction&nbsp;...",
        "isVideo": false
    },
    {
        "image": "https://miro.medium.com/v2/resize:fill:1200:632/g:fp:0.53:0.88/1*v53tXgDlzbteJjjY6fllxQ.jpeg",
        "title": "Security Token Offerings (STOs) — The first great use case for ...",
        "url": "https://medium.com/hv-capital/security-token-offerings-stos-the-first-great-use-case-for-blockchain-technology-1b9701acb070",
        "description": "Apr 11, 2019 <b>...</b> Is <b>crypto</b> dead? likely. But STOs could prove to be the first real <b>use case</b> for <b>blockchain</b> technology.",
        "isVideo": false
    }
]
```


# Parse Webpage

### Prerequisites

Requires a user auth token. See the [API Auth](/api/api-setup-text) section.

### Parsing Data

Requires 1 parameter: `url`

Extracts text from the given webpage.

```typescript
import mindplug from "@/src/mindplugAPI"; // base instance

mindplug.post("/smart/parseWeb", {
    url: "https://mindplug.io"
});
```

Return a text string of all the content on the webpage.


