Skip to main content

A Padlet API wrapper written in python using async/await syntax

Project description

padlet py

A Padlet API wrapper written in python using async/await syntax

Usage

Get started

pip install padlet-py 

In your file:

import padlet

api_key = "pdlt_0000"  # your padlet api key.
board_id = "mwrsf0033"  # The board id you are interested in.

# Create an user object.
user = padlet.user(api_key)

# This will create a board object, but it won't have any data yet.
board = user.board(board_id)
# You must fetch the data from the api using:
await board.fetch()
# The board attributes, sections, and posts (including attachments) are 
# now loaded into the object.

How to use

# The boards posts are stored in a dictionary by their ID.
a_post_that_i_need = board.posts['post_id']
a_section_that_i_need = board.sections['section_id']

At the moment, this dictionary is editable, so take care to not overwrite any values in it.
You can .fetch() the board again to load the posts and sections again from scratch.

Heres you can create a post to the padlet board:

async def create_post():
   # I'm going to grab the first section of my board
   section = board.sections.values()[0] 
   await board.create('args go here')

Here are the args that you can pass to the .create() function:

Arg Type Optional?
subject str No
body str No
color Literal['red', 'orange', 'green', 'blue', 'purple'] Yes
attachment_url str Yes
attachment_caption str Yes
status Literal['approved', 'pending_moderation', 'scheduled'] Yes
map map_object Yes
canvas canvas_object Yes
previous_post post_object Yes

Notice that some of the args are objects. You can deal with those like this:

# Import all the objects you need
from padlet import user, map_object, canvas_object, post_object, section_object

async def create(section: section_object):
    # You can create your own map object by the method below
    # or depending on your needs, reference one from another post
    map = map_object()
    map.latitude = 321
    map.longitude = 321
    map.location_name = 'Python HQ'

    # You can also construct your own post object, using just the id.
    post = post_object()
    post.id = 'post_id'
    # Again, its recommended that you reference another post from the board:
    post = section.board.posts['post_id'] 

    await section.create(subject='Python',
                         body='Just testing',
                         status='approved',
                         map=map,
                         previous_post=post)

Caveats?

At the moment this wrapper does not deal with ratelimits or error codes. That is already planned.

I also hope to make this wrapper more forwards compatible, so that it doesn't break due to any sudden changes in the padlet API.

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

padlet_py-1.0.1.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

padlet_py-1.0.1-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file padlet_py-1.0.1.tar.gz.

File metadata

  • Download URL: padlet_py-1.0.1.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for padlet_py-1.0.1.tar.gz
Algorithm Hash digest
SHA256 96480b60c21d94d16e9ee13a060038968fd1c63cd4f78aac56e15e94ff5d7000
MD5 8f01d5e361012f666554a47a2fd3b48b
BLAKE2b-256 c45123d8116f3dad971858965379e53720be9b8945389ba1fd793021b825c5b8

See more details on using hashes here.

File details

Details for the file padlet_py-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: padlet_py-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for padlet_py-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d655795ac277c31e5d78aa72dc0709a28dba4652de2588b5716f02d5483c0631
MD5 5592642a9fd9e730a4a3d569f44132c5
BLAKE2b-256 7f63524a096d0779c35470dc7da99840242362847b94ed1bd3954ebeb41733fd

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