Hello everyone!
I want to introduce Fitter for you.
Fitter + Fitter CLI
Fitter - new way for collect information from the API's/Websites
Fitter CLI - small cli command which provide result from Fitter for test/debug/home usage
Fitter Lib - library which provide functional of fitter CLI as a library
Way to collect information
- Server - parsing response from some API's or http request(usage of http.Client)
- Browser - emulate real browser using chromium + docker + playwright/cypress and get DOM information
- Static - parsing static string as data
Format which can be parsed
- JSON - parsing JSON to get specific information
- XML - parsing xml tree to get specific information
- HTML - parsing dom tree to get specific information
- XPath - parsing dom tree to get specific information but by xpath
Use like a library
go get github.com/PxyUp/fitter
package main
import (
"fmt"
"github.com/PxyUp/fitter/lib"
"github.com/PxyUp/fitter/pkg/config"
"log"
"net/http"
)
func main() {
res, err := lib.Parse
…This tool can do a lot of stuff:
- Read content by XML/XPath/Json/HTML selectors
- Emulate browser with docker/playwright/chromium
- Support proxy
- Global references
- Fallback on no empty fields
- Notification Telegram/Http/Redis/Console
- File downloading
- Full README.md
- Can work as golang library
- Support runtime golang plugins
- Work as CLI
- Works on Linux/Mac/Windows.
- Support different type of fields
- Support expression language for field and notification settings
......
N+1. Best and most important it is gluing of request
Repository have a multiple examples for CLI/Fitter
Real world example of the problem
Last week my friend need to monitor pool on some crypto stock. So here his problem:
- First of all you need get all user positions https://docs.saucerswap.finance/v/developer/saucerswap-v2/liquidity-operations/get-user-positions
- After that all stock pool https://docs.saucerswap.finance/v/developer/saucerswap-v2/liquidity-operations/fetch-all-pools
- After that you should check if pool has user positions you should send notification.
Let's see how Fitter can solve this problem:
Let me explain what is here:
- environment variables:
TELEGRAM_TOKEN - line 95
USER_ID - line 37
So my friend need just run Fitter and add UserIds for Telegram notification(line 95):
TELEGRAM_TOKEN=xxx USER_ID=xxx ./fitter --path=./config.json
- What happens in config:
2.1 Creating Reference(line 3) on all pools and caching on 60 seconds(line 4). We take the response and create an array of the objects with two fields tokenA and tokenB.
2.2 Creating Reference(line 33) on AccountId will be just string from ENV.
2.3 We create items for monitoring every 10 seconds(line 88) which take values from the server via injecting AccountIdRef(line 52). Response it is array of objects with two field: first it is (line 66) - template string with injecting token name; second is boolean field which show if pair in pool(line 71)
- Next we will inform if some of the values in array is true(line 93).
We will receive notification in Telegram:
[
{
"position": "tokenA=USDC tokenB=USDC[hts]",
"value": true
},
{
"value": false,
"position": "tokenA=USDC tokenB=USDT"
}
]
Top comments (0)