This API implements a HTTP client that connects Bit.ly API
API url: https://api-shorten-test.herokuapp.com
This API allows you to:
-
Shorten URLs
-
Get information about a shortened URL
-
Get stadistics of a certain shortened URL
-
Get all URLs previously created
POST /api/v1/links/shorten
It shorten and returns a new url
Payload
{
"url": "http://google.com"
}
Success ✅
HTTP 200
"status_code": 200,
"status_txt": "OK",
"data": {
"url": "http://bit.ly/2NeKoad",
"hash": "2NeKoad",
"global_hash": "3j4ir4",
"long_url": "http://google.com/",
"new_hash": 0
}
Errors ❌
HTTP 422
{
"error": "missing url param",
"code": "unprocessable_entity"
}
GET /api/v1/links/
It returns all urls previously created
HTTP 200
{
{
"id": 1,
"response": {
"status_code": 200,
"status_txt": "OK",
"data": {
"url": "http://bit.ly/2BJQL0z",
"hash": "2BJQL0z",
"global_hash": "2BFSAvy",
"long_url": "http://bitconcept.io/",
"new_hash": 0,
"title": "Bit Concept"
}
},
"created_at": "2019-03-11T19:47:43.577Z",
"updated_at": "2019-03-11T19:47:43.577Z"
},
{
"id": 2,
"response": {
"status_code": 200,
"status_txt": "OK",
"data": {
"url": "http://bit.ly/2BJQL0z",
"hash": "2BJQL0z",
"global_hash": "2BFSAvy",
"long_url": "http://bitconcept.io/",
"new_hash": 0,
"title": "Bit Concept"
}
},
"created_at": "2019-03-11T19:47:43.577Z",
"updated_at": "2019-03-11T19:47:43.577Z"
}
}
Errors ❌
HTTP 422
{
"error": "missing url param",
"code": "unprocessable_entity"
}
This API uses Rails 5.2.2 and Ruby 2.4.1
Open your favorite Terminal and run these commands.
- Clone repository
$ git clone https://github.com/devpolish/shortener_rails_api.git
- Installing dependencies
$ cd shortener_rails_api
$ RAILS_ENV=development bin/bundle install
- Create databases
$ rake db:migrate
$ rspec specs/*