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

Kaetlyn McCafferty
12,193 PointsObtaining API keys without a URL
Hi folks,
I was wondering if anyone had suggestions regarding the URL often required for getting API keys.
For example, after finishing the Node.js Basics course I was thinking I would try building a little command-line application for getting the weather - for my own learning purposes. So I searched for a few weather APIs, and all the ones I found seem to require a URL when you request the key. In this instance, I'm not looking to put this on the web or do anything beyond messing around with it to help myself learn (thus the only url I'd likely be using would be localhost). Can you put localhost in the request for a key or do they usually want a live url?
1 Answer

Kevin Korte
28,149 PointsI just want to make sure I understand, because some API's you can sign up on their site, get a key, and than just make calls to their url with your key, like www.someweatherapi.com?api_key=myapikey&zip=01234&forcast=next5days for instance and that would return the info.
Other APIs may want to authenticate with oAuth. That's where they want a callback URL, which would have to be a localhost url if you were developing locally. In that case the localhost url does work as a callback, since it's your local server making the call, it knows where localhost.com:3000/auth/callback
lives for example.
I hope that helps clear up your confusion.
Kaetlyn McCafferty
12,193 PointsKaetlyn McCafferty
12,193 PointsThis did help a bit. I'm just new to getting API keys in general and it's hard to explain what I mean! haha.
For example, to get Weather Underground's API key they ask for a project name and website, along with a few questions regarding what the API will be used for. The only other API I've used thus far has been Instagram which also asked for a website, but in that instance I had one that I was already using (in contrast to my current situation, which is completely local development.)
Here's what, for example, Weather Underground is asking: http://www.wunderground.com/weather/api/d/questionnaire.html?plan=a&level=0&history=undefined
So if I am planning only to use this locally, I would use my localhost url in the project website field? Basically, I just want to know what to put there, if I'm developing locally, in order to get the key. I hope this makes sense at all, and also thanks a million for your help/patience!
Kevin Korte
28,149 PointsKevin Korte
28,149 PointsYep, you got it right. For your website url you can just put localhost. You can change that later if you want, so it's not permanent to sign up. The reason I assume they, or any api wants a web address is two fold. One is if you're account is abusing it's daily allotment of api calls, they have a website associated to see for themselves what you are doing, and the second would be whether your site violates their terms, say if it was being used for commercial purposes and they don't allow that.
Once you sign up, you'll have a dashboard with your key, and where you can update any of your details, than you just make a call like this http://api.wunderground.com/api/api_key/conditions/q/CA/San_Francisco.json and you'll get a json response.
The only time your url will really matter is when you get into oAuth with an api, it will want a callback url where it will supply an auth token back, and even that url can be your localhost url. The only reason to do a oAuth is if your application is going to do things on behalf of the user. For instance, if your app makes a tweet to twitter from the user's action, you would need to use the oAuth protocol to authenticate your users account with their twitter account, and than make the call to tweet via Twitter's api. It gets much more complicated, but it's cool when it works.
Hope that helps.