← field notes
2025-03-05 · API · swagger · developer-tools · documentation · thistle

Using Swagger UI to Explore and Test the Thistle Device Hub API

previously @ Thistle Technologies

How we integrated Swagger UI into the Thistle Device Hub API for interactive API exploration, testing endpoints directly from the browser without writing code.

Swagger UI provides an interactive way to explore, understand, and test APIs without writing a single line of code. In this blog post, I'll show you how we've integrated Swagger documentation into the Thistle Device Hub API and how you can use it to quickly test endpoints and learn about the API's capabilities.

What is Swagger UI?

Swagger UI is a powerful tool that renders OpenAPI specifications as interactive documentation. It allows developers to:

  • Explore available endpoints and operations
  • Understand request parameters and response formats
  • Test API calls directly from the browser
  • View model schemas and data structures

Accessing the Thistle Device Hub API Documentation

We've integrated Swagger UI into our Device Hub service, making it accessible at /swagger/ on the Device Hub instance. The interactive interface displays all available API endpoints in a clean layout.

Exploring the API

The Swagger UI for the Thistle Device Hub API is organized by endpoints, with each section representing a different API operation:

  • Browse Endpoints: All available endpoints are listed in the main panel, grouped by functionality
  • Expand Operations: Click on any endpoint to expand it and see detailed information
  • View Parameters: Each operation shows required and optional parameters
  • Examine Responses: Response codes and data structures are visible

Swagger UI overview showing endpoint listings and model schemas

Testing Endpoints

One of the most powerful features of Swagger UI is the ability to test API calls directly from the documentation:

  1. Select an Endpoint — e.g. /enroll, /manifest, /identity
  2. Click "Try it out" — appears in the expanded view
  3. Fill in Parameters — enter required values or request body
  4. Execute — makes a live API call
  5. View Results — response with status code, headers, and body

Understanding Authentication

Many Device Hub API endpoints require authentication. Swagger UI indicates authentication requirements per endpoint and allows testing with credentials.

Example: Testing Device Enrollment

Walk through the device enrollment process using Swagger UI:

  • Navigate to /enroll in the documentation
  • Click "Try it out"
  • Fill in the required enrollment information
  • Execute and review the enrollment result

Testing the /enroll endpoint in Swagger UI

Benefits of Swagger UI

  • Faster Development: Quickly understand API interactions
  • Reduced Learning Curve: Visual representation makes the API more accessible
  • Interactive Testing: Test endpoints without external tools
  • Self-Documentation: Always up-to-date with the actual API

Conclusion

Swagger UI provides a powerful way to explore and test the Thistle Device Hub API without writing code. Whether you're a new developer getting familiar with our platform or an experienced user looking to quickly test a specific endpoint, the interactive documentation makes working with our API faster and more intuitive.