# Is a Python API available for the QA401?

**URL:** <https://forum.quantasylum.com/t/is-a-python-api-available-for-the-qa401/141>\
**Category:** Uncategorized\
**Created:** [July 30, 2020, 6:51pm UTC](https://forum.quantasylum.com/t/is-a-python-api-available-for-the-qa401/141 "2020-07-30T18:51:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![voltist](https://avatars.discourse-cdn.com/v4/letter/v/9fc348/32.png) [@voltist](https://forum.quantasylum.com/u/voltist)\
**Post date:** [July 30, 2020, 6:51pm UTC](https://forum.quantasylum.com/t/is-a-python-api-available-for-the-qa401/141/1 "2020-07-30T18:51:55Z")

</div>

We have test suites built in Python for competitor’s audio analyzer, but is an API available for the QA401 if we decide to make a switch?

---

<div class="post-metadata">

**Author:** ![matt](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@matt](https://forum.quantasylum.com/u/matt)\
**Post date:** [July 31, 2020, 3:43pm UTC](https://forum.quantasylum.com/t/is-a-python-api-available-for-the-qa401/141/2 "2020-07-31T15:43:43Z")

</div>

Hi @voltist, there are two APIs into the QA401 hardware. The QAAnalyzer.exe application exposes a dotnet remoting API.That will be hard to implement in Python.

But there’s a headless application (no gui) called the [QA401H](https://github.com/QuantAsylum/QA401H) that runs on Linux/Windows/Mac and can be “driven” by any language that supports a REST interface. And since REST is just a series of calls to load and process web pages, every language can speak to the QA401H box.

In the first link below, you’ll see an example of using Python to make a THD measurement.

The QA401H app doesn’t get the same love and attention that the GUI app does in terms of release frequency–it’s more of a workhorse app designed to sit in a factory doing its thing day in and day out. You get it working once and then don’t touch it unless you need to add tests. In other words, a QA401H install is not something you are upgrading every month like many do on the GUI app. (I just updated the outstanding customer-reported issues for the QA401H app on github [HERE](https://github.com/QuantAsylum/qa401h/issues))

I’d suggest you try a small sample with Python and the QA401H app and see how it feels. Eventually, the REST interface in the QA401H will replace the dotnet remoting interface in the GUI app too.

> **[QA401H, REST and Python](https://quantasylum.com/blogs/news/qa401h-rest-and-python?_pos=1&_sid=15855c318&_ss=r)**
>
> Release 0.99 of QA401H is up at Github. Release 0.99 moves a step closer to shipping the headless version of the QA401 control software, and measurements made with QA401H should now be agreeing very well with the QA401 GUI.
> The QA401 hardware product...

> **[QA401 Headless & Linux Support](https://quantasylum.com/blogs/news/qa401-headless-linux?_pos=2&_sid=15855c318&_ss=r)**
>
> There are two recurring requests for the QA401 platform: First, people ask if they can easily control the hardware from a language like Python, Matlab or LabView instead of DotNet C# or C++ (both of which can easily automate QA401 measurements). The...

---

<div class="post-metadata">

**Author:** ![voltist](https://avatars.discourse-cdn.com/v4/letter/v/9fc348/32.png) [@voltist](https://forum.quantasylum.com/u/voltist)\
**Post date:** [August 5, 2020, 1:29pm UTC](https://forum.quantasylum.com/t/is-a-python-api-available-for-the-qa401/141/3 "2020-08-05T13:29:32Z")

</div>

I unplugged the QA401 from my USB hub and plugged directly to my pc and now it seems to be working - at least the headless app. See output below

I’m getting connection errors when running the python code

Server started listening on port 9401  
The webserver has stopped. Webserver exception: Access is denied.  
The webserver may have failed to start listening on the specified port. It may require the application to run with admin privs OR a namespace reservation needs to be made on the port you desire. For example, for port 9401:netsh http add urlacl url=http://\*:9401/ user=DOMAIN\userTo check entries, use: netsh http show urlacl  
Version: 0.995  
Loading FX2 with file 16C04E27.hex [b58731ad] (Match)  
Usb re-opened  
Loading FPGA File: qa401.bit [eeba84b2] (Match)  
FPGA File DateTime: 4/4/2019 11:32 AM  
…  
Done loading FPGA  
===USB DESCRIPTORS===  
Endpoint: 0x1 Max Packet Size: 64 bytes  
Endpoint: 0x81 Max Packet Size: 64 bytes  
Endpoint: 0x2 Max Packet Size: 512 bytes  
Endpoint: 0x4 Max Packet Size: 512 bytes  
Endpoint: 0x86 Max Packet Size: 512 bytes  
Endpoint: 0x88 Max Packet Size: 512 bytes  
Waiting for HTTP…  
From your web browser, go to [http://localhost:9401](http://localhost:9401)  
Press ‘X’ to exit

---

<div class="post-metadata">

**Author:** ![matt](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@matt](https://forum.quantasylum.com/u/matt)\
**Post date:** [August 5, 2020, 4:22pm UTC](https://forum.quantasylum.com/t/is-a-python-api-available-for-the-qa401/141/4 "2020-08-05T16:22:21Z")

</div>

It looks like the webserver couldn’t start. Usually this is because the QA401H software tries to open port 9401 and it is already open (by the QA401 application) OR because your system won’t allow it.

Assuming you are on windows…to make sure it’s not the former, just ensure sure the QA401 application isn’t running and/or that it’s not stuck in a zombie state in your process list.

To see if your system won’t allow it, go to a cmd line and type

```auto
netsh http show urlacl

```

This lets you see who is allowed to open what ports. There’s a very, very small chance that another app might be using that port. But generally, there won’t be anything and you can add access to that port via:

```auto
netsh http add urlacl url=http://*:9401/ user=DOMAIN\user

```

where DOMAIN\user is changed to what is appropriate for your machine. OR you can run the QA401H app as admin.

More discussion [HERE](https://stackoverflow.com/questions/4019466/httplistener-access-denied) on Stackoverflow. This has been a bit of a hit or miss problem–some machines don’t need the extra permissions added, and some do.

Then, run the QA401H app again and type `http://localhost:9401` in a browser and it should open the REST interface as an HTML page.

---

<div class="post-metadata">

**Author:** ![voltist](https://avatars.discourse-cdn.com/v4/letter/v/9fc348/32.png) [@voltist](https://forum.quantasylum.com/u/voltist)\
**Post date:** [August 5, 2020, 6:08pm UTC](https://forum.quantasylum.com/t/is-a-python-api-available-for-the-qa401/141/5 "2020-08-05T18:08:42Z")

</div>

I am the admin of my pc, and it does not belong to a domain.

---

<div class="post-metadata">

**Author:** ![matt](https://avatars.discourse-cdn.com/v4/letter/m/a6a055/32.png) [@matt](https://forum.quantasylum.com/u/matt)\
**Post date:** [August 5, 2020, 8:52pm UTC](https://forum.quantasylum.com/t/is-a-python-api-available-for-the-qa401/141/6 "2020-08-05T20:52:58Z")

</div>

OK, so you need to determine your domain and user names. Your domain name on a home machine is the machine name. Type ‘system’ in the search bar and that will bring up the control panel system and security window. There, you can see the computer name–treat that as your domain name. And then type `netsh http add urlacl url=http://*:9401/ user=DOMAIN\user` into a command prompt (with domain and user adjusted to your identity). And then try to reach via `http://localhost:9401` in a browser and see if the webserver returns the expected page.
