Skip to main content

aiorentry

Asynchronous API client for rentry.co (mirror: rentry.org)

GitHub Actions Workflow Status codecov PyPI - Version GitHub License

About

This package allows you to interact with the rentry.co (or rentry.org) service.

Rentry.co is a markdown pastebin and publishing service that offers features such as previews, custom URLs, and editing.

Please note that this library is not developed by the official authors of rentry.co. It replicates the functionality of the official console utility, but provides it as an asynchronous API client. With this package you can manage your pages: create, edit and delete, as well as get data in text, PNG or PDF formats. All directly from your asynchronous Python application.

Installation

pip install aiorentry

Setup client

You can setup client in 2 ways:

As classic object

[!CAUTION] If you prefer the classic way, you should call await client.setup() during initialization and await client.close() during completion

import asyncio

from aiorentry.client import Client


async def main():
    client = Client('https://rentry.co')
    await client.setup()

    # Your code here

    await client.close()


asyncio.run(main())

As async context manager

import asyncio

from aiorentry.client import Client


async def main():
    async with Client('https://rentry.co') as client:
        # Your code here


asyncio.run(main())

Examples

Create new page

...
# Create new page
page = await client.new_page(
    '## Hello world from awesome API',
)

print(page)
...
Page(url='m2e2wpe8', edit_code='hUHeRUei', text='## Hello world from awesome API')
...
# Create new page with custom url and edit_code
awesome_page = await client.new_page(
    '## Hello world from awesome API',
    url='awesome-url',
    edit_code='qwerty=)'
)

print(awesome_page)
...
Page(url='awesome-url', edit_code='qwerty=)', text='## Hello world from awesome API')

Edit page

...
# Edit page
await client.edit_page(
    '### Updated Hello world',
    url='awesome-url',
    edit_code='qwerty=)',
)
...

Delete page

...
# Delete page
await client.delete_page(
    url='awesome-url',
    edit_code='qwerty=)',
)
...

Get raw page text

[!NOTE] This rentry functionality has limitations now. You can't just view the source text of any page.

...
# Get raw content
content = await client.raw(
    'awesome-url',
    secret_raw_access_code='YOUR_CODE_HERE',  # optional
)
print(content)
...
### Updated Hello world

To view the source text you have 2 options:

  1. Specify your personal code inside page metadata. In this case, everyone will have access to the source text of the page through the API.
  2. Specify your personal code when trying to get the source text of any page. In this case, you will be able to get the source text, regardless of the metadata of the target page

Get PDF file

[!NOTE] This functionality has been removed from the library as it is no longer available in the original service via API. This method will be completely removed in the next version.

Get PNG

[!NOTE] This functionality has been removed from the library as it is no longer available in the original service via API. This method will be completely removed in the next version.

Custom ClientSession

[!NOTE] By default, a new instance of aiohttp.ClientSession will be created automatically. So normally you don't need to worry about this.

If you don't want to automatically create the session object inside the client, you can pass an existing aiohttp.ClientSession to the client constructor.

[!CAUTION] If you pass an existing session object to the client constructor, then you should care about releasing resources yourself.
The session will not be closed automatically! Even if the asynchronous context manager was used.

from aiohttp import ClientSession, TCPConnector
from aiorentry.client import Client

connector = TCPConnector(
    limit=5,  # Just for example
)

session = ClientSession(
    connector=connector,
)


async with Client('https://rentry.co', session=session) as client:
    # Your code here

async with session.get(...) as response:
    # You can still use this session object

Metadata

Release files for aiorentry 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for aiorentry 0.2.0
File Size Uploaded Provenance Actions
aiorentry-0.2.0.tar.gz 4.9 kB Without provenance Details for aiorentry-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for aiorentry 0.2.0
File Interpreter ABI Platform Actions
aiorentry-0.2.0-py3-none-any.whl Python 3 none any Details for aiorentry-0.2.0-py3-none-any.whl

Total release size: 10.5 kB

Release files / aiorentry-0.2.0.tar.gz

Download URL aiorentry-0.2.0.tar.gz
Size 4.9 kB
Tags Source
SHA-256 checksum
How to use checksums
86af6c60f4d6b5bddd1d4eec6a326008c2b6797165591f394a6221c5daecb187
BLAKE2b-256 checksum
How to use checksums
9e3d7c53a5df9350fe1aaeb284ac20f7183f2b2417cfed19ba654159ee78fe4a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.1 CPython/3.10.13 Linux/6.8.0-1017-azure

Release files / aiorentry-0.2.0-py3-none-any.whl

Download URL aiorentry-0.2.0-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5cb5290ab10c0f2164b6ed4183eb807854088c3793f502f59f88d80e7de1ac6a
BLAKE2b-256 checksum
How to use checksums
eef4171e1e3f0c2758adfe6115d100799c331e0026aa7d655302eefea9aca2a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.0.1 CPython/3.10.13 Linux/6.8.0-1017-azure

Security for aiorentry 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page