CSV to JSON Converter is a powerful tool for converting CSV data into JSON format. It supports custom delimiters, header detection, and handles quoted fields properly.
npm install @apiverve/csvtojsonshell
npm install @apiverve/csvtojson
`
Using yarn:
`shell
yarn add @apiverve/csvtojson
`
---
Configuration
Before using the CSV to JSON Converter API client, you have to setup your account and obtain your API Key.
You can get it by signing up at https://apiverve.com
---
Quick Start
Get started with the Quick Start Guide
The CSV to JSON Converter API documentation is found here: https://docs.apiverve.com/ref/csvtojson.
You can find parameters, example responses, and status codes documented here.
$3
`javascript
const csvtojsonAPI = require('@apiverve/csvtojson');
const api = new csvtojsonAPI({
api_key: '[YOUR_API_KEY]'
});
`
---
Usage
---
$3
Using the API is simple. All you have to do is make a request. The API will return a response with the data you requested.
`javascript
var query = {
"csv": "name,age,city\nJohn Doe,30,New York\nJane Smith,25,Los Angeles",
"delimiter": ",",
"has_header": true
};
api.execute(query, function (error, data) {
if (error) {
return console.error(error);
} else {
console.log(data);
}
});
`
---
$3
You can also use promises to make requests. The API returns a promise that you can use to handle the response.
`javascript
var query = {
"csv": "name,age,city\nJohn Doe,30,New York\nJane Smith,25,Los Angeles",
"delimiter": ",",
"has_header": true
};
api.execute(query)
.then(data => {
console.log(data);
})
.catch(error => {
console.error(error);
});
`
---
$3
You can also use async/await to make requests. The API returns a promise that you can use to handle the response.
`javascript
async function makeRequest() {
var query = {
"csv": "name,age,city\nJohn Doe,30,New York\nJane Smith,25,Los Angeles",
"delimiter": ",",
"has_header": true
};
try {
const data = await api.execute(query);
console.log(data);
} catch (error) {
console.error(error);
}
}
`
---
Example Response
`json
{
"status": "ok",
"error": null,
"data": {
"row_count": 2,
"column_count": 3,
"columns": [
"name",
"age",
"city"
],
"json": [
{
"name": "John Doe",
"age": "30",
"city": "New York"
},
{
"name": "Jane Smith",
"age": "25",
"city": "Los Angeles"
}
]
}
}
``