Skip to main content

Paste codes to Nekobin.com with python

Project description

pyNekobin - A Wrapper for Nekobin API

This is a Python package that provides a simple wrapper around the Nekobin API, allowing you to easily paste and retrieve text snippets from the popular pastebin service.

MIT LICENSE Supported Python Versions Pylint Test PyPy Version Code Quality

Installation

You can install the package from pypy using pip:

pip install -U pynekobin

Documentation

Documentation of this package can be found at nusab19.github.io/pyNekobin

The content of the docs website is the same as this README file. :3

Usage

This package is asynchronous and uses httpx under the hood to make HTTP requests. So, you need to use the await keyword with each method call. First, import the Nekobin class and the asyncio library:

from nekobin import Nekobin
import asyncio

Then, create an instance of the Nekobin class:

nb = Nekobin()

To paste text to Nekobin, you can use the paste() method:

async def main():
    result = await nb.paste("Hello, world!")
    
    if result.ok:
        print("Pasted text at:", result.url) # -> Pasted text at: https://nekobin.com/abxajsyas
    else:
        print("Error:",  result.message)     # Error: Nekobin did not fulfil the request

asyncio.run(main())

Similarly, you can use the read() method to retrieve text from Nekobin:

async def main():
    result = await nb.read("https://nekobin.com/abxajsyas")
    
    if result.ok:
        print("Retrieved text:", result.content) # -> Retrieved text: Hello, world!
    else:
        print("Error:", result.message)          # -> Error: Document not found 

asyncio.run(main())

Advanced Usage

As this package uses httpx under the hood, you can pass additional keyword arguments in each method call. You can pass any keyword argument that httpx.AsyncClient may take:

from nekobin import Nekobin
import asyncio

nb = Nekobin(timeout=10, headers={}, follow_redirects=True)

If you want to pass these arguments in each method call, you have that too:

from nekobin import Nekobin
import asyncio

nb = Nekobin()

async def main():
    result = await nb.paste("Hello, world!", timeout=10)
    url = result.url
    print("Pasted at:", url)

    content = (await nb.read(url, timeout=7)).content
    print("Content:", content)

asyncio.run(main())

Contributing

If you encounter any bugs or issues, please feel free to open an issue on the GitHub repository. If you would like to contribute to the development of the package, you can fork the repository and submit a pull request with your changes.

To use this package locally:

git clone https://github.com/Nusab19/pyNekobin
cd pyNekobin
pip install -U httpx
pip install -e .

License

This package is licensed under the MIT License. See the LICENSE file for more information.

Made with ❤ by Nusab Taha from the Universe!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyNekobin-3.1.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

pyNekobin-3.1-py3-none-any.whl (5.0 kB view details)

Uploaded Python 3

File details

Details for the file pyNekobin-3.1.tar.gz.

File metadata

  • Download URL: pyNekobin-3.1.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for pyNekobin-3.1.tar.gz
Algorithm Hash digest
SHA256 dcafc576430037e90310a3ddf0788ad351017378a3e4019808903780a205ef89
MD5 8ec843aaed0da06801ff5146dadb3d78
BLAKE2b-256 2c64f3f540106f21c1c06a86bc162424a2931d6c56f8519625ee39fc5d1f79fa

See more details on using hashes here.

File details

Details for the file pyNekobin-3.1-py3-none-any.whl.

File metadata

  • Download URL: pyNekobin-3.1-py3-none-any.whl
  • Upload date:
  • Size: 5.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for pyNekobin-3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 153c654828db160a6305fc701c5e37f8051b2074a35d2aece4ced44dd0c0790c
MD5 78c6729c3e9448cfe8f73e5fc8e3947d
BLAKE2b-256 c14c4f92cc28e685fd74126a9732d55ecfa98a30d13c707f933509054e14676b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page