https://github.com/bandprotocol/pds-gateway
https://github.com/bandprotocol/pds-gateway
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/bandprotocol/pds-gateway
- Owner: bandprotocol
- License: apache-2.0
- Created: 2022-03-21T12:13:47.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2024-03-08T07:00:09.000Z (over 2 years ago)
- Last Synced: 2024-04-13T19:00:28.530Z (about 2 years ago)
- Language: Python
- Size: 322 KB
- Stars: 2
- Watchers: 6
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Premium Data Sources Gateway
The gateway for data sources on BandChain that require an API key for access. However, to prevent exposing the key on the chain, our solution allows secure access to the API without revealing the key. Only validators assigned to retrieve data for BandChain requests have the capability to obtain price data from these data sources.
## Requirements
### Environment Variables
Utilize the `.env` file by running:
```bash
cp .env.example .env
```
Ensure to update the environment variables for the Gateway and your chosen adapter.
## Running the Application
> Note: You have the option to set the environment variable `MODE=development` to facilitate testing your API locally. This allows you to make requests without the necessity of verifying that the requests originate from validators assigned to retrieve data for BandChain.
### Docker Compose
To run the application using Docker Compose:
```bash
docker-compose up
```
## Testing
Execute tests with:
```bash
pytest
```
## Supported Adapters
### StandardCryptoPrice
This adapter type retrieves the current price of each cryptocurrency symbol. Below are the specifications for the request, response, adapter input, and adapter output.
#### [GET] Request
Parameters:
- `symbols`: str (e.g., "BAND,ALPHA")
#### Response
```python
prices: []{symbol: str, price: float, timestamp: integer}
```
Example:
```python
[{symbol: "BAND", price: 99999, timestamp: 161111111111}, {symbol: "ALPHA", price: 99999, timestamp: 161111111111}]
```
#### Set Environment Valuables
- CoinMarketCap:
- `ADAPTER_TYPE = "standard_crypto_price"`
- `ADAPTER_NAME = "coin_market_cap"`
- `API_KEY = `
- CryptoCompare:
- `ADAPTER_TYPE = "standard_crypto_price"`
- `ADAPTER_NAME = "crypto_compare"`
- `API_KEY = `
- CoinGecko:
- `ADAPTER_TYPE = "standard_crypto_price"`
- `ADAPTER_NAME = "coin_gecko"`
- `API_KEY = `
## VerifiableAI
This VerifiableAI adapter type is used to request the AI API.
### OpenAI
#### [POST] Request
Body:
```json
{
"model": "gpt-3.5-turbo",
"messages": [
{ "role": "user", "content": "What is the best French cheese?" }
],
"temperature": 0.7,
"top_p": 1,
"max_tokens": 25,
"stream": false,
"seed": 1
}
```
#### Response
```json
{
"answer": "It is subjective and depends on personal preference, but some popular French cheeses include Brie, Camembert, Roquefort"
}
```
#### Set Environment Valuables
- `ADAPTER_TYPE = "verifiable_ai"`
- `ADAPTER_NAME = "openai"`
- `API_KEY = `
### Mistral
#### [POST] Request
Body:
```json
{
"model": "mistral-tiny",
"messages": [
{ "role": "user", "content": "What is the best French cheese?" }
],
"temperature": 0.7,
"top_p": 1,
"max_tokens": 16,
"stream": false,
"safe_prompt": false,
"random_seed": 1
}
```
#### Response
```json
{
"answer": "It is subjective and depends on personal preference, but some popular French cheeses include B"
}
```
#### Set Environment Valuables
- `ADAPTER_TYPE = "verifiable_ai"`
- `ADAPTER_NAME = "mistral"`
- `API_KEY = `