pasteros

copy and paste your life

API

Create

Send JSON encoded POST request to http://pasteros.io/api/v1/create
Valid data format:
                    {
                    "name" : "PasteTitle", 
                    "content" : "your fun fun fun content", 
                    "language" : "python", 
                    "visible" : false, 
                    "tag" : "myProjectY"
                    }
                    

visible corresponds to whether or not the paste shows up in the most recent 15 pastes on the main page
tag tags a paste so pastes can be grouped together. example tag

Response


                    {
                    "id" : "PASTE_ID",
                    "delete_id" : "DELETE_ID"
                    }
                    

Pastes can be accessed at https://pasteros.io/PASTE_ID. Pastes can be deleted at https://pasteros.io/PASTE_ID/delete/DELETE_ID

Get

Send JSON encoded POST request to http://pasteros.io/api/v1/get
Valid data format:
                    {
                    "id" : "PASTE_ID"
                    }
                    

Response

                    {
                    "name" : "fancyPaste",
                    "content" : "my fancy fancy content",
                    "time" : "2014-04-20 04:55:16.822237",
                    "language" : "bash",
                    "visible" : true,
                    "tag" : "myProjectY"
                    }
                    


Example


Creating a paste with curl:
curl -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '{"name":"mainFile.cpp", "content":"my fun content", "language":"c++", "visible":true, "tag":"myProject"}' https://pasteros.io/api/v1/create
                    
Example output:
                    {"id":"559a02fca369b","delete_id":"19c79082a3dcffac67eb"}
                    

Retreiving a paste with curl:
                    curl -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d '{"id":"55a344b4bf2e3"}' https://pasteros.io/api/v1/get
                    
Example output:
                    {"name":null,"content":"CPPFLAGS=\"-I\/include -I\/usr\/include\" CFLAGS=-static LDFLAGS=\"-L\/usr\/lib -L\/lib -static\" \\\r\n.\/configure --prefix=\/usr --without-readline","time":"2015-07-13 04:55:16.822237","language":"plain","visible":true,"tag":"snacklinux"}
                    


With v1 simple create:

curl -silent -H "Expect:" --data-binary @test.txt https://pasteros.io/api/v1/simplecreate 
                    
Paste ID output:
                    552235abcfacd
                    

Using the simple create API, only the content needs to be present. Visibility, paste name and syntax highlighting are set to default.

Valid language values: The request returns the paste ID or an error message if something went wrong.




Clients

.bashrc function and alias

                    function uploadText {
                    pasteid=$( curl -silent -H "Expect:" -X POST --data-binary @- https://pasteros.io/api/v1/simplecreate | tail -1)
                    echo "https://pasteros.io/$pasteid"  | xclip -selection c
                    }
                    alias paste=uploadText
                    
Usage:
                    cat myfancyfile.py | paste
                    
The resulting paste URL will be copied to the clipboard.

Python client

Usage:
usage: pastes.py [-h] [-n NAME] [-t TAG]
                 [-l {bash,c++,c#,css,diff,java,javascript,perl,php,plain,python,ruby,sql,xml}]
                 file [file ...]

positional arguments:
  file                  Put either a file, or rawtext

optional arguments:
  -h, --help            show this help message and exit
  -n NAME, --name NAME  Name of the paste
  -t TAG, --tag TAG     Tag description of paste
  -l --language {bash,c++,c#,css,diff,java,javascript,perl,php,plain,python,ruby,sql,xml}    Programming language


                    
Example:
pastes.py -l php -n "Pasteros API controller" controllers/Api_Controller.php

pastes.py --language c++ --tag myCurrentCPlusPlusProject "#include  int main(){std::cout << 1 << std::endl;}"
                    
The client will return the link to the pastes as well as the delete URL