Application tutorials¶
Use the existing movie dataset to build a movie cast service. The application accepts a movie ID and returns JSON with the movie name and its actors through GET /movies/{movie_id}/actors.
Audience¶
These tutorials are for developers who know basic Python and want to use database queries in an application. They use FastAPI to provide an HTTP endpoint; no previous knowledge of the framework is required. The examples read existing data without creating or modifying graph data.
Choose a connection method¶
| Tutorial | NebulaGraph Database Developer Edition connection | Main topics |
|---|---|---|
| Build a service with the Python SDK | Python SDK, port 9669 |
Execute queries through a client and read result sets |
| Build a service with the REST API | HTTP, port 19669 (preview feature) |
Obtain a JWT token, send query requests, and read responses |
Both tutorials implement the same application endpoint; choose either one. Start with the Python SDK for your first example, or choose the REST API to access NebulaGraph Database Developer Edition over HTTP. Both provide complete code to download.
Prepare NebulaGraph Database Developer Edition¶
- Start NebulaGraph Database Developer Edition by following Deploy Developer Edition with Docker Compose.
- Follow Connect and run your first query to load
movieand confirm that you can query movie ID3and its actors. Reuse the data if it is already loaded. - Have a NebulaGraph Database Developer Edition username and password ready. For local practice, use
rootwith the actual password set during deployment; see Set the root password for settings and escaping rules. If you changed the password, use the new one.
The examples query /default_schema/movie. If the data is in another Schema, update the graph path in both queries in the example file.
Request flow¶
flowchart LR
caller["Browser or curl"] -->|"HTTP · 8100"| app["Movie cast service<br/>FastAPI"]
app -->|"Python SDK · 9669<br/>or REST API · 19669"| database["Graph database<br/>movie graph"]
A browser or curl calls the application on port 8100; the application then accesses NebulaGraph Database Developer Edition. The application validates movie IDs, runs queries, and returns JSON. It stores and uses the NebulaGraph Database Developer Edition credentials and JWT tokens.
The example application listens on 127.0.0.1, so you can access it from the application computer. If you run it remotely over SSH, follow the port forwarding instructions in the tutorial you choose.