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)
async def get_data():
    # 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, you 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.0.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: padlet_py-1.0.0.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.0.tar.gz
Algorithm Hash digest
SHA256 ea33a490a34df45ca4496092978b8ae6728a12d0b7582e0a669494d4423af2c0
MD5 396064d3238674ecb0a82fd9e947bb6b
BLAKE2b-256 f152281695317b0a100b3eb967d0b85e5c8044b3b27524585b9416c586c575fb

See more details on using hashes here.

File details

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

File metadata

  • Download URL: padlet_py-1.0.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7284b98a813c2dbce81ea31e1f7ebb496b8ef1e01a5eacc5954dbd4ad1a66dad
MD5 1aef33fcf65e27856c2d08fcddfa67bf
BLAKE2b-256 54c8450194ce839f16e136a81687986745c7517af6509447d33b74b27d831bbb

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