Use the Data.Page API when a conversion needs to run from a script, scheduled job, internal tool, or website button. The API accepts JSON and returns CSV, or accepts CSV and returns JSON.
The free API allowance is 1 MB per day. Contact us if you need higher volume, private workflow support, or help choosing the right conversion settings.
Register here to access the API:
After registration, use one of the examples below to post data to the API and save the result.
from urllib.parse import urlencode from urllib.request import Request, urlopen import sys email = '[email protected]' input_filename = 'c:\\temp\\input.json' output_filename = 'c:\\temp\\output.csv' #read json with open(input_filename) as json_file: json = json_file.read() api_url = 'https://data.page/api/getcsv' post_fields = {'email': email, 'json': json} request = Request(api_url, urlencode(post_fields).encode(), headers={ 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.47 Safari/537.36' }) csv = urlopen(request).read().decode() #write csv with open(output_filename, "w") as f: f.write(csv) f.close()
$url = 'https://data.page/api/getcsv';
$email = '[email protected]';
$json = '{"test":true,"test2":false}';
$postdata = http_build_query(
array(
'email' => $email,
'json' => $json
)
);
$opts = array(
'http' => array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $postdata
)
);
$context = stream_context_create($opts);
$result = file_get_contents($url, false, $context);
print $result;
$email = '[email protected]';
$json = '{"test":true,"test2":false}';
$post = 'email=' . $email . '&json=' . $json;
$ch = curl_init('https://data.page/api/getcsv');
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$response = curl_exec($ch);
curl_close($ch);
echo $response;
Generate a CSV file in your Google Drive account. Contact us for variations such as pulling data into Google Sheets.
function myFunction() {
var email ="[email protected]";
var url="https://api.fiscaldata.treasury.gov/services/api/fiscal_service/v2/accounting/od/avg_interest_rates";
var json = UrlFetchApp.fetch(url).getContentText();
var options = {
'method' : 'post',
'contentType': 'application/x-www-form-urlencoded',
'payload' : {
email:email,
json:json
}
};
var resp=UrlFetchApp.fetch('https://data.page/api/getcsv', options);
// Creates a new CSV file in your Google Drive account
var fid=DriveApp.createFile(resp.getBlob());
fid.setName("DataPage-output.csv");
}
string email = "[email protected]";
string json = "{\"test\":true,\"test2\":false}";
using (var client = new HttpClient())
{
string url = "https://data.page/api/getcsv";
var content = new FormUrlEncodedContent(new[]
{
new KeyValuePair<string, string>("email", email),
new KeyValuePair<string, string>("json", json)
});
var result = client.PostAsync(url, content).Result;
string csvContent = result.Content.ReadAsStringAsync().Result;
Response.Write(csvContent);
}
To convert an input.json file to output.csv
curl -X POST https://data.page/api/getcsv -F [email protected] -F [email protected] -o output.csv
The API also has CSV to JSON functionality. This works the same way as JSON to CSV except:
https://data.page/api/getcsv to https://data.page/api/getjson.Here's a PHP sample for CSV to JSON:
$email,
'csv' => $csv
)
);
$opts = array(
'http' => array(
'method' => 'POST',
'header' => 'Content-type: application/x-www-form-urlencoded',
'content' => $postdata
)
);
$context = stream_context_create($opts);
$result = file_get_contents($url, false, $context);
print $result;