Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

314
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda