# 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
[![Downloads](https://static.pepy.tech/badge/Wordpress)](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/e4/d3/4df7278e45ecfbdccf97d3ce3c865007f7b21636e5990194ad6897292307/wordpress-1.1.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[![Downloads](https://static.pepy.tech/badge/Wordpress)](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.1",
"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": "c710b44e9a829b05fb3cb898785e2d73c93592c2841a9bacff2d35004483d022",
"md5": "ab04d7992f7749eee6e1821a05419822",
"sha256": "1b4792104b7df5cdd2fba35300092dfdf0a175844ce5c8c18664b762f9e16ba9"
},
"downloads": -1,
"filename": "Wordpress-1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ab04d7992f7749eee6e1821a05419822",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 4731,
"upload_time": "2024-09-02T02:25:24",
"upload_time_iso_8601": "2024-09-02T02:25:24.845900Z",
"url": "https://files.pythonhosted.org/packages/c7/10/b44e9a829b05fb3cb898785e2d73c93592c2841a9bacff2d35004483d022/Wordpress-1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e4d34df7278e45ecfbdccf97d3ce3c865007f7b21636e5990194ad6897292307",
"md5": "6b52346b45f9dc0b1c70f25e9f990ae9",
"sha256": "4609f53e75bbf78e21d041b41ba351641536435275db18e61dce992db240dad4"
},
"downloads": -1,
"filename": "wordpress-1.1.tar.gz",
"has_sig": false,
"md5_digest": "6b52346b45f9dc0b1c70f25e9f990ae9",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 5114,
"upload_time": "2024-09-02T02:25:26",
"upload_time_iso_8601": "2024-09-02T02:25:26.230192Z",
"url": "https://files.pythonhosted.org/packages/e4/d3/4df7278e45ecfbdccf97d3ce3c865007f7b21636e5990194ad6897292307/wordpress-1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-02 02:25:26",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "AnkushRozra",
"github_project": "wordpress",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "wordpress"
}