You need Python3.5 in your system. We recommend to use a virtual environment:
virtualenv --python=python3.5 .env
source .env/bin/activate
Then, when you virtual environment is activated, type:
pip install git+git://github.com/v-hunt/trunity-3-api-client.git
Note: PyPi package will be added soon.
First of all, you need to authenticate withing the API and create a session to interact with client classes:
from trunity_3_client import initialize_session_from_creds
session = initialize_session_from_creds('your-login', 'your-password')
You need to include the session
in all clients you want to use.
Each resource can be on of two types: list
or detail
.
For example, /topics
is a 'list' type of a resource and
/topics/{id}
is a 'detail' type of a resource. You need that
knowledge to understand how the API Clients works.
Let assume you need to make GET request to /topics/{id}
endpoint.
How it should be done:
from trunity_3_client import TopicsClient
client = TopicsClient(session)
client.detail.get(topic_id)
If you need to create a topic, you need to make POST request
to list
type of url:
client.list.post(site_id, name, topic_id, short_name, description)
Also you may use general client that has each of the client built-in:
from trunity_3_client import Client
client = Client('login', 'password')
client.topics.detail.get(topic_id)
- TopicsClient
- ContentsClient
- Added clients: TopicsClient, ContentsClient
- Added clients: TermsClient
- Switch to PROD server
- Added clients: SitesClient
- Added various clients for Terms
- Added client for Files