Super thin Python wrapper for the Wordpress REST API V2 developed by Stylight. Supports the documented read and write endpoints. Extensions and pull requests are encouraged and welcome.
Limitations:
doesn’t check input parameters
returns a single dictionary or a list of dictionaries, depending on the API endpoint
only supports basic auth, and it currently cannot be used without authentication
Dependencies:
requests
six
Installation
pip install wordpress-json
Before being able to use this package make sure you configure Wordpress properly.
Wordpress configuration
You need to install the WP-API Plugin. To do so:
Go to your Wordpress Dashboard
Click on Plugins in the left sidebar
Search for “REST API”. Install the plugin named “WordPress REST API (Version 2)”, by clicking on the “Install” button.
Activate the plugin on the next screen.
You need to install and activate the WP REST API Meta Endpoints plugin for the WP-API :
Click on Plugins in the left sidebar
Click on “Add New” on the top right, next to “Plugin”
Search for “WP REST API Meta Endpoints”. Install the plugin named “WP REST API Meta Endpoints”, by clicking on the “Install” button.
Activate the plugin on the next screen.
You need to install and activate the Basic-Auth plugin for the WP-API :
download https://github.com/WP-API/Basic-Auth/archive/master.zip
Open your Wordpress Admin Dashboard
Click on Plugins in the left sidebar
Click on “Add New” on the top right, next to “Plugin”
Click on “Upload Plugin”, Choose File, and select the file you downloaded at step 1 (master.zip)
Click on Install Now
Activate the plugin on the next screen.
Change permalink configuration to ‘Post name’ in Permalink Settings.
Usage
>>> wp = WordpressJsonWrapper('http://example.com/wp-json/wp/v2', 'wp_user', 'wp_password')
>>> posts = wp.get_posts()
>>> posts[0].keys()
dict_keys(['format', 'featured_media', 'author', ...])
>>> posts[0].get('title')
{'rendered': 'Tweetle Beetles'}
>>> posts[0].get('content')
{'rendered': '<p>What do you know about tweetle beetles? ...'}
>>> posts[0].get('id')
42
>>> wp.create_meta(post_id=42, data=dict(key='genre', value='fanciful'))
>>> meta = wp.get_meta(post_id=42)
>>> meta[0].get('key')
'genre'
>>> meta[0].get('value')
'fanciful'
Release History
0.3.1 (2017-02-22)
Documentation
Fix changelog
0.3.0 (2017-02-22)
New Features
Support non-JSON data in requests
Behavioural Changes
Use POST instead of PUT for update requests. This may not work with Wordpress versions below 4.7.
Raise an error if the Content-Type on response is not JSON.
0.2.4 (2016-08-17)
Miscellaneous
Remove debug code
0.2.3 (2016-08-17)
Bugfixes
Fix error handling
Documentation
Update example usage with correct namespace for v2
0.2.2 (2016-07-22)
Improvements
six and requests libraries not pinned to versions
0.2.1 (2016-07-20)
Bugfixes
Fix syntax errors in README.rst
Add missing dependency six to setup.py
Miscellaneous
Update authors
0.2.0 (2016-07-20)
Improvements
Update for v2 WP-API
0.1.5 (2015-07-16)
Bugfixes
Include HISTORY.rst in setup.py
0.1.4 (2015-07-16)
Documentation
Fix syntax errors in README.rst and HISTORY.rst
0.1.3 (2015-07-16)
Improvements
Allow raw url parameters to be passed in and used for the API calls
0.1.2 (2015-02-03)
Improvements
Allow headers to be passed in and used for the API calls
Documentation
Add HISTORY.rst (this change log)
0.1.1 (2015-01-27)
Bugfixes
Use json parameter instead of data parameter for requests
0.1.0 (2015-01-27)
Birth!
Metadata
Release files for wordpress_json 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| wordpress_json-0.3.1.tar.gz | 5.8 kB | Without provenance | Details |
Release files / wordpress_json-0.3.1.tar.gz
| Download URL | wordpress_json-0.3.1.tar.gz |
|---|---|
| Size | 5.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
e43091bd6d0ec4ede74c5650dc4442c4bfbf8d2885ac2b212889b8bdb5ed21fc
|
|
BLAKE2b-256 checksum How to use checksums |
30f4d76736bb4ff3a2b554a24ac974acfa90b15966a4a549e6661438f067459f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for wordpress_json 0.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.