API wrapper for https://cardboard.ink/api/v1/
Project description
cardboard.py
cardboard.py is a Python library for interacting with the cardboard API.
PyPi: https://pypi.org/project/cardboard.py/
Installation
You can install the cardboard.py library using pip:
pip install cardboard.py
Usage
Initialize the Cardboard or CardboardAsync class. Make sure to pass secret
and client_id
.
You can now use the client to make requests.
Examples
These examples will use Flask. Install it with pip install Flask
# Python Example
from flask import Flask, request, redirect, url_for, session, Response
from cardboard import Cardboard
app = Flask(__name__)
cb = Cardboard(client_id='', secret='') # get these at https://cardboard.ink
app.secret_key = 'hi' # set this to something secure, please.
@app.route('/login')
def login():
args = request.args
code = args.get('code')
if not code:
return redirect(cb.app_url)
try:
token = cb.get_token(code)
except:
return redirect(cb.app_url)
session['cardboard_token'] = token.token
return redirect(url_for('dashboard'))
@app.route('/dashboard')
def dashboard():
token = session.get('cardboard_token')
if not token:
return redirect(cb.app_url)
user = cb.get_user(token)
return Response(f'{user.name} (user id {user.id})', mimetype='text/plain')
if __name__ == '__main__':
app.run('0.0.0.0', port=5000)
Async Example
# Python Async Example
Documentation
For detailed documentation on the Cardboard API, read https://www.guilded.gg/CardBoard/groups/3y446Rmz/channels/4539a4f9-fb51-4a23-b01-0fcaeaf062d3/docs/374610
For detailed documentation on how to use the cardboard.py library, please wait while we write it lol.
Methods
A list of methods you can call with either Cardboard or CardboardAsync.
.revoke_token(token:str)
(bool).get_token(code:str)
(class AuthToken).token
(str).token_type
(str).refresh_token
(str).expires_in
(int)._raw
(dict)
.refresh_token(refresh_token:str)
(class AuthToken).token
(str).token_type
(str).refresh_token
(str).expires_in
(int)._raw
(dict)
.get_user(token:str)
(class User).name
(str).id
(str).subdomain
(str).aliases
(list(class UserAlias)).alias
(str|None).discriminator
(str|None).name
(str).createdAt
(datetime).editedAt
(datetime)._raw_createdAt
(str)._raw_editedAt
(str).userId
(str).gameId
(int).socialLinkSource
(str|None).socialLinkHandle
(str|None).additionalInfo
(dict).playerInfo
(dict|None)._raw
(dict)
.avatar
(str).banner
(str).status
(class UserStatus).text
(str|None).reaction_id
(int|None)._raw
(dict)._raw_text
(dict)._raw_reaction
(dict)
.moderationStatus
(str|None).aboutInfo
(class userAbout).bio
(str|None).tagline
(str|None)._raw
(dict)
.userTransientStatus
(str|None)._raw
(dict)
License
This project is licensed under the MIT License. See the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file cardboard.py-0.0.6.tar.gz
.
File metadata
- Download URL: cardboard.py-0.0.6.tar.gz
- Upload date:
- Size: 7.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1fa0664e31d6af3661184c1bf38f4b54d5c24ba435f912a8301605f1d050a007 |
|
MD5 | 4d77c37c0ac3b6b564e90499668eb43f |
|
BLAKE2b-256 | 2b64592264e1a8172dc5700990a52039d56e72af19c745a0948a545a0d3c05c8 |
File details
Details for the file cardboard.py-0.0.6-py3-none-any.whl
.
File metadata
- Download URL: cardboard.py-0.0.6-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0ebf9604ac339126039f5e52fe1f660ac1021360a0db74011463675d3c8698cd |
|
MD5 | 0b6897dbc5a8f702682a9915903f4771 |
|
BLAKE2b-256 | 5857e346c135eb7dc01c4bbf457d8d22a38e913c0df8391756d69a6ba99c4e0d |