Datasets upload via REST API

Hello!

I checked the REST API docs but didn’t find if there is a way to upload a dataset via the REST api. So this way I could generate random data from a schema, download the data, upload the dataset and use that set for the second schema.

So … Is this possible?

Regards, Robert

3 Likes

There isn’t yet a way to do this via the API. I can definitely see value in your use case though. Will add it to the backlog.

Hello,

OK great. Thank you for the answer.

Regards,
Robert

Did this ever make it out of the backlog - I’ve got exactly the same requirement.

Thanks,

John

I’d also like to see this functionality.

Thanks,

Brian

Upvote.
I’d like to do a similar thing so that i can script the generation of new interlinked datasets.

something like
curl “https://api.mockaroo.com/api/xytyaz?count=20&key=1234” > “Owner.csv”
** push the generated csv as Dataset **
curl “https://api.mockaroo.com/api/xytyaz?count=20&key=1234” > “Shop.csv”
** push the generated csv as Dataset **
curl “https://api.mockaroo.com/api/xytyaz?count=20&key=1234” > “Products.csv”

1 Like

Is there a solution for this? I feel like this would be a really popular use case.

I would say the same, I’d like to have this in place

+1

Needing to upload datasets in a scriptable way instead of manual upload.

Bump Bump… not hearing back from Mark. Is this a dead service?

mockaroo - is this going to be available soon?

Any news on this feature? @mockaroo

Better late than never :slight_smile:

You can now upload datasets via the API. Here’s an example in node js:

const fetch = require('node-fetch')
const fs = require('fs')

function upload(apiKey, name, path) {
  fetch(`https://api.mockaroo.com/api/upload?key=${encodeURIComponent(apiKey)}&name=${encodeURIComponent(name)}`, {
    method: 'post',
    body: fs.readFileSync(path),
    headers: {
      "content-type": "text/csv"
    }
  })
  .then(res => res.json())
  .then(result => console.log(result))
}
1 Like

@mvbrocato This is working out great.

I would like to see now an API to delete a dataset otherwise I will need to manually delete these temporary datasets I am building, uploading and consuming.

Thanks again for delivering the UPLOAD!!

You got it.

const fetch = require('node-fetch')
const fs = require('fs')

function destroy(apiKey, name, path) {
  fetch(`https://api.mockaroo.com/api/datasets/${encodeURIComponent(name)}?key=${encodeURIComponent(apiKey)}`, {
    method: 'delete'
  })
  .then(res => res.json())
  .then(result => console.log(result))
}
1 Like

And by the way, I changed the URL for uploading a dataset to POST https://api.mockaroo.com/datasets/:name. To make it more RESTful. The old /api/upload URL still works for anyone that’s using it.

1 Like

Your views really very helpful for me contributors. It resolve my problem. Thank you.

I always come in this forum site to resolve my every issue. If you’re getting an issue of AT&T Email Not Working than solve it quickly by taking experts advice from our website.

This post was flagged by the community and is temporarily hidden.

Your views really very helpful for me contributors. It resolve my problem. Thank you.
watch pinoy dramas at lambinganhdreply enter link description here