Maksudur Rahman Maateen edited this page Jan 23, 2016 · 2 revisions

#Open API Documentation

We have developed an API for developers. With this API, developers can use your website to create short URL by requesting in a pre-determined manner.

Let's say you have set up Py-URL-Shortener as http://example.com.

==API version-1.0==

####Creation

  • API:

  • Parameter:

    • long_url = The Original URL of which you wanna build a short URL.
  • HTTP Method:

    • POST
  • Return values:

    • state : 'ok' or 'error'
    • long_url : Original URL
    • short_url : Short URL
    • 'message' : If state is ok, then it is Null. Otherwise, it contains the error message.

Note: The data come to the API must be marked as JSON. Also, the data returned by the API will be in JSON format.

####Example

On Terminal we will run the following command:

curl -H "Content-Type: application/json" -X POST -d '{"long_url":"http://stackoverflow.com/questions/7172784/how-to-post-json-data-with-curl-from-terminal-commandline-to-test-spring-rest"}' http://example.com/api/v1.0/

Hope, it will produce something like below:

{
  "long_url": "http://stackoverflow.com/questions/7172784/how-to-post-json-data-with-curl-from-terminal-commandline-to-test-spring-rest",
  "message": "",
  "short_url": "http://example.com/zx0kcP",
  "state": "ok"
}

That's all till now.

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.