My space in the world

Code is poetry

Posted by Sayak
September - 16 - 2013

EDIT: Read the updated plan here: http://www.sayakbanerjee.com/2013/09/16/new-paste-kde-org-api-specs/#comment-10606

Today, I released a stable version of Sticky Notes, the app behind paste.kde.org. This release is a complete rewrite of the entire app using the Laravel 4 framework. The main intention behind a rewrite was not only to cope up with the feature requests of the application (for Sticky Notes as a product, not necessarily related to KDE Pastebin itself) and an opportunity to see how far PHP has come as a “real-OOP” language.

Since my KDE work is mostly web development oriented, I often miss out the fun involved with “hardcore coding”. However, this experience with Laravel not only changes my view about PHP but has been a good learning opportunity for me. So if you are a PHP developer with a knack of doing unconventional things, I strongly recommend Laravel to you if you haven’t tried it already.

Now coming to the point, due to the massive rewrite involved, I needed to deprecate some bad programming practices that were there in the old pastebin API. I have come to understand that there are indeed a few more than a handful of apps that uses the paste.kde.org API. So if you are reading this, and you are the author of an app that uses the KDE Pastebin API, please refer to the new API specifications. If you have any questions, please create a ticket here or on bugs.kde.org (component paste.kde.org). You can also find me at #kde-sysadmin on freenode (nick: sayakb).

There are a few things to note:

  • I will be loading the new API to paste.kde.org on 1st October 2013 12:00am CST and I’ll move the old API to pasteapi.kde.org. So if you are not able to publish the new API changes by 1st October, you can simply point your code to the fallback URL. However, pasteapi.kde.org will be temporary and will be nuked by the end of this year.
  • I have tried to keep things very similar to how they were before from an API consumer point of view. So from the top of my head, other than removing the annoying paste_ prefixes for the request parameters and some new response error codes, not much changed.
  • The URL for the requests have changed though – as Laravel uses a different approach towards URL routing. The create endpoint now supports POST only (I always wanted to remove GET as transmitting an optional password for the paste as GET is a no-no), while the list and show endpoints support GET requests.
  • If you are looking for some example code, look at this api-client branch here: https://github.com/sayakb/sticky-notes/tree/api-client
  • You can test out the new version of the API here: http://sandbox.paste.kde.org/

A mirror of the entire codebase is also available at projects.kde.org here: https://projects.kde.org/paste-kde-org

5 Responses to “New paste.kde.org API specs”

  1. Laszlo Papp says:

    Hmm, that is great!

    As I have been a curl/wgetpaste user for a while for convenience when I can paste right in the command line, I may be interested in putting a qt client together. I would prefer using and advocating KDE for this. :-)

    It could also be a nice test bed for the Qt 5 json parser for my further plans with that. Cannot guarantee I can find the time anytime soon, so if someone has more time, please go ahead…

    There has been two projects in the past with the name of “kpaste”, so that is probably taken, but how about cutepaste?

    It would be nice to have something in the official distribution repositories to be a true replacement for the aforementioned utils. I now know that there are tools like pastebinit already using the paste.kde.org API, but still: I prefer to have a tool where the KDE pastebin application is the default rather than users needing to set up on their own which will demotivate many including me.

    Once that is done, the client backend could target different platforms, like Android, Blackberry, iOS in the future, maybe even N9 (Harmattan) if someone has the motivation, and so forth.

    How does that sound?

    Thank you for your work again. :-)

    • Sayak says:

      That sounds awesome! And cutepaste is a nice name. Let me check with the pastebinit dev on what he plans to do with it, because last time I checked (which was last week), it was unfortunately broken. But in any case, it is a generic tool like you said and a dedicated one will be nice to have. Right now, a dedicated utility for KDE is limited to the paste plasmoid.

  2. I wonder how we should handle this in the Plasma Pastebin widget. We could update right now, ship it ASAP, but that would mean even users who are upgrading directly to the new release, will see a few days of non-working pastebin widget.

    Also, everybody using git master will see it breaking.

    Then, how can we test if everything works?

    I might not understand this upgrading strategy precisely, but from my POV (and I’m sure the requirements of Plasma’s pastebin are not that unique), it’s impossible to make this a transparanet upgrade for our users.

    Better would be: deprecate the old API, but keep it in place. Add the new API as an option (possibly under a new path), announce when the old API will be removed, that period should be long enough for all our users to upgrade.

    • Sayak says:

      Well, I can do this: let’s discuss what you guys actually use. I can write a “compatibility” layer over the new API to have it work with the old one. So based on the input I get from you, you might not need to change anything at all (considering mainly you guys use the create endpoint only).

      EDIT: Looks like this is not straightforward. The problem here is, earlier the paste data was sent to the index page, which now I cannot use to process API requests. So I think I can go with what you suggested – I can publish the new pastebin at pastebin.kde.org and you guys change your code to point to it. Please note that pastebin.kde.org is already an alias for paste.kde.org, so it will always remain even after we are done with the transition. Now for users who haven’t updated, I’ll disable all but the API bits on paste.kde.org and they can keep using it till it is finally removed or they upgrade their plasma-addons – while regular web users will be taken to pastebin.kde.org instead. But you still need to tell me:

      1. How long do you think this transition period will be, and
      2. What is the data that you send over to the API currently

  3. Laszlo Papp says:

    OK, thank your for your reply. I left a few notes in the bugreport below. Perhaps, it should have gone to github rather than KDE, so pardon me.

    https://bugs.kde.org/show_bug.cgi?id=325483

Leave a Reply

About Me

A son, brother and friend. Enjoys scripting and making small bits of apps here and there. Wants to conquer the world (well, who doesnt). A geek who has an obsession for ponies. Loves acoustic and wants to play guitar sitting on the Hollywood hill one day!

A Word About KDE

KDE is a versatile software compilation for all platforms. It is an intuitive and powerful desktop environment that focuses on finding innovative solutions to old and new problems, and creating a vibrant, open atmosphere for experimentation.

» http://www.kde.org