Hello,
How add/delete record from dataset using API? Can I do it?
Hello,
How add/delete record from dataset using API? Can I do it?
You can’t add or remove individual records, but you can upload a new version of the dataset via the API:
Here’s the relevant section:
POST https://api.mockaroo.com/api/datasets/:name?key=(your API key)&filename=(file name)
Uploads a dataset. Specify the data in the request body and the mime type as the Content-Type header.Content-Type must be text/csv or text/plain.
Example (JavaScript)
const fetch = require('node-fetch')
const fs = require('fs')
function upload(apiKey, name, path) {
fetch(`https://api.mockaroo.com/api/datasets/${encodeURIComponent(name)}?key=${encodeURIComponent(apiKey)}`, {
method: 'post',
body: fs.readFileSync(path),
headers: {
"content-type": "text/csv"
}
})
.then(res => res.json())
.then(result => console.log(result))
}