Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

313
Views
GET api data using curl command

I am trying to get some data from public api's using curl:

curl --request GET 'https://api.openweathermap.org/data/2.5/weather?lat=37.3565982&lon=-121.9689848&units=imperial' \
--header 'X-Api-Key: x-api-‘key \
--data 'output_format=csv' \
> save_file.csv

and if I am running the command in terminal is returning the output and everything is working just fine but if I am trying to add an extra parameter to download the result in a .csv format, is generating the file but the format inside is wrong, I mean is not added as a table format but more like a array of objects [{}, {}, {}] and so on.

It is possible to run a curl command and get the data in a csv format ?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

--data is how you add body data to a POST request. You are making a GET request.

The api documentation for the webservice you are using says:

mode optional Response format. Possible values are xml and html. If you don't use the mode parameter format is JSON by default. Learn more

So to get something other than JSON back from the server, you need to put mode=something in the query string and only XML and HTML are options.

It is not output_format.

It does not go in the body.

CSV is not an option.


If you want to put that data into CSV format, then you'll need to transform it locally. The data format described in the documentation does not look like it lends itself to the 2D data structures described by CSV so you'll have to make decisions about how to transform it.

You've tagged this javascript so you could pipe the output of curl into a program you run with Node.js which parses the JSON, restructures it however you like, and then uses a module like papaparse to convert it to JSON.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!