meine
meine 🌒 - A CLI file manager and system utility built with Textual. It combines intuitive command parsing with rich t…
Rentry.co is a markdown-powered paste/publishing service with preview, custom urls and editing.
This repo holds the official Python clients for the rentry API. rentry.py is a command-line tool in a single file with no dependencies. rentry_client is an installable library. examples/ has one runnable script per API use case. If you'd rather write your own client, skip to the API reference.
pip install rentry
That gives you both the rentry command-line tool and the rentry_client library, with no dependencies.
The CLI also works as a single self-contained file:
wget https://raw.githubusercontent.com/radude/rentry/master/rentry.py -O ./rentry && chmod +x ./rentry
git clone https://github.com/radude/rentry.git cd rentry pip install .
The scripts in examples/ additionally want pip install -r requirements.txt, which pulls in python-dotenv for reading a .env file.
Both the CLI and the examples default to https://rentry.co. Copy .env.example to .env and adjust BASE_PROTOCOL / BASE_URL if you need to point them somewhere else, such as a local dev server.
$ rentry --help
Usage: rentry {new | edit | raw | fetch | delete | update} {-h | --help} {-u | --url} {-p | --edit-code} {-f | --field} {-v | --value} {-a | --auth-code} text
Commands:
new create a new entry
edit edit an existing entry's text
raw get raw markdown text of an existing entry
fetch fetch an entry's full details (text, metadata, dates) as JSON
delete delete an entry
update update an entry's edit code, url or modify code
Options:
-h, --help show this help message and exit
-u, --url URL url for the entry, random if not specified
-p, --edit-code EDIT-CODE edit code for the entry, random if not specified
-f, --field FIELD-NAME the field you wish to update (use on update command only)
-v, --value VALUE the value you wish to update (use on update command only)
-a, --auth-code CODE rentry-auth access code (use on raw command only)
Fields: (for use on update command only)
edit_code
url
modify_code
Examples:
rentry new 'markdown text' # new entry with random url and edit code
rentry new -p pw -u example 'text' # with custom edit code and url
rentry edit -p pw -u example 'text' # edit the example entry
cat FILE | rentry new # read from FILE and paste it to rentry
cat FILE | rentry edit -p pw -u example # read from FILE and edit the example entry
rentry raw -u example # get raw markdown text
rentry raw -u example -a CODE # with a rentry-auth access code
rentry raw -u https://rentry.co/example # -u accepts absolute and relative urls
rentry fetch -u example -p pw # fetch full details as JSON
rentry delete -p pw -u example # deletes an entry
rentry update -p pw -u example -f 'edit_code' -v 'new-pw' # Sets the edit code to something new
rentry update -p pw -u example -f 'url' -v 'new_url' # Sets the url to something new
rentry update -p pw -u example -f 'modify_code' -v 'm:1' # Sets the modify code to something new
rentry update -p pw -u example -f 'modify_code' -v '' # Unsets the modify code
Optional Url can be set (-u, --url URL)
It goes rentry.co/HERE. If no Url was set then random Url will be generated automatically.
Optional edit code can be set (-p, --edit-code EDIT-CODE)
It can be used to edit the entry later. If no edit code was set then random edit code will be generated automatically. Generated edit code will be shown to you only once, so remember it or save it. You can share this code with anyone so a group of people can edit the same entry.
from rentry_client import RentryClient
client = RentryClient() # or RentryClient('https://my-instance.example')
page = client.new(text='hello world', metadata={'PAGE_TITLE': 'Hello'})
print(page['url'], page['edit_code'])
client.edit(page['url_short'], page['edit_code'], text='updated!')
details = client.fetch(page['url_short'], page['edit_code'])
print(details)
Every method hands back the parsed API response as a dict. On success, response['status'] is '200'. When something goes wrong, the details are in response['content'] and response['errors'].
Each script in examples/ covers one use case and runs as-is:
| Script | Use case |
|---|---|
examples/new.py |
Create a page, with metadata |
examples/edit.py |
Update a page's text with its edit code |
examples/edit_upsert.py |
Change some metadata options without replacing the rest |
examples/edit_modify_code.py |
Set a modify code, then edit with it |
examples/edit_secret_metadata.py |
SECRET_* metadata: preserved by default, opt in to change it |
examples/edit_change_url.py |
Move a page to a new url and rotate its edit code |
examples/fetch.py |
Fetch a page's full details |
examples/delete.py |
Delete a page |
examples/raw.py |
Read raw text with a rentry-auth access code |
Send a standard POST request to the below endpoints.
NEW: The /api endpoints are CSRF-exempt, so you don't need a csrf token, cookies or a Referer header.
Starred fields are required. replace [url] with the actual URL in question (without brackets).
Example endpoint (Editing rentry.co/example): /edit/example
All fields that can be used as well as set (url, edit_code, modify_code) have new_ appended to their names when setting them.
The metadata field accepts either of two syntaxes:
KEY = value pairs, as on the website: "PAGE_TITLE = Hello\nCONTAINER_MAX_WIDTH = 600px"{"OPTION_DISABLE_VIEWS": true, "CONTENT_TEXT_COLOR": ["grey", "red"]}There are roughly 63 options in total, covering the page itself, sharing, safety, container and content styling, and secrets. All of them are documented at rentry.co/metadata-how.
Responses always come back with HTTP 200, so check the status value inside the JSON body instead. A client should handle these: 200 success, 400 validation failed (details in errors), 403 access denied (raw access codes), 404 entry does not exist, 405 wrong HTTP method, 429 rate limited (back off and retry later), 503 database temporarily unavailable.
Fields:
Anonymous creation is rate-limited per IP, roughly 10 per minute on rentry.co and configurable per instance. A 429 status means slow down and retry later.
You may provide a modify code to the edit_code field if one is set. Use this to give other people edit access to a page without the ability to steal it.
Fields:
OPTION = ) is removed. Text is kept when omitted.SECRET_* metadata (SECRET_EMAIL_ADDRESS, SECRET_RAW_ACCESS_CODE, SECRET_VERIFY) is protected against accidental removal. When update_secret_metadata is 'false' or omitted, any SECRET_* option already set on the entry is preserved as-is, no matter what the request sends for it. Omitted, blanked, and changed values are all ignored for those keys.
To modify or remove a previously-set SECRET_* option, pass update_secret_metadata as the string 'true'. Adding a brand-new SECRET_* option to an entry that didn't have it never requires the flag. Alternatively, update_mode 'upsert' leaves omitted SECRETs untouched as before.
Behavior change note: clients that previously removed SECRET_* options by omitting them in a full-replace edit will now silently keep them until they add update_secret_metadata 'true'.
Accepts GET or POST. Raw access is never open by default. Access codes are issued by rentry admins, so contact support@rentry.co if you need one. A page's SECRET_RAW_ACCESS_CODE metadata can only be set to a code that has already been issued, and anything else is rejected at edit time. Raw access is granted when either:
Denials return status 403 with a message explaining which condition failed.
Returns:
To fetch metadata, please use /fetch endpoint
Fields:
Returns:
Fields:
more like this
meine 🌒 - A CLI file manager and system utility built with Textual. It combines intuitive command parsing with rich t…
search projects, people, and tags