This library is distributed on pypi
. In order to add it as a dependency, run the following command:
$ pip install wcfmclient
or
$ pip3 install wcfmclient
This library is built in consideration with JWT Authentication for WP REST API. Make sure that you follow WCFM's official authentication setup here.
Instantiate an API object as shown below
from wcfmclient.api import API
from wcfmclient.jwt_auth_service import JWTAuthService
from wcfmclient.session import session
api = API(**{
"username": "vendor's username",
"password": "vendor's password",
"url": "https://your.domain.name",
"session": session
})
Authenticate with your store's server.
from wcfmclient.api import API
from wcfmclient.jwt_auth_service import JWTAuthService
from wcfmclient.session import session
api = API(**{
"username": "vendor's username",
"password": "vendor's password",
"url": "https://your.domain.name",
"session": session
})
jwt_auth_service = JWTAuthService(api)
jwt_auth_service.authenticate()
Consuming wcfm rest api.
from wcfmclient.api import API
from wcfmclient.jwt_auth_service import JWTAuthService
from wcfmclient.session import session
api = API(**{
"username": "vendor's username",
"password": "vendor's password",
"url": "https://your.domain.name",
"session": session
})
jwt_auth_service = JWTAuthService(api)
jwt_auth_service.authenticate()
res = api.get("wp-json/wcfmmp/v1/products/")
products = res.json()