MENU navbar-image

Introduction

URL Shortener API - Create, manage and redirect short URLs

This documentation aims to provide all the information you need to work with our API.

<aside>As you scroll, you'll see code examples for working with the API in different programming languages in the dark area to the right (or as part of the content on mobile).
You can switch the language used with the tabs at the top right (or from the nav menu at the top left on mobile).</aside>

Authenticating requests

This API is not authenticated.

Endpoints

GET api/urls

Example request:
curl --request GET \
    --get "http://shrt-production-alb-132772302.us-east-1.elb.amazonaws.com/api/urls" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"search\": \"example.com\",
    \"per_page\": 15,
    \"page\": 1
}"
const url = new URL(
    "http://shrt-production-alb-132772302.us-east-1.elb.amazonaws.com/api/urls"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "search": "example.com",
    "per_page": 15,
    "page": 1
};

fetch(url, {
    method: "GET",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Example response (400):

Show headers
cache-control: no-cache, private
content-type: application/json
x-ratelimit-limit: 60
x-ratelimit-remaining: 59
access-control-allow-origin: *
 

{
    "error": "Device ID required"
}
 

Request      

GET api/urls

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

search   string  optional  

Search term to filter URLs by original URL or short code. Must not be greater than 255 characters. Example: example.com

per_page   integer  optional  

Number of items to return per page (1-100). Must be at least 1. Must not be greater than 100. Example: 15

page   integer  optional  

Page number for pagination. Must be at least 1. Example: 1

POST api/urls

Example request:
curl --request POST \
    "http://shrt-production-alb-132772302.us-east-1.elb.amazonaws.com/api/urls" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"url\": \"https:\\/\\/www.example.com\\/very\\/long\\/path\\/to\\/resource\"
}"
const url = new URL(
    "http://shrt-production-alb-132772302.us-east-1.elb.amazonaws.com/api/urls"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "url": "https:\/\/www.example.com\/very\/long\/path\/to\/resource"
};

fetch(url, {
    method: "POST",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Request      

POST api/urls

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

Body Parameters

url   string   

The URL to be shortened. Must be a valid RFC 1738 compliant URL. Must not be greater than 2048 characters. Example: https://www.example.com/very/long/path/to/resource

GET api/urls/{id}

Example request:
curl --request GET \
    --get "http://shrt-production-alb-132772302.us-east-1.elb.amazonaws.com/api/urls/architecto" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "http://shrt-production-alb-132772302.us-east-1.elb.amazonaws.com/api/urls/architecto"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (404):

Show headers
cache-control: no-cache, private
content-type: application/json
x-ratelimit-limit: 60
x-ratelimit-remaining: 58
access-control-allow-origin: *
 

{
    "message": ""
}
 

Request      

GET api/urls/{id}

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

URL Parameters

id   string   

The ID of the url. Example: architecto

PUT api/urls/{id}

Example request:
curl --request PUT \
    "http://shrt-production-alb-132772302.us-east-1.elb.amazonaws.com/api/urls/1" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json" \
    --data "{
    \"url\": \"https:\\/\\/www.updated-example.com\\/new\\/path\"
}"
const url = new URL(
    "http://shrt-production-alb-132772302.us-east-1.elb.amazonaws.com/api/urls/1"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

let body = {
    "url": "https:\/\/www.updated-example.com\/new\/path"
};

fetch(url, {
    method: "PUT",
    headers,
    body: JSON.stringify(body),
}).then(response => response.json());

Request      

PUT api/urls/{id}

PATCH api/urls/{id}

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

URL Parameters

id   integer   

The ID of the url. Example: 1

Body Parameters

url   string   

The new URL to replace the existing one. Must be a valid RFC 1738 compliant URL. Must not be greater than 2048 characters. Example: https://www.updated-example.com/new/path

DELETE api/urls/{id}

Example request:
curl --request DELETE \
    "http://shrt-production-alb-132772302.us-east-1.elb.amazonaws.com/api/urls/1" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "http://shrt-production-alb-132772302.us-east-1.elb.amazonaws.com/api/urls/1"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "DELETE",
    headers,
}).then(response => response.json());

Request      

DELETE api/urls/{id}

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

URL Parameters

id   integer   

The ID of the url. Example: 1

GET api/resolve/{code}

Example request:
curl --request GET \
    --get "http://shrt-production-alb-132772302.us-east-1.elb.amazonaws.com/api/resolve/NG4" \
    --header "Content-Type: application/json" \
    --header "Accept: application/json"
const url = new URL(
    "http://shrt-production-alb-132772302.us-east-1.elb.amazonaws.com/api/resolve/NG4"
);

const headers = {
    "Content-Type": "application/json",
    "Accept": "application/json",
};

fetch(url, {
    method: "GET",
    headers,
}).then(response => response.json());

Example response (404):

Show headers
cache-control: no-cache, private
content-type: application/json
x-ratelimit-limit: 60
x-ratelimit-remaining: 57
access-control-allow-origin: *
 

{
    "message": "No se encontró la URL solicitada."
}
 

Request      

GET api/resolve/{code}

Headers

Content-Type      

Example: application/json

Accept      

Example: application/json

URL Parameters

code   string   

Example: NG4