By codemonth | Updated לפני 10 חודשים | Data

0 / 10



Service Level


Back to All Tutorials (4)

Creating CSV data from Binubuo API

Creating CSV data

One of the tasks that is often needed, is to create some sort of test data as a CSV file. Binubuo API has a very simple and easy way to very quickly create as much data as you need, directly in CSV format. For this we can use the GET /data/custom/quick_fetch endpoint. The endpoint gives you the ability to simply list all of the fields and generators you want in your data, as a comma separated list to the COLS parameter in the URL. So if we imagine that we wanted to create a CSV file called user_data.csv with a list of 40 users with the following format:

  1. First Name
  2. Last Name
  3. Address
  4. City
  5. Country
  6. Email Address

All we need to do is call the endpoint with the COLS parameter specifying the data format we want, set the CSV parameter to 1 to get output in CSV and then set the rows parameter to 40 for the number of rows we want to create. The names for the comma separated list of fields, are the same names as the Binubuo API generator endpoint names.,last_name,address,city,country,email

So if we wanted call this and have the data written into a file, you could write the following powershell command:

# First we setup the headers with the correct key. 
# REMEMBER to change the key to your actual RapidAPI key for the example to work.
$headers.Add("x-rapidapi-host", "")
$headers.Add("x-rapidapi-key", "your_own_key_here")
$response = Invoke-WebRequest -Uri ',last_name,address,city,country,email' -Method GET -Headers $headers
Add-Content -Path .\user_data.csv -Value $response.Content

For a a full list of all the data generators we can use, see the API documentation: