2022-12-16 16:33:50 -05:00
---
id: tutorial-jupyter-index
2023-05-19 12:42:27 -04:00
title: Jupyter Notebook tutorials
sidebar_label: Jupyter Notebook tutorials
2022-12-16 16:33:50 -05:00
---
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
2023-03-04 21:25:19 -05:00
<!-- tutorial - jupyter - index.md and examples/quickstart/juptyer - notebooks/README.md
share a lot of the same content. If you make a change in one place, update the other
too. -->
2022-12-16 16:33:50 -05:00
2023-03-04 21:25:19 -05:00
You can try out the Druid APIs using the Jupyter Notebook-based tutorials. These
tutorials provide snippets of Python code that you can use to run calls against
the Druid API to complete the tutorial.
2022-12-16 16:33:50 -05:00
2023-03-04 21:25:19 -05:00
## Prerequisites
2022-12-16 16:33:50 -05:00
2023-05-15 18:20:52 -04:00
The simplest way to get started is to use Docker. In this case, you only need to set up Docker Desktop.
For more information, see [Docker for Jupyter Notebook tutorials ](tutorial-jupyter-docker.md ).
2022-12-16 16:33:50 -05:00
2023-05-15 18:20:52 -04:00
Otherwise, you can install the prerequisites on your own. Here's what you need:
2023-03-04 21:25:19 -05:00
2023-05-15 18:20:52 -04:00
- An available Druid instance.
- Python 3.7 or later
- JupyterLab (recommended) or Jupyter Notebook running on a non-default port.
By default, Druid and Jupyter both try to use port `8888` , so start Jupyter on a different port.
- The `requests` Python package
- The `druidapi` Python package
2023-03-04 21:25:19 -05:00
2023-05-15 18:20:52 -04:00
For setup instructions, see [Tutorial setup without using Docker ](tutorial-jupyter-docker.md#tutorial-setup-without-using-docker ).
Individual tutorials may require additional Python packages, such as for visualization or streaming ingestion.
2023-03-04 21:25:19 -05:00
2023-05-15 18:20:52 -04:00
## Python API for Druid
2022-12-16 16:33:50 -05:00
2023-05-15 18:20:52 -04:00
The `druidapi` Python package is a REST API for Druid.
2023-03-04 21:25:19 -05:00
One of the notebooks shows how to use the Druid REST API. The others focus on other
topics and use a simple set of Python wrappers around the underlying REST API. The
wrappers reside in the `druidapi` package within the notebooks directory. While the package
can be used in any Python program, the key purpose, at present, is to support these
2023-05-15 18:20:52 -04:00
notebooks. See
2023-05-30 22:42:27 -04:00
[Introduction to the Druid Python API ](https://github.com/apache/druid/blob/master/examples/quickstart/jupyter-notebooks/Python_API_Tutorial.ipynb )
2023-03-04 21:25:19 -05:00
for an overview of the Python API.
2022-12-16 16:33:50 -05:00
2023-05-15 18:20:52 -04:00
The `druidapi` package is already installed in the custom Jupyter Docker container for Druid tutorials.
2022-12-16 16:33:50 -05:00
## Tutorials
2023-03-04 21:25:19 -05:00
The notebooks are located in the [apache/druid repo ](https://github.com/apache/druid/tree/master/examples/quickstart/jupyter-notebooks/ ). You can either clone the repo or download the notebooks you want individually.
2022-12-16 16:33:50 -05:00
The links that follow are the raw GitHub URLs, so you can use them to download the notebook directly, such as with `wget` , or manually through your web browser. Note that if you save the file from your web browser, make sure to remove the `.txt` extension.
2023-03-04 21:25:19 -05:00
- [Introduction to the Druid REST API](
https://raw.githubusercontent.com/apache/druid/master/examples/quickstart/jupyter-notebooks/api-tutorial.ipynb)
walks you through some of the basics related to the Druid REST API and several endpoints.
- [Introduction to the Druid Python API](
https://raw.githubusercontent.com/apache/druid/master/examples/quickstart/jupyter-notebooks/Python_API_Tutorial.ipynb)
walks you through some of the basics related to the Druid API using the Python wrapper API.
- [Introduction to Druid SQL ](https://raw.githubusercontent.com/apache/druid/master/examples/quickstart/jupyter-notebooks/sql-tutorial.ipynb ) covers the basics of Druid SQL.