How add/delete record from dataset using API?

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 /api/datasets/:name

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.

  • name (required) The name of the dataset to create or update.
  • filename (optional) The name of the original file. The file name must have a .csv or .txt extension.
  • project (optional) The name of an existing project to add the dataset to.

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))
}