A Python API client for Freshdesk API v2
Freshdesk's API docs are here: https://developers.freshdesk.com/api/
As of now, it supports the following:
- contacts
It's very easy to implement the other endpoints. Just have a look at tapioca_freshdesk/resource_mapping.py
pip install git+https://github.com/tobiase/tapioca-freshdesk
from tapioca_freshdesk import Freshdesk
api = Freshdesk(
api_root="{https://example.freshdesk.com/api/v2/}", user="{your-user}", password="{your-password}"
)
or
from tapioca_freshdesk import Freshdesk
api = Freshdesk(api_root="{https://example.freshdesk.com}", user='{your-api-key}')
Notice: The api_root URL must be entered with it's schema, https://
or http://
.
A contact is a customer or a potential customer who has raised a support ticket through any channel.
POST /api/v2/contacts
user = {
"name": "Super Man",
"email": "superman@freshdesk.com",
"other_emails": ["lex@freshdesk.com", "louis@freshdesk.com"],
}
api.contacts().post(data=user)
https://developers.freshdesk.com/api/#create_contact
GET /api/v2/contacts/[id]
api.contact(id=434).get()
https://developers.freshdesk.com/api/#view_contact
GET /api/v2/contacts
# Get all contacts
api.contacts().get()
# Filter contacts by state
api.contacts().get(params={"state": "unverified"})
# Get soft deleted contacts
api.contacts().get(params={"state": "deleted"})
https://developers.freshdesk.com/api/#list_all_contacts
GET /api/v2/search/contacts?query=[query]
api.contacts_filter().get(params={"query": '"active:true"'})
https://developers.freshdesk.com/api/#filter_contacts
PUT /api/v2/contacts/[id]
api.contact(id=432).put(
data={
"name": "Clark Kent",
"job_title": "Journalist",
"other_emails": ["louis@freshdesk.com", "jonathan.kent@freshdesk.com"],
}
)
https://developers.freshdesk.com/api/#update_contact
DELETE /api/v2/contacts/[id]
api.contact(id=432).delete()
https://developers.freshdesk.com/api/#delete_contact
PUT api/v2/contacts/[id]/restore
api.contact_restore(id=432).put()
https://developers.freshdesk.com/api/#restore_contact
DELETE /api/v2/contacts/[id]/hard_delete
api.contact_delete(id=432).delete()
# Force delete a contact that is not soft deleted already.
api.contact_delete(id=432).delete(params={"force": "true"})
https://developers.freshdesk.com/api/#hard_delete_contact
PUT /api/v2/contacts/[id]/make_agent
api.contact_make_agent(id=432).put()
# Make occasional agent
api.contact_make_agent(id=432).put(data={"occasional": "true"})
https://developers.freshdesk.com/api/#make_agent
GET /api/v2/contact_fields
api.contact_fields().get()
https://developers.freshdesk.com/api/#list_all_contact_fields
PUT api/v2/contacts/[id]/send_invite
api.contact_send_invite(id=432).put()
https://developers.freshdesk.com/api/#send_invite
POST api/v2/contacts/merge
api.contacts_merge().post(
data={"primary_contact_id": 432, "secondary_contact_ids": [433]}
)
https://developers.freshdesk.com/api/#merge_contact
- Learn how Tapioca works here
- Explore this package using iPython
- Have fun!