Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Tip

If you are new to Search GAIA API and want to add an endpoint we recommend you start with How to Add and API Endpoint

The API framework is entirely based on FastAPI, and it simplifies just where and how you can add new endpoints to Search GAIA API. Besides that everything is FastAPI, but using a router instead of the application directly since using routers give us the following advantages:

  1. Modular code organization: Routers help organize code into separate modules, making it easier to manage and maintain larger API codebases.

  2. Route prefixing: Routers allow you to group related routes together using a common prefix, providing a clean and intuitive structure for API endpoints.

  3. Dependency injection: Routers support dependency injection, allowing you to declare and reuse dependencies at the router level.

  4. Sub-applications: Routers enable the creation of sub-applications within the main FastAPI app, facilitating the development and maintenance of complex APIs.

  5. Route inheritance and overrides: Routers support route inheritance, allowing you to define common behavior and middleware at the router level, with the ability to override specific routes when needed.

As you can see each router, in Search GAIA API is an endpoint, and within that endpoint you can do whatever you want.

Tip
titleRead about Routers

If you want to know more about routers and the guidelines we used for Search GAIA API visit the FastAPI documentation about Bigger Applications - Multiple Files

Info
titleSecurity covers all endpoints

If security is enabled, by default all endpoints are cover by it, if by any change 

Routes With App


Code Block
languagepy
themeDJango
from fastapi import FastAPI

app = FastAPI()

@app.get("/")
def read_root():
    return {"message": "Hello, World!"}

@app.get("/items/{item_id}")
def read_item(item_id: int, q: str = None):
    return {"item_id": item_id, "q": q}

Routes With Router


Code Block
languagepy
themeDJango
from fastapi import APIRouter

router = APIRouter()

@router.get("/")
def read_root():
    return {"message": "Hello, World!"}

@router.get("/items/{item_id}")
def read_item(item_id: int, q: str = None):
    return {"item_id": item_id, "q": q}

Same in both examples but in the end, the router must be included in the app

Code Block
languagepy
themeDJango
from fastapi import FastAPI
from myrouter import router

app = FastAPI()

app.include_router(router)
Info
titleMade simple

Search GAIA API already does this for you, only the implementation of the routes in the router is required 


Endpoints Available
Create from template
templateName822312961
templateId822312961
createButtonLabelAdd how-to article
buttonLabelAdd endpoint


Info

Interactive documentation can be found in API Documentation


Content Report Table
blueprintModuleCompleteKeycom.atlassian.confluence.plugins.confluence-knowledge-base:kb-how-to-article-blueprint
contentBlueprintId06c83029-c8cf-417c-8602-1b4707c30061
analyticsKeykb-how-to-article
blankDescriptionProvide step-by-step guidance for completing a task.
blankTitleHow-to article
spacesSEARCHAPI
createButtonLabelAdd how-to article
labelsendpoint