bit.lyのAPI
使ってみました。
ドキュメントはGoogleCodeで公開されています。
登録
bit.lyにユーザ登録をすると使えます。
画面右上のアカウントからAPIキーを確認が出来ます。
API Key
You can provide your API key to 3rd party apps instead of giving them your password. If you think a 3rd party is using your API key inappropriately, you can reset it.
APIキーをアプリを開発したり、使用する、3rdパーティーに教えても良いです。
JSONのリクエストを許可している時点でAPIキーが晒されるのは当たり前なので。
3rdパーティーがAPIキーを不正に利用していそうだったら、APIキーをリセットしてね。ということ。
概要
APIキーの確認はこちら http://bit.ly/account/your_api_key
shorten
longURLを与えると短縮されたURLが返ってきます
{ "errorCode": 0, "errorMessage": "", "results": { "http://www.yahoo.co.jp/": { "hash": "INPsu", "shortCNAMEUrl": "http://bit.ly/ak1LUa", "shortKeywordUrl": "", "shortUrl": "http://bit.ly/ak1LUa", "userHash": "ak1LUa" } }, "statusCode": "OK" }
expand
URLを戻す
shortUrlにbit.lyのURLを与えます
もしくは
hashにhashを与えます
{ "errorCode": 0, "errorMessage": "", "results": { "ak1LUa": { "longUrl": "http://www.yahoo.co.jp/" } }, "statusCode": "OK" }
{ "errorCode": 0, "errorMessage": "", "results": { "INPsu": { "longUrl": "http://www.yahoo.co.jp/" } }, "statusCode": "OK" }
info
URL情報
shortUrlにbit.lyのURLを与えます
もしくは
hashにhashを与えます
{ "errorCode": 0, "errorMessage": "", "results": { "ak1LUa": { "calais": {}, "calaisId": "", "calaisResolutions": {}, "contentLegth": 26698, "contentLength": "", "contentType": "text/html; charset=utf-8", "exif": {}, "fileExtension": "", "globalHash": "INPsu", "hash": "INPsu", "htmlMetaDescription": "", "htmlMetaKeywords": "", "htmlTitle": "Yahoo! JAPAN", "id3": {}, "indexed": 1256133396, "keyword": "", "keywords": [], "longUrl": "http://www.yahoo.co.jp/", "metacarta": [], "mirrorUrl": "", "robotsAllowed": true, "shortenedByUser": "hebita164", "surbl": 0, "thumbnail": {}, "urlFetched": "http://www.yahoo.co.jp/", "userHash": "ak1LUa", "users": [], "version": 1.0 } }, "statusCode": "OK" }
stats
ステータス情報
shortUrlにbit.lyのURLを与えます
もしくは
hashにhashを与えます
トラフィック、リファラー情報が分かります。
{ "errorCode": 0, "errorMessage": "", "results": { "clicks": 39532, "hash": "INPsu", "referrers": { "": { "direct": 7014 }, "1130yt.blog.so-net.ne.jp": { "/2010-02-20": 3 }, "192.168.100.230": { "/o_uccitter/": 1 }, "aboutnow.jp": { "/themes/test": 1 }, ・ ・ ・ }, "userClicks": 1, "userHash": "ak1LUa", "userReferrers": { "": { "direct": 1 } } }, "statusCode": "OK" }
errors
エラーコード
bit.ly APIのエラーコードが分かります。
リクエストサンプル
http://api.bit.ly/errors?version=2.0.1&login=hebita164&apiKey=R_878fa025e5a0ddab5cfcfe56544e0bcf