Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mohitrajput2002/my_etherscan_graphql
https://github.com/mohitrajput2002/my_etherscan_graphql
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/mohitrajput2002/my_etherscan_graphql
- Owner: mohitrajput2002
- Created: 2023-11-21T19:59:05.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-11-21T20:09:08.000Z (about 1 year ago)
- Last Synced: 2023-11-21T21:27:33.896Z (about 1 year ago)
- Language: JavaScript
- Size: 38.1 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# GraphQL With Etherscan APIs
## Getting Started
To get started using the GraphQL Etherscan API, follow these steps:
1. Clone this repository
2. Run `npm install` to install dependencies
3. Create an Etherscan API key (explained below)
4. Start the Apollo server (explained below)
5. Make GraphQL queries against the server (example below)## Benefits of using GraphQL API
Wrapping the Etherscan REST APIs in a GraphQL API provides the following benefits:
- Query multiple related resources in a single API call
- Strong typing system
- Intuitive query language
- Built-in documentation## Create an Etherscan API Key
To use the Etherscan APIs, you'll need an API key. Follow these steps:
1. Sign up for an Etherscan account at https://etherscan.io/register
2. Go to https://etherscan.io/myapikey to generate an API key
3. Add the API key to a `.env` file as `ETHERSCAN_API=your_api_key`## Overview of GraphQL Etherscan API endpoints
The GraphQL API wraps the following Etherscan REST endpoints:
- `etherBalanceByAddress` - Get ETH balance for an address
- `totalSupplyOfEther` - Get total ETH supply
- `latestEthereumPrice` - Get latest ETH price
- `blockConfirmationTime` - Get estimated block confirmation timeSee the `schema.graphql` file for details.
## How to run Apollo Server
Starting the Apollo GraphQL Server:
1. Open your terminal on VSCode
2. Run the following command to start the server: `node index.js`
3. Upon successful startup, you should see this message: 🚀 Server ready at http://localhost:9000/
4. Access the Apollo Server by navigating to http://localhost:9000 on your browser## Sample GraphQL Query
Below is a sample GraphQL query to fetch the necessary data from Etherscan
```graphql
query {
etherBalanceByAddress {
message
result
}
totalSupplyOfEther {
message
result
}
latestEthereumPrice {
message
result {
ethbtc
ethusd
ethusd_timestamp
}
}
blockConfirmationTime {
message
result
}
}
```