LizardBot/bit.ly API

From LizardWiki, FastLizard4's wiki and website
< LizardBot
Revision as of 10:52, 19 August 2010 by FastLizard4 (Talk | contribs) (bit.ly api documentation)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search



Ambox rewrite orange.svg

Note: Some experience in the PHP programming language - which this bot is written in - is recommended for using this bot. The documentation on this site assumes that you are familiar with at least the basics of PHP (such as declaring variables, how to quote strings, etc.). That said, this is only a recommendation - if you don't know PHP at all, you are welcome to try out LizardBot, and do ask for help on our IRC channel or elsewhere if you need it.


LizardBot now has the capability of interfacing with bit.ly's API, allowing for convenient URL shortening, expansion, lookups, etc., all powered by bit.ly. This functionality was introduced in LizardBot 7.1.0.0b (r69).


Command Documentation

First, it's worth noting that to access the bit.ly command, certain variables must be configured:

  • $setEnableBitly: Boolean. Set this to TRUE to enable the bit.ly API. Note that this is one of three settings required for the bit.ly API to work, the others being$setBitlyLogin and $setBitlyAPIKey.
  • $setBitlyAPISleep: Integer. The number of seconds after a @bit.ly command that the bot forces one to wait so that you don't exceed your bit.ly API limit. The default is rather high, 30.
  • $setBitlyLogin: String. Required for the bit.ly API to run. This is your username (or API username, if applicable) of your bit.ly account. You need one (which is free, by the way) to use the bit.ly API functions of LizardBot. This is normally your login username. See their website to get an account.
  • $setBitlyAPIKey: String. Required for the bit.ly API to run. This is your API key, which is generated for all users by bit.ly. You need one to use the bit.ly API functions of LizardBot. If you have an account, you can find your API Key here. Otherwise, you'll need to create an account first, then get your API Key. This is not your bit.ly login password.

In addition, one must have the bit.ly privilege, normally assigned to the * group.

The system adds only one new command to the bot, @bit.ly. However, this command has multiple "actions" (the single argument to each is in italics):

  • @bit.ly shorten Long URL to shorten into a bit.ly URL
  • @bit.ly expand bit.ly URL to expand into a long URL
  • @bit.ly clicks bit.ly URL to get click stats for
  • @bit.ly checkpro domain to check whether or not it's a bit.ly pro domain
  • @bit.ly lookup Long URL to check to see if it's already been shortened at bit.ly, and to return that shortened URL, if it exists
  • @bit.ly info bit.ly URL to get information for - specifically, the target page's title at the bit.ly URL's creator

The above list should be self-explanatory.

API Rate Limiting

bit.ly enforces API rate limits. Specifically, one IP address may only make five concurrent API requests, and each IP only gets so many [the number isn't stated directly] API requests per hour (resetting at the top of every hour). To this end, the bot itself enforces a rate limit as configured by the $setBitlyAPISleep setting (see above).

Warnings

WARNING: Unless you have an application API key, LizardBot will use your personal account's API key (however you configure it). All bit.ly links created using @bit.ly shorten will therefore appear as being created by you. You may want to take this into account when defining the access group for the bit.ly privilege.

Further Reading

You can see bit.ly's full API documentation here.