See the px-api-viewer source code on Github.