Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document Ethereum API GET Request #12

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 17 additions & 100 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,95 +1,3 @@
# WalletLabels

WalletLabels is a powerful and user-friendly web app that simplifies searching and identifying Ethereum wallets with custom labels. The application provides an intuitive interface, allowing users to search for wallet addresses by name, label or address. Visit the live website at [https://walletlabels.xyz](https://walletlabels.xyz).

**Note**: This project provides the frontend and backend (API handling) for WalletLabels but does not include the database containing wallet addresses and labels. Users will need to set up their own database when deploying a local version of this project.

## Table of Contents

1. [Features](#features)
2. [Folder Structure](#folder-structure)
3. [Prerequisites](#prerequisites)
4. [Getting Started](#getting-started)
5. [API](#api)
6. [Deployment](#deployment)
7. [Contributing](#contributing)
8. [License](#license)
9. [Support](#support)

## Features

- Search for wallet addresses by name, label type, or label subtype
- Displays wallet balance history in a graph
- Retrieves the last transaction for each address
- Responsive design for mobile and desktop devices
- Dark and light theme support

## Folder Structure

Below is an overview of the important files and folders in the WalletLabels project:

- `components/`: Contains reusable UI components and layout related components.
- `hooks/`: Contains custom React hooks used in the project.
- `lib/`: Contains utility functions and database related logic.
- `pages/`: Contains the main pages of the application and their corresponding API endpoints.
- `public/`: Contains public assets such as images and icons.
- `styles/`: Contains global and module-specific stylesheets.
- `tsconfig.json`: TypeScript configuration file.
- `next.config.mjs`: Next.js configuration file.
- `package.json`: Contains project dependencies and scripts.

## Prerequisites

To run WalletLabels locally, you need to have the following installed on your system:

- Node.js (v14 or later)
- npm (v6 or later)
- MongoDB

Additionally, you need to set up some environment variables:

- `MONGODB_URI`: The MongoDB connection URI
- `DB_NAME`: The name of your MongoDB database
- `COVALENT_API`: The Covalent API key to load the graph for balance history
- `NEXT_PUBLIC_COVALENT2_API`: The Covalent API key to fetch the last transaction for each address

## Getting Started

1. Clone the repository

```bash
git clone https://github.com/your-username/walletlabels.git
```

2. Change the current directory to the project folder

```bash
cd walletlabels
```

3. Install the required dependencies

```bash
npm install
```

4. Create a `.env.local` file in the project root and add your environment variables:

```
MONGODB_URI=your-mongodb-uri
DB_NAME=your-db-name
COVALENT_API=your-covalent-api-key
NEXT_PUBLIC_COVALENT2_API=your-covalent2-api-key
```

5. Start the development server

```bash
npm run dev
```

6. Open your browser, and navigate to [http://localhost:3000](http://localhost:3000)

## API

WalletLabels provides a single API endpoint to fetch labeled Ethereum wallet addresses based on a search query.
Expand All @@ -113,18 +21,27 @@ GET /api/query?query=exchange&limit=10

This request will return up to 10 wallet addresses containing the word "exchange" in their name, label type, or label subtype.

## Deployment
### Introduction

The Ethereum API GET request allows users to retrieve information about Ethereum wallet addresses with specific labels. This functionality is crucial for identifying and categorizing wallets based on their associated names, label types, or subtypes.

To deploy WalletLabels, you can use any platform that supports Next.js applications, like [Vercel](https://vercel.com) or [Netlify](https://netlify.com). Make sure to set your environment variables in your deployment platform.
### Usage Guide with Code Examples

## Contributing
To make a GET request to the WalletLabels API, you can use the following JavaScript code example:

```javascript
fetch('/api/query?query=exchange&limit=10')
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
```

If you would like to contribute to the project, please fork the repository, create a new branch, and submit a pull request with your changes.
This code fetches up to 10 wallet addresses containing the word "exchange".

## License
### Response Handling

WalletLabels is released under the MIT License. See the LICENSE file for more details.
The response from the API is a JSON object containing an array of wallet addresses and their labels. You should parse this data to extract and utilize the information relevant to your application.

## Support
### Error Handling

If you have any questions or issues, please open an issue on the GitHub repository or contact one of the maintainers.
When making the GET request, various errors can occur, such as network issues or invalid parameters. It's important to handle these errors gracefully in your code, typically by catching exceptions and providing informative error messages to the user.