Shorti is an API first (and only) URL shortener and click counter.
It is comprised of three end points.
HTTP Method | End Point | Function |
---|---|---|
POST | / | Create a new shortened URL |
GET | /:id | Redirect to full URL and track the click |
GET | /info/:id | What URL is shortend and the number of clicks |
The create end point will always require an API_KEY. The info end point can optionally require the API_KEY.
- Grab the source
- bundle install
- bundle exec rails db:setup
- bundle exec rails db:migrate
- bundle exec rails server
bundle exec rails spec
should do the trick.
KEY | Description |
---|---|
SHORTI_API_KEY | Controls access to create a new link. Optionally controls access to info |
SHORTI_BASE_URL | By default, Shorti will use the current request url, but you can optionally override it. |
SHORTI_INFO_API_KEY | If this key exists, Shorti will require an API Key for the info end point |
I have a version up on Heroku you can try (URL won't be that short).
curl -d "url=https://scottw.com&api_key=HOAGIES" https://shortilinks.herokuapp.com
Please note, this data will likely be cleared out every once in a while.
One outstanding item would be to track unique clicks (likely via IP Address). Not 100% yet if this will be added.
- If HTTP_ACCEPT = 'application/json' json data will be returned. Otherwise, responses will be return as plain text.