API reference

Welcome to the API reference for BadgePython.

This reference describes all officially supported APIs of our platform. We try to keep these APIs as stable as possible. There are many more (undocumented) APIs in the firmware, all of which may change at any time!

BadgePython uses MicroPython at it’s core.The libraries and APIs from the upstream MicroPython project are available in BadgePython.

The MicroPython documentation describes the builtin libraries and functions.

We’ve added some badge specific APIs for efficiently controlling hardware like the display and reading the buttons. By implementing the resource intensive parts of driving the hardware in C. This allows for a much more speedy experience and a lot more possibilities and flexibility.

If you want to help with firmware development please tell us! We’re always happy to accept PRs and improvements.

Should you have ideas, problems or observations but no means to act on them then you can always create an issue on Github.

BadgePython APIs

LibraryFunctionMCM2022SHA2017Disobey 2019Disobey 2020HackerHotel 2019CampZone 2019CampZone 2020
displayControl the display of your badge: create and display text and graphics
buttonsRead button status and attach callback functions to button interactions
mch22MCH2022 specific functions

Other libraries and APIs

This section lists most of the other libraries that you can use in your apps.

LibraryFunctionDocumentation
mathMathematical functionsMicroPython
cmathMathematical functions for complex numbersMicroPython
ubinasciiUtilities for working with binary data (Hex-string, base64 and CRC32 calculationMicroPython
ucollectionsCollection and container typesMicroPython
uerrnoSystem error code referenceMicroPython
uhashlibSHA1 and SHA256 hashing algorithmsMicroPython
uheapqHeap queue algorithmMicroPython
uioInput/output streamsMicroPython
ujsonJSON encoding and decodingMicroPython
uosBasic “operating system” servicesMicroPython
ureSimple regular expressionsMicroPython
uselectWait for events on a set of streamsMicroPython
usocketSockets (TCP, UDP)MicroPython
usslSSL/TLS moduleMicroPython
ustructPack and unpack primitive data typesMicroPython
utimeTime related functionsMicroPython
uzlibZlib decompressionMicroPython
_threadMultithreading supportMicroPython
gcControl the garbage collectorMicroPython
sysSystem specific functionsMicroPython
machineFunctions related to the hardware (Note: different from upstream version)MicroPython
micropythonAccess and control MicroPython internalsMicroPython
networkNetwork configuration (Please use the wifi library instead when possible)MicroPython
espESP32 specific functions (Note: direct flash access has been disabled)MicroPython
Last modified December 13, 2024: Remove WHY2025 badge (8f6c078)