mnn.im API

All pastes and short urls expire after 14 days


Paste

Send a POST request to http://mnn.im/c with the following fields:

Valid language codes: text, c_cpp, clojure, coffee, css, csharp, golang, haskell, html, html_ruby, java, javascript, json, llvm, lua, markdown, objectivec, perl, php, python, ruby, rust, sh.

If you post the filename extension as lang, it will try match it with the appropriate code.

A successful response will return data like this:

{
    "paste":{
        "id": "abcd",
        "link": "http://mnn.im/pabcd",
        "raw": "http://mnn.im/rabcd",
        "lang_code": "text",
        "expiration_date": "2014-06-24T00:07:42.000+00:00"
    },
    "status": "success"
}

And a failed response will return this:

{
    "error_code": 1,
    "status": "error"
}

Markdown

If the paste lang is markdown the response will include a formatted URL:

{
    "paste":{
        "id": "abcd",
        "link": "http://mnn.im/pabcd",
        "raw": "http://mnn.im/rabcd",
        "lang_code": "markdown",
        "formatted": "http://mnn.im/fabcd",
        "expiration_date": "2014-06-24T00:07:42.000+00:00"
    },
    "status": "success"
}

Paste via cURL

curl --data-urlencode paste@example_file.py http://mnn.im/c

Ruby example

# paste.rb
# Usage: ruby paste.rb some_file.txt

require 'uri'
require 'net/http'
require 'json'

def paste(text, title="", lang_code="text")
    paste_data = Net::HTTP.post_form(URI.parse("http://mnn.im/c"), {"paste" => text, "title" => title, "lang" => lang_code})
    parsed = JSON.parse(paste_data.body)
    return parsed["paste"]["link"]
end

ARGV.each do|arg|
    file = File.read(arg)
    ext  = File.extname(arg).delete('.')
    puts paste(file, arg, ext)
end

Shell script


Shorten URL

Send a POST request to http://mnn.im/s with your long URL.

A successful response will return data like this:

{
    "url": {
        "id": "wxyz",
        "short_url": "http://mnn.im/uwxyz",
        "long_url": "https://boards.4chan.org/g/catalog",
        "expiration_date": "2014-06-24T00:07:42.000+00:00"
    },
    "status": "success"
}

And a failed response will return this:

{
    "error_code": 1,
    "status": "error"
}

Shorten via cURL

curl -d "http://example.com" http://mnn.im/s