Get authorization keys
I'm giving an API documentation workshop in San Francisco, California, on November 19, 2019. Check it out on EventBrite and register today to receive a $100 early bird discount.
Almost every API has a method in place to authenticate requests. You usually have to provide an API key in your requests to get a response. Although we’ll dive into authentication and authorization later, we need to get some API keys now to make requests to our weather API.
- Why requests need authorization
- Activity 2b: Get an OpenWeatherMap API key
- Get the Aeris Weather API secret and ID
- Make sure you have a text editor
Why requests need authorization
Requiring authorization allows API publishers to do the following:
- License access to the API
- Rate limit the number of requests
- Control availability of certain features within the API, and more
To run the code samples in this course, you will need to use your own API keys, since these keys are usually treated like passwords and not given out or published openly on a web page.
Even though you should treat API keys like passwords, if you want to borrow my API keys, you can access them here. I sometimes find that workshop participants get hung up in trying to acquire API keys, so I make them available here to avoid delays in the activities.
Activity 2b: Get an OpenWeatherMap API key
To get an API key for the OpenWeatherMap API:
- Go to openweathermap.org.
- Click Sign Up in the top navigation bar and create an account.
- After you sign up, your API key is sent to the email address you provide. You can also find it on the Developer Dashboard in the site. Return to the OpenWeatherMap homepage and click Sign in.
After signing in, you’ll see the developer dashboard. Click the API Keys tab (highlighted in the screenshot below).
- Copy the key to a place you can easily find it.
(Note: It can take an hour or so for a new OpenWeatherMap API key to activate. If you have trouble with your key, use one of the keys listed here. Put your name next to the key you’re using.)
Get the Aeris Weather API secret and ID
Now for contrast, let’s get the keys for the Aeris Weather API. The Aeris Weather API requires both a secret and ID to make requests.
- Go to http://www.aerisweather.com and click Sign Up in the upper-right corner.
- Under Developer, click TRY FOR FREE. (The free version limits the number of requests you can make.)
- Enter a username, email, and password, and then click SIGN UP FOR FREE to create an Aeris account. Then sign in.
After you sign up for an account, click Account in the upper-right corner.
Click Apps (on the second navigation row, to the right of “Usage”), and then click New Application.
- In the Add a New Application dialog box, enter the following:
- Application Name: My biking app (or something)
- Application Namespace: localhost
- Click Save App.
After registering your app, you should see an ID, secret, and namespace for the app. Copy this information into a place you can easily access since you’ll need it to make requests.
Keep in mind how users authorize calls with an API — this is something you usually cover in API documentation. Later in the course, we will dive into authorization methods in more detail.
Make sure you have a text editor
In the upcoming activities, you’ll work with code in a text file. When you’re working with code, you use a text editor (to work in plain text) instead of a rich text editor (which would provide a WYSIWYG interface). Here are a few choices for text editors:
- Sublime Text (Mac or PC)
- TextWrangler or BBEdit (Mac)
- WebStorm (Mac or PC)
- Notepad++ (PC)
- Atom (Mac or Windows)
- Komodo Edit (Mac or PC)
- Coda (Mac)
These editors provide features that let you better manage the text. Choose the one you want. (My preference is to use Sublime Text when I’m working with independent code samples, and Atom when I’m working with Jekyll projects.) Avoid using TextEdit since it adds some formatting behind the scenes that can corrupt your content.
38/146 pages complete. Only 108 more pages to go.
Want to buy me lunch? Click the Donate button below to donate any amount through Paypal.