API Spec
API Spec
API Spec

Updated on Apr 27, 2024

1

min read

API Specification

Updated on Apr 27, 2024

1

min read

API Specification

Updated on Apr 27, 2024

1

min read

API Specification

Endpoints

POST /collection

Create a new collection

Example:

POST /v1/collection HTTP/1.1 Host: api.vesana.dev x-Vesana-API-key: YOUR_API_KEY Content-Type: application/json

Example Response:

{ "status": "success", "collection_id": "4321" }


POST /upload/[collection_id]

Uploads a new document to be processed and stored.

Example:

POST /v1/upload/4321 HTTP/1.1 Host: api.vesana.dev x-Vesana-API-key: YOUR_API_KEY Content-Type: application/json { "text": "Your document text here", "fields": { "title": "Document Title", "author": "Author Name", "metadata": { "tags": ["example", "document"] } } }

Example Response:

{ "status": "success", "document_id": "12345" }


GET /doc_status

Returns the processing status of a given doc.

Example:

GET /v1/doc_status?document_id=12345 HTTP/1.1 Host: api.yourdomain.com x-Vesana-API-key: YOUR_API_KEY

Response:

{ "status": "success", "doc_status": "ready"}


GET /search/[collection_id]

Searches through the processed documents based on the query parameters.

URL:

GET https://api.vesana.dev/v1/search/[collection_id]

Headers:

x-Vesana-API-key: YOUR_API_KEY

Query Parameters:

  • text (str): The text to search for

  • sql (str): SQL query to run against the dataset

  • level (int): The level of granularity for the search (default=1, root doc)

  • count (int): The number of documents to return

  • num_chunks (int): The number of chunks to include in the results, if level != 1 (e.g. in a case where level=3 is "paragraph", how many paragraphs to get before and after the matching paragraph)

Response:

{ "status": "success", "results": [ { "document_id": "string", "text": "string", "metadata": "JSON" }, ... ] }

Example:

GET /v1/search?text=example&sql="AuthorName='Tolkien' and Year<1960"&count=2 HTTP/1.1 Host: api.yourdomain.com x-Vesana-API-key: YOUR_API_KEY

Response:

{ "status": "success", "results": [ { "document_id": "12345", "text": "When Mr. Bilbo Baggins...", "metadata": { "title": "The Lord of the Rings", "author": "Tolkien", "tags": ["example", "document"] } }, { "document_id": "67890", "text": "Another sample text...", "metadata": { "title": "Another Title", "author": "Another Author", "tags": ["sample", "data"] } } ] }

Endpoints

POST /collection

Create a new collection

Example:

POST /v1/collection HTTP/1.1 Host: api.vesana.dev x-Vesana-API-key: YOUR_API_KEY Content-Type: application/json

Example Response:

{ "status": "success", "collection_id": "4321" }


POST /upload/[collection_id]

Uploads a new document to be processed and stored.

Example:

POST /v1/upload/4321 HTTP/1.1 Host: api.vesana.dev x-Vesana-API-key: YOUR_API_KEY Content-Type: application/json { "text": "Your document text here", "fields": { "title": "Document Title", "author": "Author Name", "metadata": { "tags": ["example", "document"] } } }

Example Response:

{ "status": "success", "document_id": "12345" }


GET /doc_status

Returns the processing status of a given doc.

Example:

GET /v1/doc_status?document_id=12345 HTTP/1.1 Host: api.yourdomain.com x-Vesana-API-key: YOUR_API_KEY

Response:

{ "status": "success", "doc_status": "ready"}


GET /search/[collection_id]

Searches through the processed documents based on the query parameters.

URL:

GET https://api.vesana.dev/v1/search/[collection_id]

Headers:

x-Vesana-API-key: YOUR_API_KEY

Query Parameters:

  • text (str): The text to search for

  • sql (str): SQL query to run against the dataset

  • level (int): The level of granularity for the search (default=1, root doc)

  • count (int): The number of documents to return

  • num_chunks (int): The number of chunks to include in the results, if level != 1 (e.g. in a case where level=3 is "paragraph", how many paragraphs to get before and after the matching paragraph)

Response:

{ "status": "success", "results": [ { "document_id": "string", "text": "string", "metadata": "JSON" }, ... ] }

Example:

GET /v1/search?text=example&sql="AuthorName='Tolkien' and Year<1960"&count=2 HTTP/1.1 Host: api.yourdomain.com x-Vesana-API-key: YOUR_API_KEY

Response:

{ "status": "success", "results": [ { "document_id": "12345", "text": "When Mr. Bilbo Baggins...", "metadata": { "title": "The Lord of the Rings", "author": "Tolkien", "tags": ["example", "document"] } }, { "document_id": "67890", "text": "Another sample text...", "metadata": { "title": "Another Title", "author": "Another Author", "tags": ["sample", "data"] } } ] }

Endpoints

POST /collection

Create a new collection

Example:

POST /v1/collection HTTP/1.1 Host: api.vesana.dev x-Vesana-API-key: YOUR_API_KEY Content-Type: application/json

Example Response:

{ "status": "success", "collection_id": "4321" }


POST /upload/[collection_id]

Uploads a new document to be processed and stored.

Example:

POST /v1/upload/4321 HTTP/1.1 Host: api.vesana.dev x-Vesana-API-key: YOUR_API_KEY Content-Type: application/json { "text": "Your document text here", "fields": { "title": "Document Title", "author": "Author Name", "metadata": { "tags": ["example", "document"] } } }

Example Response:

{ "status": "success", "document_id": "12345" }


GET /doc_status

Returns the processing status of a given doc.

Example:

GET /v1/doc_status?document_id=12345 HTTP/1.1 Host: api.yourdomain.com x-Vesana-API-key: YOUR_API_KEY

Response:

{ "status": "success", "doc_status": "ready"}


GET /search/[collection_id]

Searches through the processed documents based on the query parameters.

URL:

GET https://api.vesana.dev/v1/search/[collection_id]

Headers:

x-Vesana-API-key: YOUR_API_KEY

Query Parameters:

  • text (str): The text to search for

  • sql (str): SQL query to run against the dataset

  • level (int): The level of granularity for the search (default=1, root doc)

  • count (int): The number of documents to return

  • num_chunks (int): The number of chunks to include in the results, if level != 1 (e.g. in a case where level=3 is "paragraph", how many paragraphs to get before and after the matching paragraph)

Response:

{ "status": "success", "results": [ { "document_id": "string", "text": "string", "metadata": "JSON" }, ... ] }

Example:

GET /v1/search?text=example&sql="AuthorName='Tolkien' and Year<1960"&count=2 HTTP/1.1 Host: api.yourdomain.com x-Vesana-API-key: YOUR_API_KEY

Response:

{ "status": "success", "results": [ { "document_id": "12345", "text": "When Mr. Bilbo Baggins...", "metadata": { "title": "The Lord of the Rings", "author": "Tolkien", "tags": ["example", "document"] } }, { "document_id": "67890", "text": "Another sample text...", "metadata": { "title": "Another Title", "author": "Another Author", "tags": ["sample", "data"] } } ] }