Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jjanuszczak/freshdeskr
R client for Freshdesk
https://github.com/jjanuszczak/freshdeskr
Last synced: 9 days ago
JSON representation
R client for Freshdesk
- Host: GitHub
- URL: https://github.com/jjanuszczak/freshdeskr
- Owner: jjanuszczak
- License: mit
- Created: 2018-04-29T12:19:20.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-07-22T10:20:37.000Z (over 6 years ago)
- Last Synced: 2024-08-13T07:15:38.822Z (4 months ago)
- Language: R
- Size: 89.8 KB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 11
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - jjanuszczak/freshdeskr - R client for Freshdesk (R)
README
---
output: github_document
---# freshdeskr: An R Package for the Freshdesk API
**Authors:** [John Januszczak](https://github.com/jjanuszczak)
**License:** [MIT](https://opensource.org/licenses/MIT)[![Travis-CI Build Status](https://travis-ci.org/jjanuszczak/freshdeskr.svg?branch=master)](https://travis-ci.org/jjanuszczak/freshdeskr)
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "README-"
)
```This R package acts as a wrapper for the [Freshdesk API](https://developers.freshdesk.com/api/). Currently, the package contains functionality for retrieving ticket, agent, company and contact data from Freshdesk. This data can be used in subsequent analysis.
## Installation
You can install freshdeskr from github with:
```{r gh-installation, eval = FALSE}
# install.packages("devtools")
devtools::install_github("jjanuszczak/freshdeskr")
```## Examples
The following examples demonstrate how to retrieve ticket, agent, company and contact data from Freshdesk.
### Tickets
Using the `tickets` method, retrieve a data frame of tickets and get the status, priority and subject of all tickets updated since May 1, 2018:
```{r credentials, echo=FALSE}
my_domain <- Sys.getenv("FRESHDESK_DOMAIN")
my_api_key <- Sys.getenv("FRESHDESK_API_KEY")
``````{r example0, warning=FALSE}
library(freshdeskr)# create a client
fc <- freshdesk_client(my_domain, my_api_key)# gets tickets undated since May 1, 2018
ticket_data <- tickets(fc, updated_since = "2018-05-01")# subset by columns of interest
ticket_data[, c("subject", "status", "priority")]
```### Companies
Using the `companies` method, get a list of companies:
```{r example00}
# retrieve all companies
comps <- companies(fc, max_records = 2)head(comps)
```### Agents
Using the `agent` method, get data on an agent based on the agent ID:
```{r example0a}
# get agent based on agent id
ag <- agent(fc, 42001318960)# get the agent's name and email
cat(ag$contact$name, ",", ag$contact$email)
```### Contacts
Use the `contacts` method to add contact name and email to a list of tickets
```{r example0b}
# get tickets updated since January 1, 2018
ticket_date <- tickets(fc, updated_since = "2018-01-01")# get data on all contacts
contact_data <- contacts(fc)# join data frames
tickets_with_contact_info <- merge(x = ticket_data, y = contact_data, by.x = "requester_id", by.y = "id")# show contact name and email with ticket number and subject
tickets_with_contact_info[, c("id", "subject", "name", "email")]
```## Interacting Directly with the API
For lower level control and flexibility, use the `freshdesk_api` function to call the Freshdesk API directly to retrieve the following:
* parsed and consolidated content from the API's http respose objects
* the http response objects[1](#footnote1)
* rate limit statusIn the following example, we retrieve the ticket subject from the parsed response object:
```{r example1}
library(freshdeskr)# create a client
fc <- freshdesk_client(my_domain, my_api_key)# query the api and view the details of ticket #3
apidata <- freshdesk_api(fc, "/api/v2/tickets/3")# get useful data from the parsed response
apidata$content$subject
```One can also inspect the http response directly, for example:
```{r example2}
apidata$response$status_code
```Rate limit information is also returned by calls to the `freshdesk_api` function:
```{r example3}
# get current status of rate limit at time of api call
apidata$rate_limit_remaining
```Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md).
By participating in this project you agree to abide by its terms.## Endnotes
1The `freshdesk_api` method automatically handles pagination. If more than one api call was made to fetch data, a list of http response objects will be returned.