Codecademy

Sign In Create Account
01/02
find the total number of clicks on a link

You can always see how many people have clicked on any bitly-powered link by taking the link and putting a plus sign (+) at the end of it. For example: http://bitly.com/RYYpZT+

In this exercise, we'll review how to use the bitly API to programmatically get the same value.

Full documentation for the bitly clicks endpoint is here: http://dev.bitly.com/link_metrics.html#v3_link_clicks

The sample code is configured to make a call to the bitly /v3/link/clicks API endpoint with a link value, then returns the resulting JSON. You're looking for the link_clicks value -- that's how many people have clicked on this link.

Go ahead and swap the link parameter in the example for a bitly link of your own creation. How many clicks did it get? Click it and try again!

Now print just the number of clicks, but printing the value returned in ['data']['link_clicks'].

Save & Submit Code Reset Code
Back to editor

Start Here

Each lesson starts here. Read the explanation, then follow the instructions underneath. If you get stuck, you can click on the "Hint" for help.

Enter your Code

Type your response to the instructions here, in your code editor.

Submit!

Ready to see if your code does what it should? Click "Save + Submit" to run and check your code!

Click "Save + Submit" to run your code! Your code’s output will pop up on the screen.

See What it Does

This is the terminal. When you submit your code, it will run your code and display the result here.

Sign in to Codecademy