Jamf Blog
June 14, 2018 by Brad Becker

7 tips and tricks for using the Classic API

The Classic API is a RESTful API and can be used to easily obtain information about devices and initiate actions within Jamf Pro. Here are seven cool ways to leverage the Classic API.

The Classic API is a RESTful API and can be used to easily obtain information about devices and initiate actions within Jamf Pro. Maybe you are a developer and want to build an awesome integration with your own solution. Or maybe you’re a Jamf Pro administrator just getting started with the API. Either way, here are seven tips and tricks to help you out wherever you are in your journey with the Classic API.

1. Read our documentation

We put a lot of work into documenting the Classic API on the Jamf Developer Portal located at https://developer.jamf.com. Here you’ll find the full API Reference for the Classic API which includes response models and example data for each endpoint. You can even use the “Try It Out” feature to execute API calls against a sample Jamf Pro instance.

In addition to the API Reference, you’ll find some general documentation around how the Classic API functions and also some code samples that show how to perform common tasks in the API.

2. Get started with a simple cURL

macOS comes with a great little command-line tool called cURL. cURL is used to get or send data using a variety of different protocols. It’s very useful and convenient to use for interacting with APIs. Here is an example of how to use cURL to interact with the “Computers” endpoint of the Classic API:

 curl -s -u myserviceaccount:mypassword

You should see an XML response that includes a listing of all computers in your Jamf Pro server.

3. Give Postman a try

While cURL is a quick and easy way to get started interacting with the Classic API, it can become a little cumbersome to use after a while. That’s why we recommend downloading Postman (https://www.getpostman.com) to take things to the next level. Postman is an API development tool that is quickly becoming the de facto standard for building and interacting with REST APIs. Postman allows you to easily generate, save and parse API requests directly within a simple interface.

4. Use JSON instead of XML

Many of our customers and partners who are scripting events to run on a Mac will already have toolsets for parsing and serializing objects in JSON. If so, then you likely don’t want to have to import libraries and modules for dealing with XML. Luckily, the Classic API supports receiving output in JSON. To do so, simply set the Accept header to “application/json”. Keep in mind that JSON is only supported for retrieving information from the Classic API, you’ll still need to use XML to perform PUT, POSTS, or DELETES.

5. Grab an SDK (of sorts)

An SDK, or Software Development Kit, is a set of development tools that allow people that write software to create applications for their development platform. Jamf doesn’t provide an official SDK for the Classic API, but our customers and partners have created several unofficial SDKs for various languages.

  • Python is one of the most common languages people use to access Jamf Pro programmatically. If you use Python then you're going to want to import python-jss (or at the minimum be aware of it). Information on python-jss can be found at https://marketplace.jamf.com/apps/?query=jss.
  • Another common language Jamf customers and partners use to access Jamf Pro is Ruby. If you're a Ruby aficionado, you'll want to check out ruby-jss, which does a lot of the work for you. For more on ruby-jss, check out the Jamf Marketplace at https://marketplace.jamf.com/details/ruby-jss/.
  • JamfKit is an SDK that can be dropped into a Swift project so you don't have to do all the work to access Classic API endpoints. For more on JamfKit, check out https://marketplace.jamf.com/details/jamfkit/.

Use any of these tools to accelerate your development against the Classic API.

6. Make sure scripts are using service accounts, not your administrative account!

Sharing data from Jamf Pro can be pretty easy. Pass a username and password to the right endpoint and you’ll get things done quickly, as you can see in the above examples. But be careful and use some good security practices. One critical aspect of doing so is to make sure to create a dedicated account for each script that can access Jamf Pro, and to configure that account with the least required amount of privileges. Jamf Pro has an extensive set of privileges for accounts which gives the ability to get very specific to ensure security around the API.

7. Ask us for more options!

Have something you need to do but can’t? Just let us know, we’re here to help. As a Jamf customer you can get API support through the standard support process. As a Jamf developer, you can reach out to us at developer.relations@jamf.com. Let us know about any functionality you’d like us to add by submitting or up-voting a feature request on Jamf Nation.

Brad Becker
Subscribe to the Jamf Blog

Have market trends, Apple updates and Jamf news delivered directly to your inbox.

To learn more about how we collect, use, disclose, transfer, and store your information, please visit our Privacy Policy.