Skip to content
/ maple Public

A package for making API Wrappers for Django Ninja and Fast API 🍁

Notifications You must be signed in to change notification settings

foxy4096/maple

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Maple 🍁

A package for making API Wrappers for Django Ninja or Fast API 🍁

Installing

Coming Soon

pip install maple

Usage

from getpass import getpass
from pprint import pprint

from maple import Maple

USERNAME = input("Username: ")
PASSWORD = getpass("Password: ")

BASE_URL = "https://vitary.pythonanywhere.com"

# Create a new instance of Maple.
vitary = Maple(base_url=BASE_URL)

# Login to the site.
AUTH_KEY = (
    vitary.post(
        "/api/login/",
        data={
            "username": USERNAME,
            "password": PASSWORD,
        },
    )
    .json()
    .get("token")
)

vitary.set_attr("AUTHORIZATION_KEY", AUTH_KEY)

# Get the current user
myself = vitary.get("/api/myself").json()

pprint(myself)

It is that simple,

You will get the following response:

➜ Maple git:(main) python test.py
Username: foxy4096
Password: ********

{
    "id": 1,
    "first_name": "Aditya",
    "last_name": "Priyadarshi",
    "username": "foxy4096"
    "profile": {
    "allow_nsfw": True,
    "badges": [
        {
            "id": 1,
            "name": "Developer πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»"
            "description": "The devs of Vitary",
        }
    ],
    "bio": "\_A dumb developer who loves Django*",
    "follower_count": 4,
    "following_count": 9,
    "header_image": "/media/uploads/DSC00406.JPG",
    "image": "/media/uploads/profile.jpeg",
    "status": "online"
    }
}

About

A package for making API Wrappers for Django Ninja and Fast API 🍁

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages