If you are new to Search 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 API. Besides that everything is FastAPI, but using a router instead of the application directly since using routers give us the following advantages:
Modular code organization: Routers help organize code into separate modules, making it easier to manage and maintain larger API codebases.
Route prefixing: Routers allow you to group related routes together using a common prefix, providing a clean and intuitive structure for API endpoints.
Dependency injection: Routers support dependency injection, allowing you to declare and reuse dependencies at the router level.
Sub-applications: Routers enable the creation of sub-applications within the main FastAPI app, facilitating the development and maintenance of complex APIs.
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 API is an endpoint, and within that endpoint you can do whatever you want.
Read about Routers
If you want to know more about routers and the guidelines we used for Search API visit the FastAPI documentation about Bigger Applications - Multiple Files
Security covers all endpoints
If security is enabled, by default all endpoints are cover by it, if by any change
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}
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
from fastapi import FastAPI from myrouter import router app = FastAPI() app.include_router(router)
Made simple
Search API already does this for you, only the implementation of the routes in the router is required
Title | Creator | Modified |
---|---|---|
Mailer Endpoint | Potter (Esteban Alvarado) | May 30, 2024 |
How to Add and API Endpoint | Potter (Esteban Alvarado) | Apr 03, 2024 |
Stats Endpoint | Steven Peraza | Mar 31, 2024 |
Shutdown Endpoint | Steven Peraza | Mar 19, 2024 |
Import/Export Endpoint | Steven Peraza | Mar 19, 2024 |
Search Endpoint | Potter (Esteban Alvarado) | Jan 26, 2024 |
TypeAhead Endpoint | Potter (Esteban Alvarado) | Jan 02, 2024 |
Documentation Endpoint | Potter (Esteban Alvarado) | Jan 02, 2024 |
Core Endpoint | Potter (Esteban Alvarado) | Jan 02, 2024 |
API Keys Endpoint | Potter (Esteban Alvarado) | Jan 02, 2024 |
Pipeline Endpoint | Potter (Esteban Alvarado) | Jul 19, 2023 |
Feedback Endpoint | Potter (Esteban Alvarado) | Jul 19, 2023 |