This project is an API in Go that allows users to query and filter data from the Etherscan API. The API retrieves ERC20 token transfer data by address and stores it in-memory for efficient filtering and retrieval.
- Go 1.16 or higher
- Gorilla Mux package
- Etherscan API key, get yours
- Clone the repository:
git clone https://github.com/Supsource/Etherscan-API-Wrapper
- Install dependencies:
go mod download
- Set your Etherscan API key as an environment variable:
export ETHERSCAN_API_KEY=your-api-key
To start the API server, run the following command in your terminal:
go run main.go
This will start the server on localhost:8001
. You can now send requests to the API.
GET /transactions
: Returns all transactions stored in the in-memory dataset.GET /transactions?limit=10&offset=20
: Returns up to 10 transactions starting from the 20th transaction in the dataset.GET /transactions?from=0x123&to=0x456
: Returns all transactions where the from address matches0x123
and the to address matches0x456
.GET /transactions?value=1000000000000000000
: Returns all transactions where the value is greater than or equal to 1 ether.
The API returns JSON-formatted data in the following format:
{
"status": "success",
"data": [
{
"hash": "0x123...",
"blockNumber": "123456",
"timeStamp": "1620164051",
"from": "0xabc...",
"to": "0xdef...",
"value": "1000000000000000000"
},
{
"hash": "0x456...",
"blockNumber": "123457",
"timeStamp": "1620164052",
"from": "0xghi...",
"to": "0xjkl...",
"value": "2000000000000000000"
}
]
}
If the API encounters an error, it will return an error response in the following format:
{
"status": "error",
"message": "Error message goes here"
}
If you find a bug or have a feature request, please open an issue on the GitHub repository. Pull requests are also welcome!