GithubHelp home page GithubHelp logo

nusab19 / pynekobin Goto Github PK

View Code? Open in Web Editor NEW
8.0 1.0 0.0 28 KB

Python Wrapper for Nekobin API | nekobin.com

Home Page: https://nekobin.com

License: MIT License

Python 100.00%
nekobin python3 wrapper-api nusab19

pynekobin's Introduction

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 -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!

pynekobin's People

Contributors

nusab19 avatar

Stargazers

 avatar Towasin avatar  avatar Nafis Afzal avatar Roboter404 avatar  avatar AHN avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.