Library / SDK
libusb/hidapi avatar
libusb/hidapi

HIDAPI gives Windows, Linux, FreeBSD and macOS one C interface over four different HID back-ends

A Simple cross-platform library for communicating with HID devices

2,301 stars483 forksCLicense varies

At a glance

What is it?
HIDAPI lets an application talk to USB and Bluetooth HID-class devices through one small API, with a separate back-end for each operating system. On Linux you choose the back-end yourself, and the choice decides whether keyboards and Bluetooth devices work.
Who is it for?
HIDAPI fits a developer who needs to send and receive HID reports from a C program, or from a language binding built on it, across Windows, Linux, FreeBSD and macOS. It does not fit anyone who wants to read keyboards or mice on Linux through the hidraw back-end, or Bluetooth devices through the libusb back-end.
Can I use it commercially?
Check first. The repository uses a licence we do not classify automatically, so read its LICENSE file before any commercial use.
Is it still maintained?
Yes. The repository received new commits within the last day.
What is it written in?
Mainly C, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 25, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • libusb/hidapi2,301 ★ · +19
Star history
Repository2026-10-132026-11-25
libusb/hidapi2.3k2.3k

19 Stars in the last 43 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

Four back-ends sit behind one header

HIDAPI is a multi-platform library for applications that need to interface with USB and Bluetooth HID-class devices. The README lists four back-ends: Windows using `hid.dll`, Linux hidraw using the kernel's hidraw driver, libusb using libusb-1.0 on Linux, BSD and other UNIX-like systems, and macOS using IOHidManager.

The library can be built as a shared library (`.so`, `.dll` or `.dylib`). It can also be embedded directly by adding a single source file per platform and a single header to the target application, and the README sends you to a section of `BUILD.md` for the remarks on doing that.

The source tree mirrors the split, with directories named `linux`, `libusb`, `mac`, `windows` and `netbsd`, plus `hidapi` for the public header. Choosing a platform back-end is mostly decided for you by the operating system, apart from Linux.

On Linux you link either libhidapi-hidraw or libhidapi-libusb

Both Linux back-ends are built by default. The README says the application that links to HIDAPI chooses the back-end at link time by linking to either `libhidapi-libusb` or `libhidapi-hidraw`. It adds that there are tradeoffs and that the supported functionality is slightly different between them.

That means the decision is yours, not the library's. A program that links the wrong one can behave differently on the same machine, so test the exact build you ship.

The hidraw implementation lives in `linux/hid.c` and the libusb one in `libusb/hid.c`. The libusb back-end also covers FreeBSD, which makes it the choice there. The README gives no recommendation between the two on Linux, only the facts about what each can and cannot reach.

hidraw misses keyboards and mice, and libusb misses Bluetooth

The hidraw back-end supports both USB and Bluetooth HID devices and needs kernel version 2.6.39 or later to build. It only communicates with devices that have hidraw nodes associated with them. The README states that keyboards, mice and some other devices blacklisted from having hidraw nodes will not work, and calls this a non-issue for nearly all uses of hidraw.

The libusb back-end talks directly to a USB device through libusb-1.0, so it will not work with Bluetooth devices. If your product has to support a Bluetooth HID peripheral on Linux, hidraw is the only back-end that can reach it, and if your device is a keyboard, neither Linux option is the right tool. These are the two constraints the README documents, and each one rules out a class of hardware before any code runs.

Unprivileged access needs a udev rule that you ship

The README warns that you need to install a udev rule file with your application so that unprivileged users can access HID devices with HIDAPI. It points to `69-hid.rules` in the `udev` directory as an example.

Without the rule, your program may open the device fine as root and fail for an ordinary user, which is a classic support ticket after a release. HIDAPI does not install the rule on your behalf, and the README does not say which device identifiers the example rule targets, so read the file and adapt it to your vendor and product IDs.

This step applies to the Linux back-ends only. The README makes no equivalent statement for Windows or macOS.

The sample program opens a device by vendor and product ID

The README's API example includes `hidapi.h` and calls `hid_init()` to initialise the library. It then opens a device with `hid_open(0x4d8, 0x3f, NULL)`, which takes a vendor ID, a product ID and an optional serial number. If the handle is empty it prints `Unable to open device` and calls `hid_exit()`. The example continues with `hid_get_manufacturer_string`, reading into a wide character buffer of `MAX_STR` (255).

The program talks to a heavily hacked up version of the Microchip USB Generic HID sample, so the IDs there are specific to that board. The README says the API covers the most commonly used HID functions, including sending and receiving input, output and feature reports.

A bold warning sits above the sample: only run code you understand and only when it conforms to the device spec, because writing data with `hid_write` at random can break your HID devices. `hidtest/test.c` is named as a starting point for your own application.

Installing is one apt line on Ubuntu, and a source build elsewhere

To build an application against HIDAPI you need the development package. The README says it is likely provided by your package manager and gives one example for Ubuntu:

sh
sudo apt install libhidapi-dev

It notes that the package name for other systems and package managers may differ, and tells you to check their package lists. The README has no instructions for Windows beyond that, so a Windows user builds from source or takes a package from a manager they already use.

Building from source is delegated to `BUILD.md`. The repository also contains `BUILD.autotools.md` and `BUILD.cmake.md`, along with `configure.ac`, `Makefile.am`, `CMakeLists.txt` and `meson.build`, so three build systems are present. The README does not say which of the three is preferred.

The Test GUI is a historical artifact, and hidapitester replaces it

The repository still has a `testgui` directory. It uses Fox Toolkit, builds on every supported platform, and is useful when debugging hardware. The README then says the Test GUI is not actively developed or supported and is kept as a historical artifact, with no new features or bugfixes coming. It asks you to use Fox-Toolkit v1.6 if you build it and gives no install steps for the toolkit.

For poking at a device before development, the README points to `hidapitester`, a console app from a separate repository that offers most of HIDAPI's features.

On history and licensing: Alan Ott (signal11) originally developed the library, and it moved to libusb/hidapi on June 4th, 2019 to merge important bugfixes. HIDAPI may be used under one of three licenses described in `LICENSE.txt`. The release list shows hidapi-0.15.0 from May 2025 as the latest, and the last push was on 10 October 2026.

Editorial conclusion

HIDAPI fits a developer who needs to send and receive HID reports from a C program, or from a language binding built on it, across Windows, Linux, FreeBSD and macOS. It does not fit anyone who wants to read keyboards or mice on Linux through the hidraw back-end, or Bluetooth devices through the libusb back-end. Before adopting it, decide which Linux back-end you will link and ship the udev rule your users need, then check LICENSE.txt, because GitHub reports the license as NOASSERTION.

Frequently asked questions

what is hid api

HIDAPI is a multi-platform library that lets an application interface with USB and Bluetooth HID-class devices on Windows, Linux, FreeBSD and macOS.

how to install hidapi

On Ubuntu, run sudo apt install libhidapi-dev. Package names on other systems may differ, and BUILD.md covers building from source.

how to use hidapi

Include hidapi.h, call hid_init(), then open a device with hid_open using its vendor ID, product ID and optional serial number. hidtest/test.c is a starting point.

Official sources

  1. Issues
  2. libusb/hidapi on GitHub
  3. Project website
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/libusb-hidapi.svg)](https://hysenlabs.com/projects/libusb-hidapi)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/libusb-hidapi.svg)](https://hysenlabs.com/projects/libusb-hidapi)

Was this useful?