First, go to the bit. ly website (bit. ly) to apply for an account and obtain the API key. After registration, there will be records of the domain name shortening service through this account, which can help users analyze and so on.
After registering an account, you only need to enter setting to view your API key.
API description:
Rest
API response ¶
/V3/shorten tables ¶
For A Long URL,
/V3/shorten encodes a URL and returns a short one.
Parameters
- Format(Optional) indicates the requested response format. Supported
Formats: JSON (default), XML, TXT.
- LongurlIs a long URL to be shortened (example: http://betaworks.com /).
- Domain(Optional) refers to a preferred domain; either bit. ly default or J. MP.
This affects the output value of URL.
- X_login(Optional) is the end-user's login when make requests on behalf
Another bit. ly user. This allows application developers to pass along
End user's bit. ly login.
- X_apikey(Optional) is the end-user's apikey when making requests on behalf
Of another bit. ly user. This allows application developers to pass along
An end user's bit. ly apikey.
Notes
- Long URLs shocould be URL-encoded. You can not include
A longurl in the request that has '&','? ',' # ', '', Or other Reserved
Parameters without first encoding it.
- Long URLs shocould not contain
Spaces: Any longurl with spaces will be rejected. All spaces shoshould be either percent
Encoded (% 20) or plus encoded (+). Note that tabs, newlines and trailing
Spaces are all indications of errors. Please remember to strip leading and
Trailing whitespace from any user input before shortening.
- Long URLs must have a slash
Between the domain and the path component. For example, http://example.com? Query = parameter is invalid, and instead shocould be formatted as http://example.com /? Query = parameter
- When including x_login and x_apikey, the shortened URL will be
Inserted into the history for the user specified by x_login. It will not be inserted
Into the history for the user specified by login.
URL: http://code.google.com/p/bitly-api/wiki/ApiDocumentation#/v3/shorten
Http://code.google.com/p/bitly-api/wiki/ApiBestPractices#Rate_Limiting
Usage:
T.
Get method:
Http://api.bit.ly/v3/shorten? Login = xxx & apikey = r_a2dc759... & longurl = http % 3A % 2f % 2fwww.baidu.com % 2f & format = xml
Where:
Login:
Username
Apikey:
Indicates the API key (allocated after the account is registered)
Longurl:
Indicates the long URL to be converted (the comment format must be correct)
Format:
Indicates the type of the returned value. Bit. ly supports three formats: JSON, XML, and TXT. The default value is JSON.
You can also add other parameters. For more information, see the preceding parameters.
Description.
Returned results after the request:
The URL is the shortened URL.
Summary:
1.
You need to register an account with bit. ly and use the user name and API key.
2.
Select the return value type, such as JSON, XML, and txt (JSON by default)
3.
Select the domain name shortening format: bit. ly, m.jp
4.
In addition, you may have to consider the countries supported by bit. ly before shortening the domain name. Avoid unexpected termination of software in other countries.
5.
There is a limit on the Access frequency. A single IP address allows up to five connections. The Access frequency is refreshed hourly.