Code Monkey home page Code Monkey logo

api's Introduction

1pt.co API

The 1pt.co API is public so anyone can create a shortened URL

Endpoint: csclub.uwaterloo.ca/~phthakka/1pt-express

Warning

The old endpoint (csclub.uwaterloo.ca/~phthakka/1pt) is still live but will soon be deprecated.

/addURL

Method: POST

Parameter Description Example
long Required - The long URL to shorten https://www.param.me
short Optional - The part after 1pt.co/ that will redirect to your long URL. If this paramter is not provided or the requested short URL is already taken, it will return a random 5-letter string param

Example Response

{
  "message": "Added!",
  "short": "param",
  "long": "https://www.param.me"
}

With this example 1pt.co/param will redirect to https://www.param.me

Note

If the requested short is taken, it will return a random 5-letter string along with the flag receivedRequestedShort: false

api's People

Contributors

paramt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

api's Issues

Add Docker deployment mode

I am a developer from China, and it is not very convenient to use Google to deploy by myself. Will the author consider creating a Docker deployment method?

Random short is generated if the given short already exists

>>> r = requests.get("https://api.1pt.co/addURL", params={"long": "https://github.com/rpdelaney", "short": "rpdgh"})
>>> r.json()
{'status': 201, 'message': 'Added!', 'short': 'rpdgh', 'long': 'https://github.com/rpdelaney'}
>>> r = requests.get("https://api.1pt.co/addURL", params={"long": "https://doesnot.exist.com", "short": "rpdgh"})
>>> r.json()
{"status": 201, "message": "Added!", "short": "pqgku", "long": "https://doesnot.exist.com"}

I expect an error from the second request, since the given short already exists. Instead, a URL with a random short is created.

API 503

Could you check it please? got 503

curl -X POST "https://csclub.uwaterloo.ca/~phthakka/1pt-express/addURL?long=https://www.param.me"

HTTP/2 503
strict-transport-security: max-age=26784000
cache-control: private, max-age=0, must-revalidate
content-length: 385
content-type: text/html; charset=iso-8859-1
date: Mon, 11 Sep 2023 06:53:39 GMT
server: Apache/2.4.57 (Debian)

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>503 Service Unavailable</title>
</head><body>
<h1>Service Unavailable</h1>
<p>The server is temporarily unable to service your
request due to maintenance downtime or capacity
problems. Please try again later.</p>
<hr>
<address>Apache/2.4.57 (Debian) Server at csclub.uwaterloo.ca Port 443</address>
</body></html>

Hitting API responses back with my application html

Trying to Create an Application with this API, but the response is not the one I get when hitting form Thunder Client or Postman.

The request sent:

 let headersList = {
    "Accept": "*/*",
    
   }
   
   let reqOptions = {
     url: "csclub.uwaterloo.ca/~phthakka/1pt/addURL.php?url=google.com&cu",
     method: "GET",
     headers: headersList,
   }
   
   let response = await axios.request(reqOptions);
   console.log(response.data);
 

The Console log:

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8" />

    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <meta name="theme-color" content="#000000" />
    <meta
      name="description"
      content="URL Shortener"
    />

    <link rel="manifest" href="/manifest.json" />
   
    <link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-Zenh87qX5JnK2Jl0vWa8Ck2rdkQ2Bzep5IDxbcnCeuOxjzrPF/et3URy9Bv1WTRi" crossorigin="anonymous">

    <title>React App</title>
  <script defer src="/static/js/bundle.js"></script></head>
  <body>
    <noscript>You need to enable JavaScript to run this app.</noscript>
    <div id="root"></div>
   
    <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-OERcA2EqjJCMA+/3y+gxIOqMEjwtxJY7qPCqsdltbNJuaOe923+mo//f6V8Qbsw3" crossorigin="anonymous"></script>

  </body>
</html>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.