Passing Data to ConvertCSV API
All our conversion APIs require the "infile" parameter to identify the data to be converted.
You may use the GET request if your data source is a URL or you have a small input string.
If you are uploading a file, then we require a HTTP POST request.
For POST, set enctype="multipart/form-data" if using HTML forms with a file upload, otherwise use "application/x-www-form-urlencoded".
When using the command line tool
curl, there are 3 different ways to pass data to our API:
- POSTed form field:
curl -X POST "https://www.convertcsv.io/api/v1/csv2json" -H "Authorization: Token XXXXX" ... -F "infile=@myfile.csv"
- GET for URL containing the data:
curl "https://www.convertcsv.io/api/v1/csv2json?auth_token=XXXXX&infile="https%3A%2F%2Fjsonplaceholder.typicode.com%2Fusers"
Note that the infile URL string must be URL encoded. See URL Encoder
- GET for less than 1K of data:
curl "https://www.convertcsv.io/api/v1/csv2json?auth_token=XXXXX&infile="raw input data goes here, such as a CSV or JSON string"
Note that the infile data must be URL encoded. If you are using an HTML form with the GET method, then this will be done for you. You may use this URL Encoder to URL data.
Each converter has optional parameters that should be passed as part of the query string of the URL, example:
curl "https://www.convertcsv.io/api/v1/json2csv?auth_token=XXXXX&outtab=Y&infile=https%3A%2F%2Fjsonplaceholder.typicode.com%2Fusers"