Skip to main content

Python SDK for the Businnect API

Project description

Businnect Python

The official Python SDK for the Businnect API.

Installation

pip install businnect

Setup

Find your API token at https://businnect.com/settings/developer after creating an account at https://businnect.com/register.

from businnect import Businnect

client = Businnect(api_token="your_api_token_here")

Micropost

Create a post

from businnect.schemas.micropost import PostType

# Text post
post = client.micropost.client_create_micropost(
    title="Hello World",
    body="This is my first post.",
)
print(post.public_id)
print(post.link)

# Media post
with open("photo.png", "rb") as f:
    post = client.micropost.client_create_micropost(
        title="My photo",
        body="Check this out",
        post_type=PostType.MEDIA,
        file=("photo.png", f, "image/png"),
    )

# Reply to a post
reply = client.micropost.client_create_micropost(
    body="Great post!",
    parent_micropost_public_id="post_public_id_here",
)

# Nested reply (reply to a comment)
nested = client.micropost.client_create_micropost(
    body="I agree!",
    parent_micropost_public_id="post_public_id_here",
    parent_micropost_comment_public_id="comment_public_id_here",
)

Delete a post

client.micropost.client_delete_micropost(public_id="post_public_id_here")

Vote on a post (toggle)

result = client.micropost.client_vote_micropost(public_id="post_public_id_here")
print(result.user_voted)  # True or False

Blog

Get admin article

article = client.blog.client_get_admin_blog()
if article:
    print(article.title)
    print(article.body)

List admin articles

result = client.blog.client_list_admin_blogs()
print(result.total_list)
for article in result.list:
    print(article.title, article.slug)

API Reference

Businnect(api_token, base_url?)

Parameter Type Description
api_token str Your API token
base_url str API base URL (default: https://api.businnect.com)

client.micropost.client_create_micropost(...)

Parameter Type Default Description
body str required Content of the post
title str None Required for original posts
post_type PostType PostType.TEXT TEXT or MEDIA
community_name str None Community to post in
parent_micropost_public_id str None For replies
parent_micropost_comment_public_id str None For nested replies
allow_comments bool True Whether comments are allowed
is_draft bool False Save as draft
file tuple None (filename, file_object, mime_type) for MEDIA posts

Returns: CreatedWithPublicIdAndLinkResponse with public_id and link


client.micropost.client_delete_micropost(public_id)

Parameter Type Description
public_id str Public ID of the post to delete

Returns: None (204 on success)


client.micropost.client_vote_micropost(public_id)

Parameter Type Description
public_id str Public ID of the post to vote on

Returns: VoteResponse with user_voted (bool)


client.blog.client_get_admin_blog()

Returns: BlogResponse or None


client.blog.client_list_admin_blogs()

Returns: BlogListResponse with list, total_list and total_pages


Development

# Install in editable mode
pip install -e .

# Run unit tests
python -m pytest businnect/tests/test_businnect_unit.py -v

# Run integration tests (requires real API token)
BUSINNECT_API_TOKEN=your_token python -m pytest businnect/tests/test_businnect_integration.py -v -s

License

MIT

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

businnect-0.0.2.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

businnect-0.0.2-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file businnect-0.0.2.tar.gz.

File metadata

  • Download URL: businnect-0.0.2.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for businnect-0.0.2.tar.gz
Algorithm Hash digest
SHA256 8f9598ff4c09af9e4c851088f9f39f978911353357ea6c5b3adca21bce6289ca
MD5 4ab2a080f936dbea3ededc13d9815363
BLAKE2b-256 c254cc10a8308d7dd2750817a5cd835928cf64ee8a9352e5279cf315f2164a08

See more details on using hashes here.

File details

Details for the file businnect-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: businnect-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for businnect-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 984f2336a76537762a7b76234c4e921cde4ead3c7977d7ac83f24844d8d340b1
MD5 6ba7a807563c3caf1a5cace01b05f22a
BLAKE2b-256 916648ceb69c5c526546a089135dad266cfea35d30e6678f6ae244c9796af061

See more details on using hashes here.

Supported by

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