Developer Documentation

DataVision API Reference

Embed natural-language data analysis directly into your applications. Upload datasets, ask questions in plain English, and receive AI-powered insights and interactive Plotly charts.

REST API
Bearer Auth
multipart/form-data

Overview

The DataVision API is a REST endpoint that accepts multipart/form-data requests. You can upload a CSV or Excel file along with a natural-language question, and the API returns an AI-generated analysis with text insights and an optional Plotly chart configuration.

How it works

1

Upload

Send your dataset + question

2

Analyze

AI parses, analyzes, and visualizes

3

Receive

Get insights + chart config in JSON

Authentication

Authenticate every request by including your API key as a Bearer token in the Authorization header.

HTTP Header
Authorization: Bearer dv_live_YOUR_API_KEY_HERE

Generating your API key

  1. 1Log in to your DataVision AI account.
  2. 2Navigate to Account Settings.
  3. 3Scroll to API Keys and click Generate New Key.
  4. 4Give it a recognizable name (e.g., "Python Scripting" or "Prod Backend").

Important: Copy your key immediately after generating it. For security, the full key cannot be viewed again.

Endpoint

All API interactions go through a single endpoint. The endpoint accepts multipart/form-data only.

Base URL
POSThttps://datavision-ai.vercel.app/api/chat

Request Parameters

All parameters are sent as multipart/form-data fields. There are two request flows.

Flow 1

Initial Analysis — Upload a File

ParameterTypeStatusDescription
messagestringRequiredYour question in plain English.
filefileRequiredDataset to analyze (CSV, XLS, or XLSX).
Flow 2

Follow-up Questions — Cached Context

ParameterTypeStatusDescription
messagestringRequiredYour follow-up question.
cached_schemastringRequiredSchema string from your previous response.
cached_df_jsonstringRequiredDataframe JSON from your previous response.

Tip: Using cached context avoids re-uploading files and reduces credit cost.

Code Examples

Copy-paste examples to start integrating immediately. Pick your language below.

import requests

url = "https://datavision-ai.vercel.app/api/chat"
api_key = "dv_live_YOUR_API_KEY_HERE"

headers = {
    "Authorization": f"Bearer {api_key}"
}

# ── Initial analysis (upload a file) ──
data = {
    "message": "Show me total sales by region as a bar chart"
}
files = {
    "file": ("sales_data.csv", open("sales_data.csv", "rb"), "text/csv")
}

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

if response.status_code == 200:
    result = response.json()
    print("AI Analysis:", result.get("text_overview"))
    print("Credits left:", result.get("creditsRemaining"))

    # Save context for follow-ups
    cached_schema = result.get("cached_schema")
    cached_df_json = result.get("cached_df_json")
else:
    print(f"Error {response.status_code}: {response.text}")

Response Codes

The API uses standard HTTP response codes. Here are the ones you should handle:

200Analysis completed successfully
401Invalid or missing API key
402Insufficient credits
429Rate limit exceeded
500Internal server error
503Backend unavailable

Success Response Shape

200 OK — JSON
{
  "text_overview": "The dataset shows total sales of $1.2M across 4 regions...",
  "plotly_config": { ... },
  "cached_schema": "col1:string, col2:number, ...",
  "cached_df_json": "[{...}, {...}]",
  "creditsRemaining": 42
}
FieldTypeDescription
text_overviewstringAI-generated text analysis of the data.
plotly_configobject | nullPlotly chart JSON config, if a chart was generated.
cached_schemastringSchema of the dataset — pass this in follow-up requests.
cached_df_jsonstringSerialized dataframe — pass this in follow-up requests.
creditsRemainingnumberYour remaining credit balance after this request.

Credits & Rate Limits

Each API request consumes credits from your account balance. New accounts start with 100 free credits.

Initial File Upload8

Credits per request when uploading a new file for analysis.

Follow-up Question4

Credits per follow-up using cached context from a prior request.

Rate Limit Errors

402Insufficient credits — upgrade your plan
429Too many requests — slow down or upgrade

If you consistently hit rate limits, consider spacing out requests or upgrading your plan for higher throughput.