Pasted paste services for humans

Using the Python Client

Get a URL, go be productive.

Pasted.tech has a command line interface written in python. This page will cover the installation of and use of the python command line interface.

Typical Client Usage

The pasted-client can be used in several different ways. Here are some of the more typical uses:

  • Using stdin and a pipe into the client
  • Using the path to a given file
  • Using in scripts with an input stream literal
  • Using it directly to create original content
  • Using it as a library within your own python application
Installation of the python command line client

Once the CLI and Library has been installed, the pasted command will be available to you.

$ pip install --user pasted-client
$ which pasted
/home/${USERNAME}/.local/bin/pasted

The command line interface can also be installed from source.

pip install --user git+https://github.com/cloudnull/pasted-client@master

Once the client is installed, see pasted --help for all available options.

Using the python command line client

Pipe the file to pasted and get back a URL to a raw paste of that file.

$ cat somefile | pasted
https://pasted.tech/pastes/89001a7fbbe57e6921a91b2ba166fa98e1579cd2.raw

You can also paste multiple using pasted with the file upload method. All pastes will be created in the order in which they're passed into the client.

$ pasted /path/to/file1 /path/to/file2 /path/to/file3
https://pasted.tech/pastes/294b43b2cec9919063be1a3b49e8722648424779.raw
https://pasted.tech/pastes/3c56f1d7f112e09002627d24b82446431df5039a.raw
https://pasted.tech/pastes/f9372ce11a7370c54135f3c708131de123caf90f.raw

pasted can be used in an input stream literal, "here-document, here-text, heredoc, hereis, here-string, here-script".

$ pasted <<EOF
> This is a heredoc (input stream literal)
> which is very useful in scripting.
> EOF
https://pasted.tech/pastes/346d5e8536297bdae6703d809fc7d90ae37deca7.raw

If original content needs to be created, the pasted command can be run without any arguments. Once content is created, press ctrl + d to exit the sub-shell and upload the content.

Using the python library.
from pasted_client import pasted
c = pasted.Client()
url = c.create_paste('Lorem ipsum.')
print(url)
https://pasted.tech/pastes/d363e6857bb08ddc400611a5308996aa64982551.raw

Alternatively, if you’re using your own deployment of Pasted, pass your own API endpoint to the client:

c = pasteraw.Client('http://pasted.example.tld/api/pastes')