Skip to main content

A simple to use synchronous Discord REST API wrapper for Python

Project description

Zenora

License: MIT prs Code Style: Black pyvers Build
Pypi Docs GitHub release (latest by date including pre-releases) Maintainability issues CodeQL

A simple to use API wrapper for the Discord REST API in Python

What is Zenora

Zenora is a synchronous library for accessing the Discord REST API. It allows you to access the API without async/await. And also gives you REST-only API access, not the gateway. Pretty useful for making bot web dashboards, or desktop applications, etc. There's some Oauth features as well

Installation

Install from Git

pip install git+https://github.com/ahnaf-zamil/zenora

or install with pip

pip install Zenora

Basic Usage

from zenora import APIClient

client = APIClient(token="...")
# There is also a set_token method which can be used to replace the token later on

# Make API request to get the currently logged in user object
user = client.users.get_current_user()

# Use the data :D
print(user.username)

Using Oauth

Zenora has can be used for accessing the Discord Oauth API (WIP). It is very simple to use, and reduces a lot of the hassle for implementing Discord Oauth in your application. But before you do try out Zenora, you need to know how to use get the authorization code from the Discord API in order to use it (this is mandatory and cannot be avoided as Zenora depends on that code in order to get the access token).

Link: https://discord.com/developers/docs/topics/oauth2#authorization-code-grant

Once you have the authorization code, Zenora will do the rest of the work for you. Just call some functions and you will get your access token and will be able to use that to with the Discord API.

Example:

from zenora import APIClient

TOKEN = "Your bot's token"
client = APIClient(
    TOKEN,
    client_secret="Your bot's client secret",
)

oauth_url = "your oauth redirect uri"

...

code = "the authorization code that you get from the Discord API everytime someone uses your Oauth application"

access_token = client.oauth.get_access_token(
    code, redirect_uri=oauth_url
).access_token


# Setting it to bearer because we are using Oauth here
bearer_client = APIClient(access_token, bearer=True)

# Query the user object that has used your Oauth application
user = bearer_client.users.get_current_user()

print(user) # Prints it out :)

If you want to know how to use Oauth with a specific web framework, check out the Examples section of the repository.

Documentation

The latest documentation is currently hosted here.

Contributing

If you are considering to contribute, thanks a lot! We welcome all contributors here and, you can help out as well.

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Before contributing, please check out our CONTRIBUTING.md and Code of Conduct for more information.

License

MIT License

Copyright (c) 2022 DevGuyAhnaf

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is

furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

Zenora-0.0.3.post1-py3-none-any.whl (32.1 kB view details)

Uploaded Python 3

File details

Details for the file Zenora-0.0.3.post1-py3-none-any.whl.

File metadata

  • Download URL: Zenora-0.0.3.post1-py3-none-any.whl
  • Upload date:
  • Size: 32.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.5

File hashes

Hashes for Zenora-0.0.3.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 3e0d0e10e86f7911ca3f4cfc79cabb2b1b7a3abc78934dc9026edd79b8f8076a
MD5 1ec5170ad64167ebc63e83f24a53876d
BLAKE2b-256 6a88ff3d0bcbfeae305368b7ef06115eaabb798455d5cae4769fb6ae3a843da0

See more details on using hashes here.

Supported by

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