Predictive Hacks

How To Save an API Response Into a File

We can easily save an API response into a file by just using the terminal in our system. We will use a fake API that returns a JSON file.

Let’s first get the response using curl.

curl https://api.mocki.io/v1/b043df5a

output:

[{"city":"Stockholm","name":"Lennart Johansson"},{"city":"London","name":"Karl Eriksson"},{"city":"Helsinki","name":"Pekka Hartikainen"},{"city":"Berlin","name":"Mia Svensson"}]

Now, If we want to save the response into a file, we can do it easily by running the following

curl -o file.txt https://api.mocki.io/v1/b043df5a

Running the above, you should have a fille created with the name file.txt.

API response into a file

Share This Post

Share on facebook
Share on linkedin
Share on twitter
Share on email

Subscribe To Our Newsletter

Get updates and learn from the best

More To Explore

Python

Image Captioning with HuggingFace

Image captioning with AI is a fascinating application of artificial intelligence (AI) that involves generating textual descriptions for images automatically.

Python

Intro to Chatbots with HuggingFace

In this tutorial, we will show you how to use the Transformers library from HuggingFace to build chatbot pipelines. Let’s