API Access

Hi! We have an API for pasting too! You just need a client that's capable of making POST requests.

You will need an API key to use the API. You can get one by Signing in!

The POST request should be made to this URL: https://ada-young.com/pastebin/api/v1/create

The following parameters are available:

POST Parameter Required/Optional Description
content Required This is the content of your paste. It's the same thing you'd paste in big white box on the site.
format Required This is the format of your paste. Supported values are plain, html, and log.
title Optional This is the title of your paste. A title above 50 characters is silently truncated.
tags Optional Tags help classify your paste and allow people to search for them. You can supply multiple tags separated by space here. Tags longer than 15 characters are silently truncated. Non-alphanumeric characters are silently stripped. Duplicate tags are dropped. A maximum of 15 tags are accepted.

Here is how you create a new paste using Python:

          import requests

          url = 'https://ada-young.com/pastebin/api/v1/create'
          headers = {
            "Authorization": "Bearer YOUR-API-KEY",
            "Content-Type": "application/json",
          }

          data = {
            "content": "Hello, World!",
            "format": "plain",
            "title": "Hello, World!",
            "tags": "hello world",
          }

          response = requests.post(url, headers=headers, json=data)
          print(response.json())
        

Here's a working example with Mudlet using an alias and the getClipboardText function:

        Alias pattern: ^apaste( .+)?$
        Script:

        cecho("\n[Ada]: Attempting to paste... please wait!")
        toPastebin(matches[2] or '')
        --------------------------------------------------------------------------------

        Script name: Pastebin
        Registered Event Handlers: sysPostHttpDone, sysPostHttpError
        Script:

        local api_key = "YOUR-API-KEY"

        local url = "https://ada-young.com/pastebin/api/v1/create"

        local headers = {
          ["Authorization"] = "Bearer " ..api_key,
          ["Content-Type"] = "application/json",
        }

        function toPastebin(title)
          local data = {
            ["content"] = getClipboardText(),
            ["format"] = "html",
            ["title"] = title,
            -- Adjust default tags or parametrize them as needed
            ["tags"] = f("{gmcp.Char.Status.name} {gmcp.Char.Status.class}"),
          }

          postHTTP(yajl.to_string(data), url, headers)
        end

        function Pastebin(event, one, two)
          if event == "sysPostHttpDone" then
            local response = yajl.to_value(two)
            cecho("\n[Ada]: Success! " ..response.url)
          elseif event == "sysPostHttpError" then
            cecho("\n[Ada]: Oop, error! " ..one)
          end
        end
      

Once you have setup the alias and the script, you can:

  • Select text as usual in your Mudlet main window
  • Right click and then click on Copy HTML menu item to copy
  • Type apaste in the Mudlet command line!
  • Or type apaste Some title! to paste with a title!

Newer versions of Mudlet (v4.14+) have a feature called addCommandLineMenuEvent which may make it possible to even add a menu item to right-click and paste in one go! See if you can make that work!