{"id":17377401,"url":"https://github.com/pradel/stacks-graphql-api","last_synced_at":"2025-04-14T06:45:27.912Z","repository":{"id":43288443,"uuid":"434367502","full_name":"pradel/stacks-graphql-api","owner":"pradel","description":"A GraphQL API to query the Stacks blockchain.","archived":false,"fork":false,"pushed_at":"2022-03-09T23:31:23.000Z","size":10,"stargazers_count":12,"open_issues_count":3,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-27T20:23:19.115Z","etag":null,"topics":["stacks"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pradel.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-02T20:37:21.000Z","updated_at":"2023-05-02T01:00:53.000Z","dependencies_parsed_at":"2022-09-08T22:00:29.926Z","dependency_job_id":null,"html_url":"https://github.com/pradel/stacks-graphql-api","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pradel%2Fstacks-graphql-api","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pradel%2Fstacks-graphql-api/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pradel%2Fstacks-graphql-api/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pradel%2Fstacks-graphql-api/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pradel","download_url":"https://codeload.github.com/pradel/stacks-graphql-api/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248837269,"owners_count":21169373,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["stacks"],"created_at":"2024-10-16T05:05:57.265Z","updated_at":"2025-04-14T06:45:27.883Z","avatar_url":"https://github.com/pradel.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n\u003ch1\u003estacks-graphql-api\u003c/h1\u003e\n\u003cp\u003eA GraphQL API to query the Stacks blockchain.\u003c/p\u003e\n\n\u003c/div\u003e\n\n\u003e 🚧🚧🚧 Consider this repository as highly experimental 🚧🚧🚧\n\n## Features\n\n- Query the Stacks blockchain using a GraphQL API.\n- Create complex queries including relations, pagination, sorting, and filtering.\n- Realtime updates via GraphQL subscriptions.\n- Blazing fast, using [Hasura](https://github.com/hasura/graphql-engine).\n\n## Usage example\n\n### Queries\n\nGet the data of transaction `0x5cca607a5fa44855e2b56dd4fc41a53b871c1f75eecbf5e271c2d6439e32b745`:\n\n```graphql\n{\n  transactions_connection(\n    where: {\n      tx_id: {\n        _eq: \"\\\\x5cca607a5fa44855e2b56dd4fc41a53b871c1f75eecbf5e271c2d6439e32b745\"\n      }\n    }\n  ) {\n    edges {\n      node {\n        id\n        sender_address\n        fee_rate\n        nonce\n        contract_call_contract_id\n        contract_call_function_name\n        contract_call_function_args\n        contract_call {\n          source_code\n          tx_id\n        }\n        block {\n          block_hash\n          block_height\n          burn_block_time\n          burn_block_hash\n          burn_block_height\n        }\n        ft_events {\n          asset_event_type_id\n          asset_identifier\n          sender\n          recipient\n        }\n        nft_events {\n          asset_event_type_id\n          asset_identifier\n          sender\n          recipient\n        }\n      }\n    }\n  }\n}\n```\n\n### Subscriptions\n\nReceive an event when a new block is mined:\n\n```graphql\nsubscription {\n  blocks_connection(first: 1, order_by: {block_height: desc}) {\n    edges {\n      node {\n        block_height\n        block_hash\n        burn_block_time\n        burn_block_hash\n        burn_block_height\n        # Number of transactions included in the block\n        transactions_aggregate {\n          aggregate {\n            count\n          }\n        }\n      }\n    }\n  }\n```\n\n## Deploying with docker-compose\n\nThe `docker-compose.yml` file start a stacks-blockchain node, the stacks-blockchain-api which is seeding a Postgres database, and the Hasura GraphQL API.\n\nOn your server run:\n\n```sh\ndocker-compose up -d\n```\n\nThen to apply the metadata to the deployed Hasura instance, run:\n\n```sh\ncd stacks-graphql-api\nhasura metadata apply --endpoint https://my-endpoint --admin-secret \"super-secret\"\n```\n\nFinally to interact with the API, go to https://graphqlbin.com/v2/new (or any GraphiQL client) and use https://my-server-ip:8080/v1beta1/relay for the endpoint. On the right side, you will be able to browse the GraphQL schema docs.\n\n## Contributing\n\nDo you have an idea or want to contribute? Pull requests are very welcome!\n\n## Known limitations\n\n- No support for balances\n- Some tables are not tracked and exposed yet\n- No clean views to convert \"bytea\" to \"hex\" in the query response as well as the \"where\" arguments - Hasura does not support Materialized Views for relay yet https://github.com/hasura/graphql-engine/issues/5044\n\n## License\n\nMIT License © [Léo Pradel](https://www.leopradel.com/)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpradel%2Fstacks-graphql-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpradel%2Fstacks-graphql-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpradel%2Fstacks-graphql-api/lists"}