# aiorentry
Asynchronous API client for [rentry.co](https://rentry.co) (mirror: [rentry.org](https://rentry.org))
![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/froosty/aiorentry/lint_and_test.yml)
[![codecov](https://codecov.io/gh/froosty/aiorentry/graph/badge.svg?token=FJBRTOQ2HR)](https://codecov.io/gh/froosty/aiorentry)
[![PyPI - Version](https://img.shields.io/pypi/v/aiorentry)](https://pypi.org/project/aiorentry/)
![GitHub License](https://img.shields.io/github/license/froosty/aiorentry)
## About
This package allows you to interact with the [rentry.co](https://rentry.co) (or [rentry.org](https://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](https://github.com/radude/rentry), 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
```bash
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
```python
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
```python
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
```python
...
# Create new page
page = await client.new_page(
'## Hello world from awesome API',
)
print(page)
...
```
```bash
Page(url='m2e2wpe8', edit_code='hUHeRUei', text='## Hello world from awesome API')
```
```python
...
# 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)
...
```
```bash
Page(url='awesome-url', edit_code='qwerty=)', text='## Hello world from awesome API')
```
### Edit page
```python
...
# Edit page
await client.edit_page(
'### Updated Hello world',
url='awesome-url',
edit_code='qwerty=)',
)
...
```
### Delete page
```python
...
# 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.
```python
...
# 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.
```python
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
```
Raw data
{
"_id": null,
"home_page": "https://github.com/froosty/aiorentry",
"name": "aiorentry",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0,>=3.10",
"maintainer_email": null,
"keywords": "markdown, pastebin, rentry",
"author": "froosty",
"author_email": "froosty.gh@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/9e/3d/7c53a5df9350fe1aaeb284ac20f7183f2b2417cfed19ba654159ee78fe4a/aiorentry-0.2.0.tar.gz",
"platform": null,
"description": "# aiorentry\n\nAsynchronous API client for [rentry.co](https://rentry.co) (mirror: [rentry.org](https://rentry.org))\n\n![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/froosty/aiorentry/lint_and_test.yml)\n[![codecov](https://codecov.io/gh/froosty/aiorentry/graph/badge.svg?token=FJBRTOQ2HR)](https://codecov.io/gh/froosty/aiorentry)\n[![PyPI - Version](https://img.shields.io/pypi/v/aiorentry)](https://pypi.org/project/aiorentry/)\n![GitHub License](https://img.shields.io/github/license/froosty/aiorentry)\n\n## About\n\nThis package allows you to interact with the [rentry.co](https://rentry.co) (or [rentry.org](https://rentry.org)) service.\n\nRentry.co is a markdown pastebin and publishing service that offers features such as previews, custom URLs, and editing.\n\n**Please note** that this library is not developed by the official authors of rentry.co. It replicates the functionality of the [official console utility](https://github.com/radude/rentry), 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.\n\n## Installation\n\n```bash\npip install aiorentry\n```\n\n## Setup client\n\nYou can setup client in 2 ways:\n\n### As classic object\n\n> [!CAUTION]\n> If you prefer the classic way, you should call `await client.setup()` during initialization and `await client.close()` during completion\n\n```python\nimport asyncio\n\nfrom aiorentry.client import Client\n\n\nasync def main():\n client = Client('https://rentry.co')\n await client.setup()\n\n # Your code here\n\n await client.close()\n\n\nasyncio.run(main())\n```\n\n### As async context manager\n\n```python\nimport asyncio\n\nfrom aiorentry.client import Client\n\n\nasync def main():\n async with Client('https://rentry.co') as client:\n # Your code here\n\n\nasyncio.run(main())\n```\n\n## Examples\n\n### Create new page\n\n```python\n...\n# Create new page\npage = await client.new_page(\n '## Hello world from awesome API',\n)\n\nprint(page)\n...\n```\n\n```bash\nPage(url='m2e2wpe8', edit_code='hUHeRUei', text='## Hello world from awesome API')\n```\n\n```python\n...\n# Create new page with custom url and edit_code\nawesome_page = await client.new_page(\n '## Hello world from awesome API',\n url='awesome-url',\n edit_code='qwerty=)'\n)\n\nprint(awesome_page)\n...\n```\n\n```bash\nPage(url='awesome-url', edit_code='qwerty=)', text='## Hello world from awesome API')\n```\n\n### Edit page\n\n```python\n...\n# Edit page\nawait client.edit_page(\n '### Updated Hello world',\n url='awesome-url',\n edit_code='qwerty=)',\n)\n...\n```\n\n### Delete page\n\n```python\n...\n# Delete page\nawait client.delete_page(\n url='awesome-url',\n edit_code='qwerty=)',\n)\n...\n```\n\n### Get raw page text\n\n> [!NOTE]\n> This rentry functionality has limitations now. You can't just view the source text of any page.\n\n```python\n...\n# Get raw content\ncontent = await client.raw(\n 'awesome-url',\n secret_raw_access_code='YOUR_CODE_HERE', # optional\n)\nprint(content)\n...\n```\n\n```\n### Updated Hello world\n```\n\nTo view the source text you have 2 options:\n1. Specify your personal code inside page metadata. In this case, everyone will have access to the source text of the page through the API.\n2. 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\n\n### Get PDF file\n\n> [!NOTE]\n> 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.\n\n### Get PNG\n\n> [!NOTE]\n> 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.\n\n## Custom ClientSession\n\n> [!NOTE]\n> By default, a new instance of `aiohttp.ClientSession` will be created automatically. So normally you don't need to worry about this.\n\nIf you don't want to automatically create the session object inside the client, you can pass an existing `aiohttp.ClientSession` to the client constructor.\n\n> [!CAUTION]\n> If you pass an existing session object to the client constructor, then you should care about releasing resources yourself. \\\n> **The session will not be closed automatically!** Even if the asynchronous context manager was used.\n\n```python\nfrom aiohttp import ClientSession, TCPConnector\nfrom aiorentry.client import Client\n\nconnector = TCPConnector(\n limit=5, # Just for example\n)\n\nsession = ClientSession(\n connector=connector,\n)\n\n\nasync with Client('https://rentry.co', session=session) as client:\n # Your code here\n\nasync with session.get(...) as response:\n # You can still use this session object\n\n```",
"bugtrack_url": null,
"license": "MIT",
"summary": "Asynchronous client for https://rentry.co/ (https://rentry.org/)",
"version": "0.2.0",
"project_urls": {
"Homepage": "https://github.com/froosty/aiorentry",
"Repository": "https://github.com/froosty/aiorentry"
},
"split_keywords": [
"markdown",
" pastebin",
" rentry"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "eef4171e1e3f0c2758adfe6115d100799c331e0026aa7d655302eefea9aca2a5",
"md5": "b3b0fd83a752af538a470db07051e165",
"sha256": "5cb5290ab10c0f2164b6ed4183eb807854088c3793f502f59f88d80e7de1ac6a"
},
"downloads": -1,
"filename": "aiorentry-0.2.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "b3b0fd83a752af538a470db07051e165",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0,>=3.10",
"size": 5560,
"upload_time": "2025-01-12T16:52:32",
"upload_time_iso_8601": "2025-01-12T16:52:32.105928Z",
"url": "https://files.pythonhosted.org/packages/ee/f4/171e1e3f0c2758adfe6115d100799c331e0026aa7d655302eefea9aca2a5/aiorentry-0.2.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9e3d7c53a5df9350fe1aaeb284ac20f7183f2b2417cfed19ba654159ee78fe4a",
"md5": "712253bc96e9a22e75353d085bfc7613",
"sha256": "86af6c60f4d6b5bddd1d4eec6a326008c2b6797165591f394a6221c5daecb187"
},
"downloads": -1,
"filename": "aiorentry-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "712253bc96e9a22e75353d085bfc7613",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0,>=3.10",
"size": 4902,
"upload_time": "2025-01-12T16:52:34",
"upload_time_iso_8601": "2025-01-12T16:52:34.451326Z",
"url": "https://files.pythonhosted.org/packages/9e/3d/7c53a5df9350fe1aaeb284ac20f7183f2b2417cfed19ba654159ee78fe4a/aiorentry-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-12 16:52:34",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "froosty",
"github_project": "aiorentry",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "aiorentry"
}