# Wordpress Python Library
The `wordpress` Python library provides a simple interface to interact with the WordPress REST API. It allows you to manage various aspects of your WordPress site, including pages, posts, categories, media, users, and comments.
## Download stats
[](https://pepy.tech/project/Wordpress)
## Features
- Fetch, create, update, and delete `pages`
- Fetch, create, update, and delete `posts`
- Fetch, create, update, and delete `categories`
- Upload and manage `media`
- Fetch and manage `users`
- Fetch and manage `comments`
## Installation
You can install the library using pip:
```bash
pip install wordpress
```
## Usage
Importing the Library
```python
import wordpress
```
## Connecting to WordPress
To use the library, create an instance of the wordpress.Connect class by providing the base URL of your WordPress site and authentication details (username and password).
```python
site_url = "https://yourwordpresssite.com"
username = "yourusername"
password = "your_application_password" #read documentation https://wordpress.com/support/security/two-step-authentication/application-specific-passwords/
wp = wordpress.Connect(site_url, username, password)
```
## Pages
### Fetch All Pages
```python
wp.page.fetch_all_pages()
```
### Create a New Page
```python
wp.page.create_page(title="About Us", content="This is the About Us page.")
```
### Fetch a Specific Page
```python
wp.page.fetch_page(page_id=123)
```
### Delete a Page
```python
wp.page.delete_page(page_id=123)
```
## Posts
### Fetch All Posts
```python
wp.post.fetch_all_posts()
```
### Create a New Post
```python
wp.post.create_post(title="New Blog Post", content="This is a new blog post.")
```
### Fetch a Specific Post
```python
wp.post.fetch_post(post_id=123)
```
### Delete a Post
```python
wp.post.delete_post(post_id=123)
```
### Categories
### Fetch All Categories
```python
wp.category.fetch_all_categories()
```
### Create a New Category
```python
wp.category.create_category(name="New Category")
```
### Fetch a Specific Category
```python
wp.category.fetch_category(category_id=123)
```
### Delete a Category
```python
wp.category.delete_category(category_id=123)
```
## Media
### Upload Media
```python
wp.media.upload_media(file_path="path/to/your/image.jpg")
```
### Fetch All Media
```python
wp.media.fetch_all_media()
```
### Fetch a Specific Media Item
```python
wp.media.fetch_media(media_id=123)
```
### Delete Media
```python
wp.media.delete_media(media_id=123)
```
## Users
### Fetch All Users
```python
wp.user.fetch_all_users()
```
### Fetch a Specific User
```python
wp.user.fetch_user(user_id=123)
```
## Comments
### Fetch All Comments
```python
wp.comment.fetch_all_comments()
```
### Fetch a Specific Comment
```python
wp.comment.fetch_comment(comment_id=123)
```
Raw data
{
"_id": null,
"home_page": null,
"name": "Wordpress",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "WordPress, WordPress API, WordPress SDK, REST API, wp python, WP",
"author": null,
"author_email": "Ankush Kumar <ankush1611996@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/c4/57/e615f7afec4bcf5c56aa577bc0557419a08478591a763c141f745428c1db/wordpress-1.2.tar.gz",
"platform": null,
"description": "# Wordpress Python Library\n\nThe `wordpress` Python library provides a simple interface to interact with the WordPress REST API. It allows you to manage various aspects of your WordPress site, including pages, posts, categories, media, users, and comments.\n\n## Download stats\n[](https://pepy.tech/project/Wordpress)\n## Features\n\n- Fetch, create, update, and delete `pages`\n- Fetch, create, update, and delete `posts`\n- Fetch, create, update, and delete `categories`\n- Upload and manage `media`\n- Fetch and manage `users`\n- Fetch and manage `comments`\n\n## Installation\n\nYou can install the library using pip:\n\n```bash\npip install wordpress\n```\n\n## Usage\nImporting the Library\n```python\nimport wordpress\n```\n\n## Connecting to WordPress\nTo use the library, create an instance of the wordpress.Connect class by providing the base URL of your WordPress site and authentication details (username and password).\n\n```python\nsite_url = \"https://yourwordpresssite.com\"\nusername = \"yourusername\"\npassword = \"your_application_password\" #read documentation https://wordpress.com/support/security/two-step-authentication/application-specific-passwords/\nwp = wordpress.Connect(site_url, username, password)\n```\n\n## Pages\n### Fetch All Pages\n```python\nwp.page.fetch_all_pages()\n```\n### Create a New Page\n```python\nwp.page.create_page(title=\"About Us\", content=\"This is the About Us page.\")\n```\n### Fetch a Specific Page\n```python\nwp.page.fetch_page(page_id=123)\n```\n### Delete a Page\n```python\nwp.page.delete_page(page_id=123)\n```\n## Posts\n### Fetch All Posts\n```python\nwp.post.fetch_all_posts()\n```\n### Create a New Post\n```python\nwp.post.create_post(title=\"New Blog Post\", content=\"This is a new blog post.\")\n```\n### Fetch a Specific Post\n```python\nwp.post.fetch_post(post_id=123)\n```\n### Delete a Post\n```python\nwp.post.delete_post(post_id=123)\n```\n### Categories\n### Fetch All Categories\n```python\nwp.category.fetch_all_categories()\n```\n### Create a New Category\n```python\nwp.category.create_category(name=\"New Category\")\n```\n### Fetch a Specific Category\n```python\nwp.category.fetch_category(category_id=123)\n```\n### Delete a Category\n```python\nwp.category.delete_category(category_id=123)\n```\n## Media\n### Upload Media\n```python\nwp.media.upload_media(file_path=\"path/to/your/image.jpg\")\n```\n### Fetch All Media\n```python\nwp.media.fetch_all_media()\n```\n### Fetch a Specific Media Item\n```python\nwp.media.fetch_media(media_id=123)\n```\n### Delete Media\n```python\nwp.media.delete_media(media_id=123)\n```\n## Users\n### Fetch All Users\n```python\nwp.user.fetch_all_users()\n```\n### Fetch a Specific User\n```python\nwp.user.fetch_user(user_id=123)\n```\n## Comments\n### Fetch All Comments\n```python\nwp.comment.fetch_all_comments()\n```\n### Fetch a Specific Comment\n```python\nwp.comment.fetch_comment(comment_id=123)\n```\n",
"bugtrack_url": null,
"license": null,
"summary": "A Python library for interacting with the WordPress REST API",
"version": "1.2",
"project_urls": {
"Bug Tracker": "https://github.com/AnkushRozra/wordpress/issues",
"Homepage": "https://github.com/AnkushRozra/wordpress"
},
"split_keywords": [
"wordpress",
" wordpress api",
" wordpress sdk",
" rest api",
" wp python",
" wp"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "6eaa0639fc805f587e195121c0322248272239c1a8be9ad9b1e029f7d78d07fb",
"md5": "356bd65558acd50b74ad4eecf868fe69",
"sha256": "113dc22028eb6e08548766936d60015b23301dbd7ac5f525c2fb07ef161b218a"
},
"downloads": -1,
"filename": "Wordpress-1.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "356bd65558acd50b74ad4eecf868fe69",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 6132,
"upload_time": "2025-01-08T17:40:30",
"upload_time_iso_8601": "2025-01-08T17:40:30.877805Z",
"url": "https://files.pythonhosted.org/packages/6e/aa/0639fc805f587e195121c0322248272239c1a8be9ad9b1e029f7d78d07fb/Wordpress-1.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c457e615f7afec4bcf5c56aa577bc0557419a08478591a763c141f745428c1db",
"md5": "7f994527fa3e4d88ecd1221cb4980c78",
"sha256": "fb61df0a435905aaa83b56ca7800f3a367fb59d01730a5d1f0d383ea7cca27fd"
},
"downloads": -1,
"filename": "wordpress-1.2.tar.gz",
"has_sig": false,
"md5_digest": "7f994527fa3e4d88ecd1221cb4980c78",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 6018,
"upload_time": "2025-01-08T17:40:33",
"upload_time_iso_8601": "2025-01-08T17:40:33.049938Z",
"url": "https://files.pythonhosted.org/packages/c4/57/e615f7afec4bcf5c56aa577bc0557419a08478591a763c141f745428c1db/wordpress-1.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-08 17:40:33",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "AnkushRozra",
"github_project": "wordpress",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "wordpress"
}