@pvt-app/client
v0.0.1
Published
Official client for the Pvt chart artifact API. One call to turn a DSL string into a renderable Highcharts config.
Maintainers
Readme
@pvt-app/client
Official client for the Pvt chart artifact API. One call turns a DSL string into a renderable Highcharts config.
Install
npm install @pvt-app/clientQuickstart
const { PvtClient } = require('@pvt-app/client');
const pvt = new PvtClient({ apiKey: 'pvt_live_...' });
const { config, chartType } = await pvt.chart({
dsl: `
series: bar
x: State
y: GDP
`,
csvData: 'State,GDP\nCalifornia,3400\nTexas,2100\n',
});
// config is a standard Highcharts config object
Highcharts.chart('container', config);API
new PvtClient(options)
| option | type | default |
|---|---|---|
| apiKey | string (required) | — |
| baseUrl | string | https://pvt.app |
| timeoutMs | number | 30000 |
| fetch | function | global fetch |
pvt.chart({ dsl, csvData?, formats? })
Returns { config, chartType, formats, errors }.
formatsdefaults to['json']. You can request['json','svg','png']— SVG/PNG are stubbed server-side pending the Highcharts export server rollout; JSON config always returns.
pvt.uploadDataset({ name, content, contentType? })
Uploads a dataset via POST /api/v1/datasets. Returns { dataset } with slug, id, etc.
pvt.listKeys()
Lists the caller's API keys. Session auth only — primarily for the dashboard UI.
Errors
Non-2xx responses throw PvtApiError with .status and .body:
const { PvtApiError } = require('@pvt-app/client');
try {
await pvt.chart({ dsl });
} catch (err) {
if (err instanceof PvtApiError) {
console.error(`API ${err.status}:`, err.body.error);
}
}License
ISC
