Node wrapper for Freshdesk v2 API
npm install --save freshdesk-api
Also, you could use version 1 of API, provided by Kumar Harsh @kumarharsh, but this version is obsolete, and marked as deprecated:
npm install freshdesk-api@APIv1
var Freshdesk = require('freshdesk-api')
var freshdesk = new Freshdesk('https://yourdomain.freshdesk.com', 'yourApiKey')
Or, with promises:
var Freshdesk = require('freshdesk-api')
var Promise = require('bluebird')
var asyncFreshdesk = Promise.promisifyAll(
new Freshdesk('https://yourdomain.freshdesk.com', 'yourApiKey')
)
// see usage examples
bluebird
is not a dependency of this package, install it separately: npm install bluebird
freshdesk.createTicket({
name: 'test ticket',
email: 'test@test.com',
subject: 'test sub',
description: 'test description',
status: 2,
priority: 1
}, function (err, data) {
console.log(err || data)
})
freshdesk.updateTicket(21, {
description: 'updated description',
status: 2,
priority: 1
}, function (err, data, extra) {
console.log(err || data)
})
freshdesk.getTicket(21, function (err, data, extra) {
console.log(err || data)
})
freshdesk.deleteTicket(21, function (err, data, extra) {
console.log(err || data)
})
* for promisified version only
asyncFreshdesk.getTicketAsync(21)
.then((data, extra) => {
console.log(data, extra)
})
.catch(Freshdesk.FreshdeskError, err => {
// typed `catch` exists only in bluebird
console.log('ERROR OCCURED', err)
})
})
Every SDK method receives a callback
parameter. It is a function, which will be called on Freshdesk response received.
Callback called with following arguments:
err
-Error
instance (if occured) ornull
data
-object
. Freshdesk response, an object, parsed from JSONextra
- additional data, gathered from response. For example, information about paging
extra
is an object with following fields:
pageIsLast
- indicates, that the response is generated from the last page, and there is no sense to play withpage
andper_page
parameters. This parameter is useful forlistXXX
methods, called with pagination
To enable debug info, run your program with environment flags
- on linux
$ DEBUG=freshdesk-api nodejs NAME-OF-YOUR-SCRIPT.js
- createTicket(ticket, callback) - Create a new ticket, list of parameters
- getTicket(id, callback) - Get a ticket by its id
- updateTicket(id, ticket, callback) - Update a ticket by its id, list of parameters
- deleteTicket(id, callback) - Delete a ticket by its id
- restoreTicket(id, callback) - Restore a ticket by its id
- listAllTickets(filter, callback) - List All Tickets, check list of filters
- listAllTicketFields(callback) - List All Ticket Fields
- listAllConversations(id, callback) - List All Conversations of a Ticket by its id
- listAllTimeEntries(id, callback) - List All Time Entries of a Ticket by its id
- listAllSatisfactionRatings - NOT IMPLEMENTED http://developers.freshdesk.com/api/#view_ticket_satisfaction_ratings
- createReply(id, reply, callback) - Create a Reply for a ticket by its id, list of parameters
- createNote(id, note, callback) - Create a Note for a ticket by its id, list of parameters
- updateConversation(id, conversation, callback) - Update a conversation by its id, list of parameters
- deleteConversation(id, callback) - Delete a conversation by its id
- createContact(contact, callback) - Create a new contact, list of parameters
- getContact(id, callback) - Get a contact by its id
- updateContact(id, contact, callback) - Update a contact by its id, list of parameters
- deleteContact(id, callback) - Delete a contact by its id
- listAllContacts(filter, callback) - List All Contact, check list of filters
- listAllContactFields(callback) - List All Contact Fields
- makeAgent(id, callback) - Make a contact an Agent, read more
Not implemented: http://developers.freshdesk.com/api/#agents
Not implemented: http://developers.freshdesk.com/api/#roles
Not implemented: http://developers.freshdesk.com/api/#groups
- createCompany(data, callback) - Create a new company record using parameters
- getCompany(id, callback) - Get company by ID; read more
- listAllCompanies(callback) - List all companies; parameters
- updateCompany(id, data, callback) - Update a company by ID; parameters
- deleteCompany(id, callback) - Delelete a company by ID, read more
Not implemented: http://developers.freshdesk.com/api/#discussions
Not implemented: http://developers.freshdesk.com/api/#solutions
Not implemented: http://developers.freshdesk.com/api/#surveys
Not implemented: http://developers.freshdesk.com/api/#satisfaction-ratings
Not implemented: http://developers.freshdesk.com/api/#time-entries
Not implemented: http://developers.freshdesk.com/api/#email-configs
Not implemented: http://developers.freshdesk.com/api/#products
Not implemented: http://developers.freshdesk.com/api/#business-hours
SLA = service level agreement
Not implemented: http://developers.freshdesk.com/api/#sla-policies
Not implemented: http://developers.freshdesk.com/api/#settings
- Arjun Komath arjunkomath
- Kumar Harsh @kumarharsh
- Maksim Koryukov @maxkoryukov
Feature Request, Bugs and Ideas can be added here.
Built with <3 by Arjun Komath (and contributors), arjunkomath@gmail.com
See the LICENSE file for license rights and limitations (MIT).