• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XenForo API in Python

ManagerJosh

Well-known member
#2
I know I'm not a programmer/developer and I don't pretend to be one, but reading the code - it looks like it leverages the XF user permissions... which is awesome...except for the fact everyone is going to be assigning it by default an XF admin account.
 

Digital Doctor

Well-known member
#3
Cool :)

PyXenForoAPI
PyXenForoAPI

PyXenForoAPI is module that'll help you interact with websites running the famous XenForo forum.

Methods

Login
Post in a thread
Edit a post
Delete a post
Create a thread in a specific section
Edit a thread
Start a new conversation
Reply to a conversation
Get all messages from a conversation
Installation

From PyPi:

$ pip install pyxenforoapi
Or:

$ easy_install pyxenforoapi
Or clone from Github:

$ git clone https://github.com/lqaz/pyxenforoapi

$ cd pyxenforoapi

$ sudo python3 setup.py install
Usage

Import:

from pyxenforoapi import pyxenforo
Login:

xf = pyxenforo.Xenforo(username, password, site)
If you want to use a proxy to login, pass the proxy parameter, the proxy must be passed as a dict. Example:

xf = pyxenforo.Xenforo(username, password, site, proxy={"http:" "http://user:pass@host:port/", "https": "https://user:pass@host:port/"})
Args:

username (str): The username you login with

password (str): Password to your account

site (str): Website to login to

Keyword args:

proxy (dict): Optional to pass, specify proxy as a dictionary if you wish to use a proxy. The proxy will be used on all your actions, only need to specify it once

Raises:

LoginError if the login was unsuccessful

Post in a thread:

xf.post_in(thread, reply)
Args:

thread (str): thread id to post in

reply (str): message to reply with

Edit a post:

xf.edit_post(post_id, text)
Args:

post_id (str): id of the post to edit

text (str): text to replace the current post with

Delete a post:

xf.delete_post(post_id, delete_value, reason)
Args:

post_id (str): the ID of the post you want to delete.

delete_value (int): whether to soft (0) or hard delete a post (1)

reason (str): reason for removal of the post, empty string equals no reason.

Create a thread:

xf.create_thread_in(section, title, body)
Args:

section (str): which section to post the thread in

title (str): what to title the thread

body (str): the message of the thread

Edit a thread:

xf.edit_thread(thread, new_title)
Args:

thread (str): id of the thread you wish to edit

new_title (str): what to replace the current title with

Start a new conversation:

xf.new_conversation(recipient, title, message)
Args:

recipients (str): The names of users you want to start a conversation with. Separate names with comma

title (str): The title of the conversation

message (str): The message you want to start the conversation with

Reply to a conversation:

xf.reply_to_conversation(conversation_id, message)
Args:

message (str): The message to reply with

conversation_id (str): The conversation to add a reply to

Get conversation messages:

xf.get_conversation_messages(conversation_id)
Args:

conversation_id (str): The conversation to get messages from

License

PyXenForoAPI is protected by the MIT license.