Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Clojure wrapper for the Bit.ly API

branch: master

Merge pull request #2 from danielsz/master

Back to working order
latest commit 08a83115b8
Geoff van der Meer authored November 03, 2013
Octocat-spinner-32 src more goodies November 02, 2013
Octocat-spinner-32 .gitignore Initial commit June 02, 2011
Octocat-spinner-32 README.md
Octocat-spinner-32 project.clj
README.md

clojure-bitly

Clojure mapping for the Bitly API v3.

Usage

Declare the dependency for your project:

(defproject your-project "1.0.0-SNAPSHOT"
  :description "Your project description"
  :dependencies [[org.clojure/clojure "1.2.1"]
                 [org.clojure/clojure-contrib "1.2.0"]
                 [clojure-bitly "0.1.2"]])

Then download dependencies:

lein deps

Require:

(ns sample (:require [bitly :as bitly]))

Shorten a url:

(def api-user "your-bitly-user")
(def api-key "your-bitly-apikey")

(bitly/with-auth api-user api-key
 (bitly/shorten "http://www.example.com/"))
> "http://j.mp/j5YLIl"

Shorten for a custom domain:

(bitly/with-auth api-user api-key
 (bitly/shorten "http://www.example.com/" {:domain "bit.ly"}))

Find statistics for a url:

(bitly/with-auth api-user api-key
  (let [short-url (bitly/lookup "http://www.example.com/")]
    (bitly/clicks short-url)))
> {:clicks [{:short_url "http://bit.ly/3hDSUb", :global_hash "3hDSUb", :user_clicks 956, :user_hash "3hDSUb", :global_clicks 956}]}

Lookup one url:

(bitly/with-auth api-user api-key
 (bitly/lookup "http://www.example.com/"))
> "http://bit.ly/bIXfqr"

Lookup many urls:

(bitly/with-auth api-user api-key
 (bitly/lookup ["http://www.example.com/" "http://www.google.com/"]))
> [{:url "http://www.example.com", :short_url "http://bit.ly/bIXfqr", :global_hash "bIXfqr"} {:url "http://www.google.com/", :short_url "http://bit.ly/2V6CFi", :global_hash "2V6CFi"}]

Building

lein deps
lein jar

License

Copyright (C) 2011 Geoff Wilson

Distributed under the Eclipse Public License, the same as Clojure.

Something went wrong with that request. Please try again.