It is currently April 27th, 2024, 12:54 pm

How to use api for unmineable pool?

Get help with creating, editing & fixing problems with skins
User avatar
mtchannel
Posts: 24
Joined: October 21st, 2021, 11:08 pm

How to use api for unmineable pool?

Post by mtchannel »

Hello friends. I'm looking for a simple widget. My goal is to see the total amount accumulated in the pool I mine from. How can I achieve this? I examined the ready-made ones, but I could not succeed. I would be glad if you help.

pool website:
https://unmineable.com/support/article/do-you-have-an-api-for-developers

example;
Image
User avatar
balala
Rainmeter Sage
Posts: 16176
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to use api for unmineable pool?

Post by balala »

mtchannel wrote: March 5th, 2024, 4:10 pm I'm looking for a simple widget.
Unfortunately more or less, but this sounds as a not allowed skin request. However you could get help on creating the skin, assuming the information you want to acquire is on the linked site, which it's not the case in my opinion. So which is exactly the information you need on that site?

Additional info: In Rainmeter we're working with skins, not with widgets.
User avatar
Yincognito
Rainmeter Sage
Posts: 7175
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: How to use api for unmineable pool?

Post by Yincognito »

mtchannel wrote: March 5th, 2024, 4:10 pm Hello friends. I'm looking for a simple widget. My goal is to see the total amount accumulated in the pool I mine from. How can I achieve this? I examined the ready-made ones, but I could not succeed. I would be glad if you help.

pool website:
https://unmineable.com/support/article/do-you-have-an-api-for-developers

example;
Image
Generally, you'd use a WebParser measure, with its URL option set to the address you want to extract data from, its RegExp option set to a regular expression pattern to capture the desired data, and its StringIndex option set to the number of that capture. For example, for the GET /pool address of https://api.unminable.com/v4/pool and its Output example from the site you linked to, if you wanted to extract the value of the total_paid_btc field in that JSON, you'd write a skin along these lines:

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
BackgroundMode=2
SolidColor=47,47,47,255

---Measures---

[WebParser]
Measure=WebParser
URL=https://api.unminable.com/v4/pool
RegExp=(?siU)"total_paid_btc":(.*)[,}]
StringIndex=1
UpdateRate=600
RegExpSubstitute=1
Substitute="(?:^\s+|\s+$)":"",'(?:^"|"$)':""

---Meters---

[WebParserValue]
Meter=String
FontFace=Consolas
FontColor=255,255,255,255
Padding=5,5,5,5
FontSize=16
AntiAlias=1
MeasureName=WebParser
Text="WebParser Value:#CRLF##CRLF#%1"
DynamicVariables=1
The key things here are the two regex patterns. The one in RegExp extracts what's after "total_paid_btc": and up to the first , or } characters in the 1st capture (a capture is enclosed between round brackets). The one in the Substitute has two parts, separated by commas: the 1st part aka "(?:^\s+|\s+$)":"" removes the leading and trialing spaces from the result, and the 2nd part aka '(?:^"|"$)':"" removes the leading and trailing quotes from the result.

Feel free to adjust things to your needs. Check RegExR.com or regex101.com to test regular expressions and get to know what such symbols mean (Rainmeter uses the PCRE flavor of regex, by the way).
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
mtchannel
Posts: 24
Joined: October 21st, 2021, 11:08 pm

Re: How to use api for unmineable pool?

Post by mtchannel »

It was exactly what I wanted. With a little editing it turned out the way I wanted it to. Thank you.

Image
User avatar
mtchannel
Posts: 24
Joined: October 21st, 2021, 11:08 pm

Re: How to use api for unmineable pool?

Post by mtchannel »

Image
I want to set the API data in the image you see above to be one under the other. but it happens side by side. how can I do that. I'm an amateur user, sorry. You can see what I have done so far in the picture below. I added a frame.

01-) I want to put the API data one under the other
02-) I want the "lite coin" text to remain in the middle (it already is), but I want the API data to be at the top left. how can I do it.

Image

edit;

Code: Select all

---Measures---

[WebParser]
Measure=WebParser
URL=https://api.unminable.com/v4/address/LİTECOİNADDRESS?coin=LTC
RegExp=(?siU)"balance":(.*)"balance_payable":(.*)[,}]
UpdateRate=600
RegExpSubstitute=1


---Meters---

[WebParserValue]
Meter=String
FontFace=Consolas
FontColor=255
StringStyle=BOLD
StringEffect=SHADOW
FontEffectColor=0,0,0,50
Padding=80,15
FontSize=15
AntiAlias=1
MeasureName=WebParser
Text=">> LiTE COiN <<#CRLF#%1"
DynamicVariables=1
Last edited by balala on March 6th, 2024, 1:07 pm, edited 1 time in total.
Reason: Please use <code> tags whenever are you posting codes. It's the </> button.
User avatar
mtchannel
Posts: 24
Joined: October 21st, 2021, 11:08 pm

Re: How to use api for unmineable pool?

Post by mtchannel »

I tested something like this but it didn't react at all.

Code: Select all

[WebParser]
Measure=WebParser
URL1="https://api.unminable.com/v4/address/LTCADDRESS?coin=LTC"
URL2="https://api.unminable.com/v4/address/LTCADDRESS?coin=LTC"
UpdateRate=600
Substitute="(?:^\s+|\s+$)":"",'(?:^"|"$)':""
RegExp1="(?siU)"balance":(.*)[,}]"
RegExp1="(?siU)"payment_threshold":(.*)[,}]"
ForceReload=1

[balance]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=#URL1#
RegExp=#RegExp1#

[payment]
Measure=Plugin
Plugin=Plugins\WebParser.dll
Url=#URL2#
RegExp=#RegExp2#
Last edited by balala on March 6th, 2024, 1:08 pm, edited 1 time in total.
Reason: Please use <code> tags whenever are you posting codes. It's the </> button.
User avatar
balala
Rainmeter Sage
Posts: 16176
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to use api for unmineable pool?

Post by balala »

mtchannel wrote: March 6th, 2024, 9:01 am I want to set the API data in the image you see above to be one under the other. but it happens side by side. how can I do that. I'm an amateur user, sorry. You can see what I have done so far in the picture below. I added a frame.
I can't get the above [WebParser] measure working, It seems the used URL (https://api.unminable.com/v4/address/LİTECOİNADDRESS?coin=LTC) is not accessible. Sorry, but a working code would be helpful.
mtchannel wrote: March 6th, 2024, 10:52 am I tested something like this but it didn't react at all.
There is no URL1 option, nor a RegExp1. They should be URL and RegExp, accordingly. With URL1 and RegExp1, the measure can't work (and nor its child measures). Using URL1 and RegExp1, you get no error messages in the log, just simply can't get the skin working.
User avatar
mtchannel
Posts: 24
Joined: October 21st, 2021, 11:08 pm

Re: How to use api for unmineable pool?

Post by mtchannel »

Unfortunately, I cannot share my wallet address. That's why I wrote "LITECOİNADDRESS" there. Sir, you cannot access it because I did not write my wallet address. However, if I type my wallet address, you will be greeted with something like the following.

Image

specified in the api;
"balance":"0.06163807","balance_payable":"0.06163807","precision":"8","payment_threshold":"0.00075","mining_fee":"0.75"

How can I arrange these one below the other, sir?
Can you give me an example code, please?
User avatar
Yincognito
Rainmeter Sage
Posts: 7175
Joined: February 27th, 2015, 2:38 pm
Location: Terra Yincognita

Re: How to use api for unmineable pool?

Post by Yincognito »

mtchannel wrote: March 6th, 2024, 9:01 am Image
I want to set the API data in the image you see above to be one under the other. but it happens side by side. how can I do that. I'm an amateur user, sorry. You can see what I have done so far in the picture below. I added a frame.

01-) I want to put the API data one under the other
02-) I want the "lite coin" text to remain in the middle (it already is), but I want the API data to be at the top left. how can I do it.

Image

edit;

Code: Select all

---Measures---

[WebParser]
Measure=WebParser
URL=https://api.unminable.com/v4/address/LİTECOİNADDRESS?coin=LTC
RegExp=(?siU)"balance":(.*)"balance_payable":(.*)[,}]
UpdateRate=600
RegExpSubstitute=1


---Meters---

[WebParserValue]
Meter=String
FontFace=Consolas
FontColor=255
StringStyle=BOLD
StringEffect=SHADOW
FontEffectColor=0,0,0,50
Padding=80,15
FontSize=15
AntiAlias=1
MeasureName=WebParser
Text=">> LiTE COiN <<#CRLF#%1"
DynamicVariables=1
Yeah, we're all amateurs here, so no worries. You need to understand that the data in the skin (usually represented by measures and / or variables) is independent of the visual elements in the skin (called meters) and their positioning. So, to make it work the way you want, you'll need something like (feel free to adjust, this is untested):

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1
BackgroundMode=2
SolidColor=47,47,47,255

---Measures---

[Unminable]
Measure=WebParser
URL=https://api.unminable.com/v4/address/LİTECOİNADDRESS?coin=LTC
RegExp=(?siU)"balance":(.*)[,}].*"balance_payable":(.*)[,}].*"precision":(.*)[,}].*"payment_threshold":(.*)[,}].*"mining_fee":(.*)[,}].*
UpdateRate=600

[Balance]
Measure=WebParser
URL=[Unminable]
StringIndex=1

[Payable]
Measure=WebParser
URL=[Unminable]
StringIndex=2

...add the rest here...

---Meters---

[BalanceText]
Meter=String
X=80
Y=15
FontFace=Consolas
FontColor=255,255,255,255
StringStyle=BOLD
StringEffect=SHADOW
FontEffectColor=0,0,0,50
FontSize=15
AntiAlias=1
MeasureName=Balance
Text=Balance: %1
DynamicVariables=1

[PayableText]
Meter=String
X=80
Y=35
FontFace=Consolas
FontColor=255,255,255,255
StringStyle=BOLD
StringEffect=SHADOW
FontEffectColor=0,0,0,50
FontSize=15
AntiAlias=1
MeasureName=Payable
Text=Payable: %1
DynamicVariables=1

...add the rest here...

Adding the rest is a matter of copy pasting the previous with a corresponding name and StringIndex in the case of the WebParser child measures, and with a corresponding name, Y, MeasureName and Text in the case of the associated meters. Obviously, the name of the measures and / or meters can be different, as long as they are referred to accordingly in the options.

EDIT: Forgot to mention, to remove leading spaces and quotes, the earlier regex substitute should be added to each of the WebParser child measures, e.g.:

Code: Select all

[Balance]
Measure=WebParser
URL=[Unminable]
StringIndex=1
RegExpSubstitute=1
Substitute="(?:^\s+|\s+$)":"",'(?:^"|"$)':""
and so on.
Profiles: Rainmeter ProfileDeviantArt ProfileSuites: MYiniMeterSkins: Earth
User avatar
balala
Rainmeter Sage
Posts: 16176
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

Re: How to use api for unmineable pool?

Post by balala »

mtchannel wrote: March 6th, 2024, 1:57 pm However, if I type my wallet address, you will be greeted with something like the following.
Ok, understand. Maybe in meantime Yincognito fixed the issue (did he?), so I have only one thing to say above this. It's practically almost completely useless to post images / screenshots of codes, no mater if those are screenshots of code of the skin, screenshots of code of a site you'd like to parse or whatever else. Instead you should have to copy the relevant part of the code and paste it as editable text. This way we can at least copy and save it as a text file, to can use this file when working with it. We can't work this way with a screenshot.