aptos-labs / aptos-indexer-processors

Set of core processors that index data on the Aptos blockchain
https://aptos.dev/indexer/indexer-landing
55 stars 65 forks source link

[Indexer API] Self hosted indexer api #201

Open DaraDoyoung opened 10 months ago

DaraDoyoung commented 10 months ago

Description

Is there any updates on self hosted indexer api? https://aptos.dev/indexer/api/self-hosted

I'm running processors which are saving data to Postgres DB, and I would like to open an endpoint to this. It seems no guide on this is provided yet.

larry-aptos commented 6 months ago

you can use hasura self-hosted solution(hasura docker image) and https://github.com/aptos-labs/aptos-indexer-processors/tree/main/hasura-api/metadata-json this file as the metadata to use.

olivbau commented 5 months ago

I'm trying to import the unified.json file to Hasura. For people struggling, don't forget to add INDEXER_V2_POSTGRES_URL env var to your docker compose file

Something like this:

  graphqlengine:
    image: hasura/graphql-engine:latest
    ports:
      - 8080:8080
    restart: always
    environment:
      HASURA_GRAPHQL_METADATA_DATABASE_URL: postgres://postgres_user:postgres_password@dbhasura:5432/hasura
      HASURA_GRAPHQL_ENABLE_CONSOLE: "true"
      HASURA_GRAPHQL_ADMIN_SECRET: myadminsecretkey
      HASURA_GRAPHQL_DEV_MODE: "false"
      INDEXER_V2_POSTGRES_URL: postgres://postgres_user:postgres_password@localhost:5432/indexer
olivbau commented 5 months ago

While import unified.json file I have an error:

[
    {
        "definition": {
            "name": "current_nft_marketplace_listings",
            "schema": "nft_marketplace_v2"
        },
        "name": "table nft_marketplace_v2.current_nft_marketplace_listings in source indexer-v2",
        "reason": "Inconsistent object: no such table/view exists in source: \"nft_marketplace_v2.current_nft_marketplace_listings\"",
        "type": "table"
    },
    {
        "definition": {
            "name": "current_nft_marketplace_collection_offers",
            "schema": "nft_marketplace_v2"
        },
        "name": "table nft_marketplace_v2.current_nft_marketplace_collection_offers in source indexer-v2",
        "reason": "Inconsistent object: no such table/view exists in source: \"nft_marketplace_v2.current_nft_marketplace_collection_offers\"",
        "type": "table"
    },
    {
        "definition": {
            "name": "current_nft_marketplace_auctions",
            "schema": "nft_marketplace_v2"
        },
        "name": "table nft_marketplace_v2.current_nft_marketplace_auctions in source indexer-v2",
        "reason": "Inconsistent object: no such table/view exists in source: \"nft_marketplace_v2.current_nft_marketplace_auctions\"",
        "type": "table"
    },
    {
        "definition": {
            "name": "current_nft_marketplace_token_offers",
            "schema": "nft_marketplace_v2"
        },
        "name": "table nft_marketplace_v2.current_nft_marketplace_token_offers in source indexer-v2",
        "reason": "Inconsistent object: no such table/view exists in source: \"nft_marketplace_v2.current_nft_marketplace_token_offers\"",
        "type": "table"
    },
    {
        "definition": {
            "name": "nft_marketplace_activities",
            "schema": "nft_marketplace_v2"
        },
        "name": "table nft_marketplace_v2.nft_marketplace_activities in source indexer-v2",
        "reason": "Inconsistent object: no such table/view exists in source: \"nft_marketplace_v2.nft_marketplace_activities\"",
        "type": "table"
    }
]

image

olivbau commented 5 months ago

I did manage to import the file by removing some parts of it Modified version of the unified.json file I used: modified_unified.json

banool commented 5 months ago

@olivbau thanks for reporting this. Some of the tables are missing in the DB because they come from a different processor outside of the normal Rust stack.

cc @yuunlimm we should consider publishing a copy of the metadata with the changes that @olivbau made. This would be helpful for the local testnet too since I actually manually edit the metadata in exactly the same way myself every single time I update the metadata that it uses.