Links
/v3/expand
Given a bitly URL or hash (or multiple), returns the target (long) URL.
Authentication: oauth2 / api key
Parameters
- shortUrl - refers to one or more bitly links. e.g.:
http://bit.ly/1RmnUTorhttp://j.mp/1RmnUT. - hash - refers to one or more bitly hashes. e.g.:
2bYgqRora-custom-name.
Note
- Either
shortUrlorhashmust be given as a parameter. - The maximum number of
shortUrlandhashparameters is 15.
Return Values
- short_url - an echo back of the shortUrl request parameter.
- hash - an echo back of the hash request parameter.
- user_hash - the corresponding bitly user identifier.
- global_hash - the corresponding bitly aggregate identifier.
- error - indicates there was an error retrieving data for a given shortUrl or hash. An example error is "NOT_FOUND".
- long_url - the URL that the requested short_url or hash points to.
Example Request
API Address: https://api-ssl.bitly.com GET /v3/expand?access_token=ACCESS_TOKEN&shortUrl=http%3A%2F%2Fbit.ly%2Fze6poY
Example Response
{
"data": {
"expand": [
{
"global_hash": "900913",
"long_url": "http://google.com/",
"short_url": "http://bit.ly/ze6poY",
"user_hash": "ze6poY"
}
]
},
"status_code": 200,
"status_txt": "OK"
}
/v3/info
This is used to return the page title for a given bitly link.
Authentication: oauth2
Parameters
- hash refers to one or more bitly hashes, (e.g.:
2bYgqRora-custom-name). - shortUrl refers to one or more bitly links e.g.:
http://bit.ly/1RmnUTorhttp://j.mp/1RmnUT. - expand_user - optional
true|false- include extra user info in response.
Return Values
- short_url - this is an echo back of the shortUrl request parameter.
- hash - this is an echo back of the hash request parameter.
- user_hash - the corresponding bitly user identifier.
- global_hash - the corresponding bitly aggregate identifier.
- error - indicates there was an error retrieving data for a given shortUrl or hash. An example error is "NOT_FOUND".
- title - the HTML page title for the destination page (when available).
- created_by - the bitly username that originally shortened this link, if the link is public. Otherwise, null.
- created_at - the epoch timestamp when this bitly link was created.
Example Request
API Address: https://api-ssl.bitly.com GET /v3/info?access_token=ACCESS_TOKEN&shortUrl=http%3A%2F%2Fbit.ly%2F1RmnUT
Example Response
{
"data": {
"info": [
{
"created_at": 1212926400,
"created_by": null,
"global_hash": "1RmnUT",
"short_url": "http://bit.ly/1RmnUT",
"title": "Google",
"user_hash": "1RmnUT"
}
]
},
"status_code": 200,
"status_txt": "OK"
}
/v3/link/lookup
This is used to query for a bitly link based on a long URL.
Authentication: oauth2
Parameters
- url - one or more long URLs to lookup.
Return Values
- url - an echo back of the url parameter.
- aggregate_link - the corresponding bitly aggregate link (global hash).
Example Request
API Address: https://api-ssl.bitly.com GET /v3/link/lookup?url=http%3A%2F%2Fgoogle.com%2F&access_token=ACCESS_TOKEN
Example Response
{
"data": {
"link_lookup": [
{
"aggregate_link": "http://bit.ly/2V6CFi",
"url": "http://www.google.com/"
}
]
},
"status_code": 200,
"status_txt": "OK"
}
/v3/shorten
Given a long URL, returns a bitly short URL.
Authentication: oauth2 / api key
Parameters
- longUrl - a long URL to be shortened (example:
http://betaworks.com/). - domain - (optional) refers to a preferred domain; either
bit.ly,j.mp, orbitly.com, for users who do NOT have a custom short domain set up with bitly. This affects the output value of url. The default for this parameter is the short domain selected by each user in his/her bitly account settings. Passing a specific domain via this parameter will override the default settings for users who do NOT have a custom short domain set up with bitly. For users who have implemented a custom short domain, bitly will always return short links according to the user's account-level preference.
Notes
- Long URLs should be URL-encoded.
You can not include a longUrl in the request that has
&,?,#, or other reserved parameters without first encoding it. - Long URLs should not contain spaces: any longUrl with spaces will be rejected.
All spaces should be either percent encoded
%20or 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=parameteris invalid, and instead should be formatted ashttp://example.com/?query=parameter. - The default value for the
domainparameter is selected by each user from within his/her bitly account settings at http://bitly.com/a/account.
Return Values
- new_hash - designates if this is the first time this long_url was shortened by this user. The return value will equal 1 the first time a long_url is shortened. It will also then be added to the user history.
- url - the actual link that should be used, and is a unique value for the given bitly account.
- hash - a bitly identifier for long_url which is unique to the given account.
- global_hash - a bitly identifier for long_url which can be used to track aggregate stats across all bitly links that point to the same long_url.
- long_url - an echo back of the longUrl request parameter. This may not always be equal to the URL requested, as some URL normalization may occur (e.g., due to encoding differences, or case differences in the domain). This long_url will always be functionally identical the the request parameter.
When the output format is txt, the only response is the short url.
Example Request
API Address: https://api-ssl.bitly.com GET /v3/shorten?access_token=ACCESS_TOKEN&longUrl=http%3A%2F%2Fgoogle.com%2F
Example Response
{
"data": {
"global_hash": "900913",
"hash": "ze6poY",
"long_url": "http://google.com/",
"new_hash": 0,
"url": "http://bit.ly/ze6poY"
},
"status_code": 200,
"status_txt": "OK"
}
/v3/user/link_edit
Changes link metadata in a user's history.
Authentication: oauth2
Parameters
- link - the bitly link to be edited.
- title - optional the title of this bitmark.
- note - optional a description of, or note about, this bitmark.
- private - optional boolean
trueorfalseindicating privacy setting (defaults to user-level setting). - user_ts - optional timestamp as an integer epoch.
- archived - optional boolean
trueorfalseindicating whether or not link is to be archived. - edit - a comma separated string of fields to be edited.
ie: to edit the note field you also need to pass
edit=note.
Notes
- Any fields specified in the
editparameter are required. - Because link metadata is modified asynchronously, it may take a few moments for changes made via this API method to update.
Return Values
- link - an echo back of the edited bitly link.
Example Request
API Address: https://api-ssl.bitly.com GET /v3/user/link_edit?edit=note¬e=News+from+a+great+record+label+%23music&access_token=ACCESS_TOKEN&link=http%3A%2F%2Fbit.ly%2FJGVkUk
Example Response
{
"data": {
"link_edit": {
"link": "http://bit.ly/JGVkUk"
}
},
"status_code": 200,
"status_txt": "OK"
}
/v3/user/link_lookup
This is used to query for a bitly link shortened by the authenticated user based on a long URL.
Authentication: oauth2
Parameters
- url - one or more long URLs to lookup.
Return Values
- url - an echo back of the url parameter.
- link - the corresponding bitly link (short URL).
- aggregate_link - the corresponding bitly aggregate link (global hash).
Example Request
API Address: https://api-ssl.bitly.com GET /v3/user/link_lookup?url=http%3A%2F%2Fgoogle.com%2F&access_token=ACCESS_TOKEN
Example Response
{
"data": {
"link_lookup": [
{
"aggregate_link": "http://bit.ly/2V6CFi",
"link": "http://bit.ly/zhheQ9",
"url": "http://www.google.com/"
}
]
},
"status_code": 200,
"status_txt": "OK"
}
/v3/user/link_save
Saves a link as a bitmark in a user's history, with optional pre-set metadata. (Also returns a short URL for that link.)
Authentication: oauth2
Parameters
- longUrl - the URL to be saved as a bitmark.
- title - optional the title of this bitmark.
- note - optional a description of, or note about, this bitmark.
- private - optional boolean
trueorfalseindicating privacy setting (defaults to user-level setting). - user_ts - optional timestamp as an integer epoch.
Notes
- Long URLs should be URL-encoded.
You can not include a longUrl in the request that has
&,?,#, or other reserved parameters without first encoding it. - Long URLs should not contain spaces: any longUrl with spaces will be rejected.
All spaces should be either percent encoded
%20or 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 saving. - Long URLs must have a slash between the domain and the path component.
For example,
http://example.com?query=parameteris invalid, and instead should be formatted ashttp://example.com/?query=parameter
Return Values
- link - the bitly short URL for the provided longUrl, specific to this user.
- aggregate_link - a bitly short URL for the provided longUrl, which can be used to track aggregate stats across all bitly links that point to the same longUrl.
- new_link - returns
1if the authenticated user is saving this link for the first time,0if the user has previously saved it. - long_url an echo back of the longUrl request parameter. This may not always be equal to the URL requested, as some URL normalization may occur (e.g., due to encoding differences, or case differences in the domain). This long_url will always be functionally identical the the request parameter.
Example Request
API Address: https://api-ssl.bitly.com GET /v3/user/link_save?access_token=ACCESS_TOKEN&longUrl=http%3A%2F%2Fmergerecords.com%2F
Example Response (Newly Saved Link)
{
"data": {
"link_save": {
"aggregate_link": "http://bit.ly/JGVkUl",
"link": "http://bit.ly/JGVkUk",
"long_url": "http://mergerecords.com/news",
"new_link": 1
}
},
"status_code": 200,
"status_txt": "OK"
}
Example Response (Previously Saved Link)
{
"data": {
"link_save": {
"aggregate_link": "http://bit.ly/a58InP",
"link": "http://bit.ly/HjFd4H",
"long_url": "http://mergerecords.com",
"new_link": 0
}
},
"status_code": 304,
"status_txt": "LINK_ALREADY_EXISTS"
}