I have a very interesting request from you. I did a lot of research to solve it myself so as not to ask you, but I couldn't even come close to what I was looking for.
Now the reason for such a search is the stock market etc. Companies have limited free APIs. I thought of something different.
Let me first explain what I want to do.
First of all, I want to convert the "dollar" currency in the circle in the picture below to the "try" currency. Not all coins on the list are available on a single exchange. I found an exchange that has all of these but there is an API limitation. The fee is too high. I thought something like this. I want it to detect the "dollar $" currency you see for the circle in the picture and display it as the "try" currency opposite it. However, I want to do this without using the API. In short, prices are already taken from the stock exchange and displayed. I want to convert the received dollar$ prices to "try" currency without using the API again. If it can be done, my API problem will disappear.
dolar to try converter
https://www.google.com/search?client=opera&q=dolar+kaç+tl&sourceid=opera&ie=UTF-8&oe=UTF-8
Dollar $ detects the currency and then etc. in the dollar to try link I left above. I want to convert currencies from the site to each other and print the result.
What I want may seem very complicated. I hope I was able to explain what I want. If there is something you do not understand, you can ask.
It is currently April 28th, 2024, 3:08 am
How to use api for unmineable pool?
-
- Posts: 24
- Joined: October 21st, 2021, 11:08 pm
-
- Rainmeter Sage
- Posts: 7178
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: How to use api for unmineable pool?
In terms of detecting the currency symbols in strings or doing the math, this is possible. However, you'd still need to know all the exchange rates between currencies, and unless you have a professional / international banker as a friend or you find a site providing all these for free, you'd still have to go online and check them out. Only around 50 currencies have a fixed exchange rate to some other currency, so for the rest you'll need to find either a single or multiple web source(s) providing the rates - even if those rates are based on a single major currency (like the dollar), it would be enough, since you could do the rest of the basic math needed to convert between any of them. Googling for "all currencies" does provide complete lists and limited conversion possibilities, but for more I guess you'll need to search further. Alternatively to grabbing such data from a single source / API, I guess you could just write 150+ WebParser measures querying different sources (presumably free), each for some specific currency, at the same time, then aggregate everything in the skin. Obviously, if you're only interested in the major currencies, I think you can find free sources / APIs - see for example Mordasius' financial skin here, which uses cnbc.com as a source:mtchannel wrote: ↑March 17th, 2024, 11:41 pm I have a very interesting request from you. I did a lot of research to solve it myself so as not to ask you, but I couldn't even come close to what I was looking for.
Now the reason for such a search is the stock market etc. Companies have limited free APIs. I thought of something different.
Let me first explain what I want to do.
First of all, I want to convert the "dollar" currency in the circle in the picture below to the "try" currency. Not all coins on the list are available on a single exchange. I found an exchange that has all of these but there is an API limitation. The fee is too high. I thought something like this. I want it to detect the "dollar $" currency you see for the circle in the picture and display it as the "try" currency opposite it. However, I want to do this without using the API. In short, prices are already taken from the stock exchange and displayed. I want to convert the received dollar$ prices to "try" currency without using the API again. If it can be done, my API problem will disappear.
dolar to try converter
https://www.google.com/search?client=opera&q=dolar+kaç+tl&sourceid=opera&ie=UTF-8&oe=UTF-8
Dollar $ detects the currency and then etc. in the dollar to try link I left above. I want to convert currencies from the site to each other and print the result.
What I want may seem very complicated. I hope I was able to explain what I want. If there is something you do not understand, you can ask.
https://forum.rainmeter.net/viewtopic.php?t=36931
-
- Posts: 24
- Joined: October 21st, 2021, 11:08 pm
Re: How to use api for unmineable pool?
I just found a very nice site. Gives 10000 credits per day for API. It resets every 24 hours. Not a problem for me. quite enough.
site :
I managed to get it working when I checked the api documentation.
I quickly became a member and created an API key. then from the api documentation;
I ran this code.
The "rate" part in the output is the part that works for me.
example python content;
After pasting this code into the text document and saving it as "test.py", I run cmd as administrator and type "test.py" and the screen below works.
I tried to adapt "rainmeter" with the method you taught. I'm making a mistake somewhere but I don't understand. Let me share with you the code I adapted. show me my mistake.
site :
Code: Select all
https://www.livecoinwatch.com/tools/api
I quickly became a member and created an API key. then from the api documentation;
Code: Select all
https://livecoinwatch.github.io/lcw-api-docs/#coinssingle
The "rate" part in the output is the part that works for me.
example python content;
Code: Select all
import requests
import json
url = "https://api.livecoinwatch.com/coins/single"
payload = json.dumps({
"currency": "TRY",
"code": "BTC",
"meta": True
})
headers = {
'content-type': 'application/json',
'x-api-key': '90290ad6-4e32-4117-a2ac-9c16cdca060e'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)
I tried to adapt "rainmeter" with the method you taught. I'm making a mistake somewhere but I don't understand. Let me share with you the code I adapted. show me my mistake.
Code: Select all
[Rainmeter]
Update=100
Author=-MTCHANNEL-
BackgroundMode=2
SolidColor=0,0,0,1
MiddleMouseUpAction=[!Refresh]
RightMouseUpAction=[!SkinCustomMenu]
DynamicWindowSize=1
AccurateText=1
---10000credit APi---
[10000credit]
Measure=Plugin
Plugin=RunCommand
Program=python
Parameter=test.py
State=Hide
OutputType=ANSI
RegExpSubstitute=1
Substitute="(?siU)^(?:.*'rate':(.*)[,}].*|.*)$":"\1","^\\\d+$":"","(?:^\s+|\s+$)":"","(?:^'|'$)":"" <<<< (I tried this part in different variations. I 100% think I'm getting an error in this part.)
---10000credit APi---
---APi CONNECT---
[10000creditRate]
Meter=String
UpdateDivider=60
OnUpdateAction=[!CommandMeasure 10000credit "Run"]
---APi CONNECT---
---10000creditText---
[10000creditText]
Meter=String
X=230
Y=201
FontFace=Consolas
FontColor=255,255,255,255
StringStyle=BOLD
StringEffect=SHADOW
FontEffectColor=0,0,0,50
FontSize=15
AntiAlias=1
MeasureName=10000credit
Text= : %1 TRY
DynamicVariables=1
---10000creditText---
-
- Rainmeter Sage
- Posts: 7178
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: How to use api for unmineable pool?
I don't know why you insist in using a python script to access what should be easily available to a WebParser measure assuming a correct query address (the only reason I could think of for this is WebParser not being able to use session-based authentication or logins, though this should be possible if the API allows passing your key or whatever as a parameter in the URL query string), but anyway...mtchannel wrote: ↑March 18th, 2024, 10:44 am I just found a very nice site. Gives 10000 credits per day for API. It resets every 24 hours. Not a problem for me. quite enough.
site :I managed to get it working when I checked the api documentation.Code: Select all
https://www.livecoinwatch.com/tools/api
I quickly became a member and created an API key. then from the api documentation;I ran this code.Code: Select all
https://livecoinwatch.github.io/lcw-api-docs/#coinssingle
The "rate" part in the output is the part that works for me.
example python content;After pasting this code into the text document and saving it as "test.py", I run cmd as administrator and type "test.py" and the screen below works.Code: Select all
import requests import json url = "https://api.livecoinwatch.com/coins/single" payload = json.dumps({ "currency": "TRY", "code": "BTC", "meta": True }) headers = { 'content-type': 'application/json', 'x-api-key': '90290ad6-4e32-4117-a2ac-9c16cdca060e' } response = requests.request("POST", url, headers=headers, data=payload) print(response.text)
I tried to adapt "rainmeter" with the method you taught. I'm making a mistake somewhere but I don't understand. Let me share with you the code I adapted. show me my mistake.
Code: Select all
[Rainmeter] Update=100 Author=-MTCHANNEL- BackgroundMode=2 SolidColor=0,0,0,1 MiddleMouseUpAction=[!Refresh] RightMouseUpAction=[!SkinCustomMenu] DynamicWindowSize=1 AccurateText=1 ---10000credit APi--- [10000credit] Measure=Plugin Plugin=RunCommand Program=python Parameter=test.py State=Hide OutputType=ANSI RegExpSubstitute=1 Substitute="(?siU)^(?:.*'rate':(.*)[,}].*|.*)$":"\1","^\\\d+$":"","(?:^\s+|\s+$)":"","(?:^'|'$)":"" <<<< (I tried this part in different variations. I 100% think I'm getting an error in this part.) ---10000credit APi--- ---APi CONNECT--- [10000creditRate] Meter=String UpdateDivider=60 OnUpdateAction=[!CommandMeasure 10000credit "Run"] ---APi CONNECT--- ---10000creditText--- [10000creditText] Meter=String X=230 Y=201 FontFace=Consolas FontColor=255,255,255,255 StringStyle=BOLD StringEffect=SHADOW FontEffectColor=0,0,0,50 FontSize=15 AntiAlias=1 MeasureName=10000credit Text= : %1 TRY DynamicVariables=1 ---10000creditText---
The problem, as far as I could tell, is the fact that you still use ' as field and value delimiter in your regex patterns. I already explained this above, you should use " as field and value delimiters (just like in the response from the site), and use ' as the substitution parts delimiters when such parts include " quotes (or viceversa, if the site uses ' as field and value delimiters). In other words, your pattern contents should replicate the syntax in your response, so they can match what's being there.
-
- Posts: 24
- Joined: October 21st, 2021, 11:08 pm
Re: How to use api for unmineable pool?
I changed all my APIs to Python. That's why I insist
[/url]
It works in cmd screen. but when I run "rainmeter" I get the unicode error in the image. I tried different unicodes. I think it's a font style error. I'm trying different alternatives now.
[/url]
It works in cmd screen. but when I run "rainmeter" I get the unicode error in the image. I tried different unicodes. I think it's a font style error. I'm trying different alternatives now.
-
- Rainmeter Sage
- Posts: 7178
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: How to use api for unmineable pool?
Oh, I see. Well, since I probably won't be able to test the API, by the looks of it this seems like a python script error. If the STDOUT output text shows up properly (in the log or by displaying it in the skin) after running the RunCommand, then there's no need to change the value of the OutputType option (plus, its value doesn't influence the actual output of the script anyway, only what you get to see as the measure output):
https://docs.rainmeter.net/manual/plugins/runcommand/
I'd say that maybe some parameter / function in python can help, or, you can try using %ComSpec% /U /C as the value of the Program option and python test.py as the value of the Parameter option to see if it solves anything.
-
- Rainmeter Sage
- Posts: 7178
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: How to use api for unmineable pool?
Alright, I've been able to test your code and try out different fixes, but I'm not familiar enough with python yet to make it work. What I can say for sure is that it's definitely related to this (so, it's a python issue, not a Rainmeter one):
https://stackoverflow.com/questions/10569438/how-to-print-unicode-character-in-python
Yes, I tried various variants from that page and others, and although the error message changed, it didn't print the expected result. Maybe you'll have better luck with this - if you do, post the solution here as well, maybe it will help others that might have the same problem in the future.
-
- Rainmeter Sage
- Posts: 7178
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: How to use api for unmineable pool?
Found a solution (sort of)!
test.py:
Code: Select all
import codecs
import sys
import requests
import json
url = "https://api.livecoinwatch.com/coins/single"
payload = json.dumps({
"currency": "TRY",
"code": "BTC",
"meta": True
})
headers = {
'content-type': 'application/json',
'x-api-key': '90290ad6-4e32-4117-a2ac-9c16cdca060e'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text.encode('utf-8'))
Code: Select all
[Rainmeter]
Update=1000
Author=-MTCHANNEL-
BackgroundMode=2
SolidColor=0,0,0,1
MiddleMouseUpAction=[!Refresh]
;RightMouseUpAction=[!SkinCustomMenu]
DynamicWindowSize=1
AccurateText=1
---10000credit APi---
[10000credit]
Measure=Plugin
Plugin=RunCommand
Program=python
Parameter=test.py
State=Hide
OutputType=UTF8
RegExpSubstitute=1
Substitute='(?siU)^(?:.*"rate":(.*)[,}].*|.*)$':"\1","^\\\d+$":"","(?:^\s+|\s+$)":"",'(?:^"|"$)':""
---10000credit APi---
---APi CONNECT---
[10000creditRate]
Meter=String
UpdateDivider=60
---APi CONNECT---
---10000creditText---
[10000creditText]
Meter=String
X=230
Y=201
FontFace=Consolas
FontColor=255,255,255,255
StringStyle=BOLD
StringEffect=SHADOW
FontEffectColor=0,0,0,50
FontSize=15
AntiAlias=1
MeasureName=10000credit
Text= : %1 TRY
LeftMouseUpAction=[!CommandMeasure 10000credit "Run"]
DynamicVariables=1
---10000creditText---
https://docs.rainmeter.net/manual/variables/character-variables/
Or, you could perfect the method yourself in python, so that such substitutions in Rainmeter wouldn't be required and funky characters would be printed properly to STDOUT from the start.
Note: I saw that you used Update=100 and UpdateDivider=60 in your original code. This means python and the request is ran every 100 * 60 = 6000 milliseconds = 6 seconds. Not sure if it's reasonable from the site's point of view, but well, you'll be the one to lose if they think otherwise - I did my part and explained why...
You do not have the required permissions to view the files attached to this post.
-
- Posts: 24
- Joined: October 21st, 2021, 11:08 pm
Re: How to use api for unmineable pool?
I will test the codes you gave. There is a slight improvement for me. Check this out if you want.
note: "Update=100 and UpdateDivider=60" Yes, I did these like this. because if you do this every 60 seconds, it will be defeated. If I do "Update=1000 and UpdateDivider=60", it is refreshed every 150 seconds. Frankly, I didn't understand either.
Code: Select all
test.py;
import requests
import json
url = "https://api.livecoinwatch.com/coins/single"
payload = json.dumps({
"currency": "TRY",
"code": "BTC",
"meta": True
})
headers = {
'content-type': 'application/json',
'x-api-key': '90290ad6-4e32-4117-a2ac-9c16cdca060e'
}
response = requests.request("POST", url, headers=headers, data=payload)
response.encoding = response.apparent_encoding
print(response.text)
-
- Rainmeter Sage
- Posts: 7178
- Joined: February 27th, 2015, 2:38 pm
- Location: Terra Yincognita
Re: How to use api for unmineable pool?
It gives me the same error as in your original code. So, for me, what I posted the last time works.
I believe you, but I seriously doubt it updated every 150 seconds if you properly told it to update every 60 seconds. Proof:
Code: Select all
import codecs
import sys
import requests
import json
url = "https://api.livecoinwatch.com/coins/single"
payload = json.dumps({
"currency": "TRY",
"code": "BTC",
"meta": True
})
headers = {
'content-type': 'application/json',
'x-api-key': '90290ad6-4e32-4117-a2ac-9c16cdca060e'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text.encode('utf-8'))
Code: Select all
[Rainmeter]
Update=1000
Author=-MTCHANNEL-
BackgroundMode=2
SolidColor=0,0,0,1
MiddleMouseUpAction=[!Refresh]
;RightMouseUpAction=[!SkinCustomMenu]
DynamicWindowSize=1
AccurateText=1
---10000credit APi---
[10000credit]
Measure=Plugin
Plugin=RunCommand
Program=python
Parameter=test.py
State=Hide
OutputType=UTF8
;RegExpSubstitute=1
;Substitute='(?siU)^(?:.*"rate":(.*)[,}].*|.*)$':"\1","^\\\d+$":"","(?:^\s+|\s+$)":"",'(?:^"|"$)':""
---10000credit APi---
---APi CONNECT---
[10000creditRate]
Meter=String
UpdateDivider=60
OnUpdateAction=[!Log "Running the command"][!CommandMeasure 10000credit "Run"]
---APi CONNECT---
---10000creditText---
[10000creditText]
Meter=String
X=230
Y=201
W=600
FontFace=Consolas
FontColor=255,255,255,255
StringStyle=BOLD
StringEffect=SHADOW
FontEffectColor=0,0,0,50
FontSize=15
AntiAlias=1
ClipString=2
MeasureName=10000credit
Text= : %1 TRY
DynamicVariables=1
---10000creditText---
You do not have the required permissions to view the files attached to this post.