kopia lustrzana https://github.com/bugout-dev/moonstream
[WIP] Adding /nft endpoint to the API
rodzic
e112c6edde
commit
d4d1f8b6e0
|
@ -8,12 +8,12 @@ from fastapi import FastAPI
|
||||||
from fastapi.middleware.cors import CORSMiddleware
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
|
|
||||||
from . import data
|
from . import data
|
||||||
from .routes.subscriptions import app as subscriptions_api
|
|
||||||
from .routes.users import app as users_api
|
|
||||||
from .routes.txinfo import app as txinfo_api
|
|
||||||
from .routes.streams import app as streams_api
|
|
||||||
from .routes.address_info import app as addressinfo_api
|
from .routes.address_info import app as addressinfo_api
|
||||||
|
from .routes.nft import app as nft_api
|
||||||
|
from .routes.subscriptions import app as subscriptions_api
|
||||||
|
from .routes.streams import app as streams_api
|
||||||
|
from .routes.txinfo import app as txinfo_api
|
||||||
|
from .routes.users import app as users_api
|
||||||
from .settings import ORIGINS
|
from .settings import ORIGINS
|
||||||
from .version import MOONSTREAM_VERSION
|
from .version import MOONSTREAM_VERSION
|
||||||
|
|
||||||
|
@ -51,3 +51,4 @@ app.mount("/users", users_api)
|
||||||
app.mount("/streams", streams_api)
|
app.mount("/streams", streams_api)
|
||||||
app.mount("/txinfo", txinfo_api)
|
app.mount("/txinfo", txinfo_api)
|
||||||
app.mount("/address_info", addressinfo_api)
|
app.mount("/address_info", addressinfo_api)
|
||||||
|
app.mount("/nft", nft_api)
|
||||||
|
|
|
@ -350,3 +350,21 @@ ethereum_txpool_provider = EthereumTXPoolProvider(
|
||||||
estimated_events_per_time_interval=50,
|
estimated_events_per_time_interval=50,
|
||||||
tags=["client:ethereum-txpool-crawler-0"],
|
tags=["client:ethereum-txpool-crawler-0"],
|
||||||
)
|
)
|
||||||
|
|
||||||
|
nft_summary_description = """Event provider for NFT market summaries.
|
||||||
|
|
||||||
|
This provider periodically generates NFT market summaries for the last hour of market activity.
|
||||||
|
|
||||||
|
Currently, it summarizes the activities on the following NFT markets:
|
||||||
|
1. The Ethereum market
|
||||||
|
|
||||||
|
This provider is currently not accessible for subscription. The data from this provider is publicly
|
||||||
|
available at the /nft endpoint."""
|
||||||
|
nft_summary_provider = BugoutEventProvider(
|
||||||
|
event_type="nft_summary",
|
||||||
|
description=nft_summary_description,
|
||||||
|
# 40 blocks per summary, 15 seconds per block + 2 seconds wiggle room.
|
||||||
|
default_time_interval_seconds=40 * 17,
|
||||||
|
estimated_events_per_time_interval=1,
|
||||||
|
tags=["crawl_type:nft_ethereum"],
|
||||||
|
)
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
"""
|
||||||
|
Moonstream's /nft endpoints.
|
||||||
|
|
||||||
|
These endpoints provide public access to NFT market summaries. No authentication required.
|
||||||
|
"""
|
||||||
|
import logging
|
||||||
|
from typing import Optional
|
||||||
|
|
||||||
|
from fastapi import FastAPI, Query
|
||||||
|
from fastapi.middleware.cors import CORSMiddleware
|
||||||
|
|
||||||
|
from . import data
|
||||||
|
from ..settings import DOCS_TARGET_PATH, ORIGINS
|
||||||
|
from ..version import MOONSTREAM_VERSION
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
tags_metadata = [
|
||||||
|
{"name": "nft", "description": "NFT market summaries"},
|
||||||
|
]
|
||||||
|
|
||||||
|
app = FastAPI(
|
||||||
|
title=f"Moonstream /nft API",
|
||||||
|
description="User, token and password handlers.",
|
||||||
|
version=MOONSTREAM_VERSION,
|
||||||
|
openapi_tags=tags_metadata,
|
||||||
|
openapi_url="/openapi.json",
|
||||||
|
docs_url=None,
|
||||||
|
redoc_url=f"/{DOCS_TARGET_PATH}",
|
||||||
|
)
|
||||||
|
|
||||||
|
app.add_middleware(
|
||||||
|
CORSMiddleware,
|
||||||
|
allow_origins=ORIGINS,
|
||||||
|
allow_credentials=True,
|
||||||
|
allow_methods=["*"],
|
||||||
|
allow_headers=["*"],
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/", tags=["streams"], response_model=data.GetEventsResponse)
|
||||||
|
async def stream_handler(
|
||||||
|
start_time: int = Query(0),
|
||||||
|
end_time: Optional[int] = Query(None),
|
||||||
|
include_start: bool = Query(False),
|
||||||
|
include_end: bool = Query(False),
|
||||||
|
) -> data.GetEventsResponse:
|
||||||
|
pass
|
|
@ -28,7 +28,7 @@ tags_metadata = [
|
||||||
]
|
]
|
||||||
|
|
||||||
app = FastAPI(
|
app = FastAPI(
|
||||||
title=f"Moonstream users API.",
|
title=f"Moonstream /txinfo API.",
|
||||||
description="User, token and password handlers.",
|
description="User, token and password handlers.",
|
||||||
version=MOONSTREAM_VERSION,
|
version=MOONSTREAM_VERSION,
|
||||||
openapi_tags=tags_metadata,
|
openapi_tags=tags_metadata,
|
||||||
|
|
Ładowanie…
Reference in New Issue