# How to use qan-api2?

**URL:** <https://forums.percona.com/t/how-to-use-qan-api2/14611>\
**Category:** PMM 2.x\
**Tags:** pmm\
**Created:** [March 3, 2022, 8:34am UTC](https://forums.percona.com/t/how-to-use-qan-api2/14611 "2022-03-03T08:34:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![xiangqianforth](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/xiangqianforth/32/5910_2.png) [@xiangqianforth](https://forums.percona.com/u/xiangqianforth)\
**Post date:** [March 3, 2022, 8:34am UTC](https://forums.percona.com/t/how-to-use-qan-api2/14611/1 "2022-03-03T08:34:56Z")

</div>

I used docker to build PMM-server in the local environment. The version is 2.25.0.

I want to use qan-api2 provided on GitHub to get the data of query-analysis, but these interfaces can’t be used.

> **[GitHub - percona/qan-api2: qan-api for PMM 2.x.](https://github.com/percona/qan-api2)**
>
> qan-api for PMM 2.x. Contribute to percona/qan-api2 development by creating an account on GitHub.

example:  
curl -s -X POST -d ‘{“period\_start\_from”: “2019-01-01T00:00:00Z”, “period\_start\_to”: “2019-01-01T10:00:00Z”, “order\_by”: “num\_queries”, “columns”: [“lock\_time”, “sort\_scan”], “group\_by”: “server”}’ [http://127.0.0.1:9922/v0/qan/GetReport](http://127.0.0.1:9922/v0/qan/GetReport) | jq

question:

1. Which process port is 9922?
2. Do you need to make some settings on PMM server before using this API?
3. Can this interface really be used
4. Can qan-API provide more detailed documentation?
5. Is there no permission setting for using this API? Such as key and admin password?

I can’t thank you enough for asking for help

---

<div class="post-metadata">

**Author:** ![xiangqianforth](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/xiangqianforth/32/5910_2.png) [@xiangqianforth](https://forums.percona.com/u/xiangqianforth)\
**Post date:** [March 4, 2022, 2:33pm UTC](https://forums.percona.com/t/how-to-use-qan-api2/14611/2 "2022-03-04T14:33:20Z")

</div>

please help me, thank you very much!

---

<div class="post-metadata">

**Author:** ![Michael\_Coburn](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/michael_coburn/32/18_2.png) [@Michael\_Coburn](https://forums.percona.com/u/Michael_Coburn)\
**Post date:** [March 4, 2022, 5:35pm UTC](https://forums.percona.com/t/how-to-use-qan-api2/14611/3 "2022-03-04T17:35:45Z")

</div>

Hi @xiangqianforth , thank you for posting to the Percona forums!

> [@xiangqianforth](#):
>
> Which process port is 9922?

I’m not familiar with this port, you should be using port `443/tcp` in order to interact with the PMM Server

> [@xiangqianforth](#):
>
> Do you need to make some settings on PMM server before using this API?

No, the API should already be fully functional as this is how for example `pmm-admin` communicates remotely with PMM Server.

> [@xiangqianforth](#):
>
> - Can this interface really be used

The feature is GA so should be useful

> [@xiangqianforth](#):
>
> - Can qan-API provide more detailed documentation?

This is a known limitation - as you discover more working examples we would appreciate you sharing them with the Community, and we would be happy to put them in our Documentation

> [@xiangqianforth](#):
>
> 1. Is there no permission setting for using this API? Such as key and admin password?

yes you should be using the syntax and of course changing your password as needed:

```auto
curl ... --user "admin:admin" ...

```

may I additionally mention that we provide a swagger interface that will help you to develop the correct `curl` syntax. The location is simply [https://PMM-SERVER/swagger/](https://PMM-SERVER/swagger/)

Best of luck!

---

<div class="post-metadata">

**Author:** ![xiangqianforth](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/xiangqianforth/32/5910_2.png) [@xiangqianforth](https://forums.percona.com/u/xiangqianforth)\
**Post date:** [March 4, 2022, 8:30pm UTC](https://forums.percona.com/t/how-to-use-qan-api2/14611/5 "2022-03-04T20:30:09Z")

</div>

Hi,@Michael_Coburn, Thank you for your reply!

But when I use curl command, I can’t get the correct return result. For example, my PMM server runs on 192.168.70.13.

Can you share some examples of using this API correctly? (v0/qan/GetMetricsNames)

 ![test](https://us1.discourse-cdn.com/flex019/uploads/percona1/original/2X/7/7608d8c0cf73c07d65d69777275ff7d6628642ea.png)

 ![test3](https://us1.discourse-cdn.com/flex019/uploads/percona1/original/2X/1/12601dc7fad6e04cd6b2f1c22e37a1972a43e191.png)

---

<div class="post-metadata">

**Author:** ![nurlan](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/nurlan/32/1523_2.png) [@nurlan](https://forums.percona.com/u/nurlan)\
**Post date:** [March 6, 2022, 12:36pm UTC](https://forums.percona.com/t/how-to-use-qan-api2/14611/6 "2022-03-06T12:36:16Z")

</div>

Hi @xiangqianforth,

If you open [https://PMM-SERVER/swagger/](https://pmm-server/swagger/) and replace value /swagger.json with /swagger-dev.json on the top input you will be able to see definition of QAN endpoints.

```auto
curl -X POST "https://PMM-SERVER/v0/qan/GetMetricsNames" -H "accept: application/json" -H "Content-Type: application/json" -d "{}"

```

Best regards,  
Thanks
