Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Node.js Basics 2017 Building a Command Line Application Making a GET Request with https

How to get JSON data from any URL (API)?

For instance, I found a website, and I want to use the data there, is there a way that I can get JSOn data from any website or only certian websites?

How to get JSON data from the url then? and How do we know is there is a json data available? Thank you

app.js

It is a general question I just thought of, nothing about this challenge.

1 Answer

Robert Manolis
STAFF
Robert Manolis
Treehouse Guest Teacher

Hey Hanwen Zhang , you can only get a JSON response if the server you're pinging is set up to return JSON. You can try researching a site or app to see if has an API that you can send requests to. Or you can try just sending a request and see what you get. If you found a site that you want to get info from, but it doesn't return JSON, you may be able to scrape the site to get info off the page. But you can't ethically get anything off the server that they don't want to give you. :thumbsup: