# How can I query external TAP services?

**URL:** <https://www.rubin.community/t/how-can-i-query-external-tap-services/5726>\
**Category:** Support\
**Tags:** dp0\
**Created:** [July 27, 2021, 4:13pm UTC](https://www.rubin.community/t/how-can-i-query-external-tap-services/5726 "2021-07-27T16:13:48Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rnikutta](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/rnikutta/32/1683_2.png) [@rnikutta](https://www.rubin.community/u/rnikutta)\
**Post date:** [July 27, 2021, 4:13pm UTC](https://www.rubin.community/t/how-can-i-query-external-tap-services/5726/1 "2021-07-27T16:13:48Z")

</div>

Hi team, how could one define an external TAP service URL, and query for data there?

I was hoping that the `get_tap_service()` method from `rubin_jupyter_utils.lab.notebook` method would accept an argument to define a TAP URL, but it does not appear to be the case. Is there another way?

Thank you,  
Robert

---

<div class="post-metadata">

**Author:** ![rnikutta](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/rnikutta/32/1683_2.png) [@rnikutta](https://www.rubin.community/u/rnikutta)\
**Post date:** [July 27, 2021, 4:22pm UTC](https://www.rubin.community/t/how-can-i-query-external-tap-services/5726/2 "2021-07-27T16:22:03Z")

</div>

Ah, that function uses pyvo.dal.TAPService() under the hood. So, this works for instance:

```
import pyvo
tap = pyvo.dal.TAPService('https://datalab.noirlab.edu/tap')
tap.run_sync('select count(*) from gaia_edr3.gaia_source')

<Table length=1>
  COUNT   
  int32   
----------
1811709771

```

Thank you.

---

<div class="post-metadata">

**Author:** ![fsklich](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/fsklich/32/1589_2.png) [@fsklich](https://www.rubin.community/u/fsklich)\
**Post date:** [August 6, 2021, 1:32pm UTC](https://www.rubin.community/t/how-can-i-query-external-tap-services/5726/3 "2021-08-06T13:32:19Z")

</div>

Hi Robert  
I’m trying to run the 01\_Intro\_to\_DP0\_Notebooks jupyter notebook.  
Can you advise where you downloaded and pip-installed the **rubin\_jupyter\_utils.lab.notebook** module.  
I found one, however, while the import seems to work, the **service = get\_tap\_service()** seems to go nowhere.

---

<div class="post-metadata">

**Author:** ![MelissaGraham](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/melissagraham/32/2549_2.png) [@MelissaGraham](https://www.rubin.community/u/MelissaGraham)\
**Post date:** [August 6, 2021, 3:06pm UTC](https://www.rubin.community/t/how-can-i-query-external-tap-services/5726/4 "2021-08-06T15:06:32Z")

</div>

Hi @fsklich,  
Although you can pip install (probably you found [this](https://pypi.org/project/rubin-jupyter-utils.hub/)?), the DP0 notebooks will only work when run in the Rubin Science Platform. I’m really sorry this was unclear, and have added an explicit statement to the tutorial-notebooks repository’s [README](https://github.com/rubin-dp0/tutorial-notebooks/blob/main/README.md) file.  
Melissa

---

<div class="post-metadata">

**Author:** ![fsklich](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/fsklich/32/1589_2.png) [@fsklich](https://www.rubin.community/u/fsklich)\
**Post date:** [August 6, 2021, 3:50pm UTC](https://www.rubin.community/t/how-can-i-query-external-tap-services/5726/5 "2021-08-06T15:50:53Z")

</div>

It’s not unclear. Two days ago, I did see the intro notebook explicitly stated “Target audience: All DP0 delegates…” .

---

<div class="post-metadata">

**Author:** ![frossie](https://sea2.discourse-cdn.com/flex002/user_avatar/www.rubin.community/frossie/32/9_2.png) [@frossie](https://www.rubin.community/u/frossie)\
**Post date:** [August 6, 2021, 9:28pm UTC](https://www.rubin.community/t/how-can-i-query-external-tap-services/5726/6 "2021-08-06T21:28:47Z")

</div>

To expand on Melissa’s entirely correct answer: The RSP Notebook Aspect is a service based on JupyterLab, however the environment is heavily customized to provide convenience features to Rubin users and to support and improve service quality. This is why it is not a requirement for our notebooks to run in a stock ipython environment, and frequently they will not. `get_tap_service()`is an example of such a convenience function we provide to RSP users since depending on which particular deployment you are using, the TAP service you should address is different, but we want the same notebook to work on all our RSP deployments without modification.

That said, as @rnikutta discovered, you can address any TAP service you like using standard TAP libraries such as pyvo.
