TopGit tracks zendesk/zendesk_api_client_rb on GitHub as part of the Backend family. The project has 410 stars. Official Ruby Zendesk API Client
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
This Ruby gem is a generic wrapper around Zendesk's REST API. Follow this README and the wiki for how to use it.
You can interact with all the resources defined in resources.rb. Basically we have some clever code to convert Ruby objects into HTTP requests.
Please refer to our API documentation for the specific endpoints and once you understand the mapping between Ruby and the HTTP endpoints you should be able to call any endpoint.
The Yard generated documentation is available in at RubyDoc.
Please report any bug in the Github issues page.
You might want to try out this gem in a REPL for exploring your options, if so, check out this project.
Product Support
This Ruby gem supports the REST API's for Zendesk Support, Zendesk Guide,
and Zendesk Talk. It does not yet support other Zendesk products such as
Zendesk Chat, Zendesk Explore, and Zendesk Sell.
Installation
The Zendesk API client can be installed using Rubygems or Bundler.
Rubygems
gem install zendesk_api
Bundler
Add it to your Gemfile
gem "zendesk_api"
Then bundle install as usual.
Configuration
Configuration is done through a block returning an instance of ZendeskAPI::Client.
require 'zendesk_api'
client = ZendeskAPI::Client.new do |config|
# Mandatory:
config.url = "<- your-zendesk-url ->" # e.g. https://yoursubdomain.zendesk.com/api/v2
# Basic / Token Authentication
config.username = "[email protected]"
# Choose one of the following depending on your authentication choice
# More information on obtaining API tokens can be found here:
# https://developer.zendesk.com/api-reference/introduction/security-and-auth/#api-token
config.token = "your zendesk token"
# OAuth Authentication
# More information on obtaining OAuth access tokens can be found here:
# https://developer.zendesk.com/api-reference/introduction/security-and-auth/#oauth-access-token
config.access_token = "your OAuth access token"
# Optional:
# Retry uses middleware to notify the user
# when hitting the rate limit, sleep automatically,
# then retry the request.
config.retry = true
# Raise error when hitting the rate limit.
# This is ignored and always set to false when `retry` is enabled.
# Disabled by default.
config.raise_error_when_rate_limited = false
# Logger prints to STDERR by default, to e.g. print to stdout:
require 'logger'
config.logger = Logger.new(STDOUT)
# Disable resource cache (this is enabled by default)
config.use_resource_cache = false
# Changes Faraday adapter
# config.adapter = :patron
# Merged with the default client options hash
# config.client_options = {:ssl => {:verify => false}, :request => {:timeout => 30}}
# When getting the error 'hostname does not match the server certificate'
# use the API at https://yoursubdomain.zendesk.com/api/v2
# Change retry configuration (this is disabled by default)
config.retry_on_exception = true
# Error codes when the request will be automatically retried. Defaults to 429, 503
config.retry_codes = [ 429 ]
end
Usage
The result of configuration is an instance of ZendeskAPI::Client which can then be used in two different methods.
One way to use the client is to pass it in as an argument to individual classes.
Note: all method calls ending in ! will raise an exception when an error occurs, see the wiki page for more info.
The methods under ZendeskAPI::Client (such as .tickets) return an instance of ZendeskAPI::Collection, a lazy-loaded list of that resource.
Actual requests may not be sent until an explicit ZendeskAPI::Collection#fetch!, ZendeskAPI::Collection#to_a!, or an applicable methods such
as #each.
Caveats
Resource updating is implemented by sending only the changed? attributes to the server (see ZendeskAPI::TrackChanges).
Unfortunately, this module only hooks into Hash meaning any changes to an Array not resulting in a new instance will not be tracked and sent.
# Note that CBP (cursor based pagination) is the default and preferred way
# and has fewer limitations on deep pagination
tickets = client.tickets.per_page(3)
page1 = tickets.fetch! # GET /api/v2/tickets?page[after]={cursor}&page[size]=3
page2 = tickets.next # GET /api/v2/tickets?page[after]={cursor}&page[size]=3
# ...
# OR...
# Note that OBP (offset based pagination) can incur to various limitations
tickets = client.tickets.page(2).per_page(3)
next_page = tickets.next # => 3
tickets.fetch! # GET /api/v2/tickets?page=3&per_page=3
previous_page = tickets.prev # => 2
tickets.fetch! # GET /api/v2/tickets?page=2&per_page=3
Iteration over all resources and pages is handled by Collection#all:
client.tickets.all! do |resource|
# every resource, from all pages, will be yielded to this block
end
If given a block with two arguments, the page number is also passed in.
client.tickets.all! do |resource, page_number|
# all resources will be yielded along with the page number
end
Cursor Based Pagination
A few endpoints related to organizations, tickets, triggers and groups will now make use of cursor based pagination by default.
It is also recommended to use CBP whenever the Zendesk developer documentation says it's supported.
Pass page[size]=number in the parameters to attempt a CBP request, like the example below:
Callbacks can be added to the ZendeskAPI::Client instance and will be called (with the response env) after all response middleware on a successful request.
client.insert_callback do |env|
puts env[:response_headers]
end
Resource management
Individual resources can be created, modified, saved, and destroyed.
To facilitate a smaller number of requests and easier manipulation of associated data we allow "side-loading," or inclusion, of selected resources.
For example:
A ZendeskAPI::Ticket is associated with ZendeskAPI::User through the requester_id field.
API requests for that ticket return a structure similar to this:
Calling ZendeskAPI::Ticket#requester automatically fetches and loads the user referenced above (/api/v2/users/7).
Using side-loading, however, the user can be partially loaded in the same request as the ticket.
tickets = client.tickets.include(:users)
# Or client.tickets(:include => :users)
# Does *NOT* make a request to the server since it is already loaded
tickets.first.requester # => #<ZendeskAPI::User id=...>
# OR
ticket = client.tickets.find!(:id => 1, :include => :users)
ticket.requester # => #<ZendeskAPI::User id=...>
Currently, this feature is limited to only a few resources and their associations.
They are documented on developer.zendesk.com.
Recommended Approach
For better control over your data and to avoid large response sizes, consider fetching related resources explicitly. This approach can help you manage data loading more precisely and can lead to optimized performance for complex applications.
By explicitly fetching associated resources, you can ensure that your application only processes the data it needs, improving overall efficiency.
Omnichannel
Support for the Agent Availability API
An agent’s availability includes their state (such as online) for each channel (such as messaging), and their unified state across channels. It also includes the work items assigned to them.
# All agent availabilities
client.agent_availabilities.fetch
# fetch availability for one agent, their channels and work items
agent_availability = ZendeskAPI::AgentAvailability.find(client, 386390041152)
agent_availability.channels
agent_availability.channels.first.work_items
# Using the agent availability filter
ZendeskAPI::AgentAvailability.search(client, { select_channel: 'support' })
ZendeskAPI::AgentAvailability.search(client, { channel_status: 'support:online' })
Search
Searching is done through the client. Returned is an instance of ZendeskAPI::Collection:
client.search(:query => "my search query") # /api/v2/search.json?query=...
client.users.search(:query => "my new query") # /api/v2/users/search.json?query=...
Special case: Custom resources paths
API endpoints such as tickets/recent or topics/show_many can be accessed through chaining.
They will too return an instance of ZendeskAPI::Collection.
Note: job statuses are currently not supported, so you must manually poll the job status API for app creation.
body = {}
until %w{failed completed}.include?(body["status"])
response = client.connection.get(app.response.headers["Location"])
body = response.body
sleep(body["retry_in"])
end
See .github/workflows/main.yml to understand the CI process.
bundle exec rake # Runs the tests
bundle exec rubocop # Runs the lint (use `--fix` for autocorrect)
Releasing a new version
A new version is published to RubyGems.org every time a change to version.rb is pushed to the main branch.
In short, follow these steps:
Update version.rb,
merge this change into main,
post a message in Slack #rest-api, so advocacy are aware that we are going to release a new gem, just in case any customer complains about something related to the gem,
after 2 hours from the above message, you can approve the release of the gem
look at the action for output.
To create a pre-release from a non-main branch:
change the version in version.rb to something like 1.2.0.pre.1 or 2.0.0.beta.2,
push this change to your branch,
go to Actions → “Publish to RubyGems.org” on GitHub,
click the “Run workflow” button,
pick your branch from a dropdown.
Contributing
Fork the project.
Make your feature addition or bug fix.
Add tests for it. This is important so that we don't break it in a future
version unintentionally.
Commit. Do not alter Rakefile, version, or history. (If you want to have
your own version, that is fine, but bump version in a commit by itself that
we can ignore when we pull.)
Submit a pull request.
Note: Live specs will likely fail for external contributors. The Zendesk devs can help with that. If you have permissions and some live specs unexpectedly fail, that might be a data error, see the REPL for that.
Merging contributors pull requests
External contributions don't run live specs, so we need to use a workaround. Assuming a PR from author:author/branch to default_branch:
Create a branch in our repo author_branch
Change the destination branch of the PR to author_branch
Merge
Create a pr in our repo from default_branch
Make sure they know the commits still carry their name
How active is development on zendesk/zendesk_api_client_rb?
The most recent commit recorded on zendesk/zendesk_api_client_rb was 1 month ago, based on the GitHub push timestamp. The repository has 182 forks — one of the better signals of community interest.
How many stars does zendesk/zendesk_api_client_rb have?
zendesk/zendesk_api_client_rb has 410 GitHub stars — refresh the page for the live number, or check github.com/zendesk/zendesk_api_client_rb. TopGit mirrors GitHub's count but does not claim minute-by-minute accuracy.
Is zendesk/zendesk_api_client_rb open source?
Yes — zendesk/zendesk_api_client_rb ships under the Apache-2.0 license, which makes its source code freely readable (and, depending on license terms, forkable and reusable). Source: github.com/zendesk/zendesk_api_client_rb.
What else is in the Backend space?
zendesk/zendesk_api_client_rb is tracked by TopGit under the Backend category, alongside 2 GitHub-tagged topics. Trending and Topics pages list peer repositories of comparable stars and language.
What topics is zendesk/zendesk_api_client_rb associated with?
GitHub's repository topics for zendesk/zendesk_api_client_rb: "ruby", "zendesk". TopGit's editorial category is Backend.
Where can I see zendesk/zendesk_api_client_rb in action?
The project maintains a homepage at http://developer.zendesk.com/. The README tab on this page also usually contains screenshots and a quickstart.
Where do I read more about zendesk/zendesk_api_client_rb?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/zendesk/zendesk_api_client_rb is the definitive source.
Read full README in the tab above.
Curious whether zendesk_api_client_rb is right for you?
Let ChatGPT, Claude, or Perplexity look into it — click below and see what AI actually says about zendesk_api_client_rb.