How can I connecting NanoPool.org API to Telegram by Json - json

I'm using cryptocurrency mining website NanoPool.org
I should check the Data of this site for example Hashrate, workers and other things like that
I want to know how can I connect this site to my telegram.
Actually I don't know nothing about that, the only thing I aware about is that, the site have API with json but I searched a lot on Google couldn't find accurate training about that.
This is API link of this website.
Would you please help me how can I do that?
Thanks
User Data example code:
{
"account": "4AHBwkKjWT2jHv83V6ahZXUWCYe9JmyNygQJ7ueQUMhHJrJQJrWnYHHUMuaZhCGSnvKTjodddyxqwdz8y2o7aKRV6C1xntS",
"unconfirmed_balance": "0.36812920",
"balance": "5.87838746",
"hashrate": "2767380.0",
"avgHashrate": {
"h1": "2777915.0",
"h3": "2773365.0",
"h6": "2726529.2",
"h12": "2648470.4",
"h24": "2764918.3"
},
"workers": [
{
"id": "is",
"hashrate": "1861860.0",
"lastShare": 1505534231,
"rating": 322640212,
"avg_h1": "1855980.0",
"avg_h3": "1860296.7",
"avg_h6": "1858237.5",
"avg_h12": "1854944.6",
"avg_h24": "1854664.6"
},
{
"id": "china",
"hashrate": "905520.0",
"lastShare": 1505534231,
"rating": 118148712,
"avg_h1": "921935.0",
"avg_h3": "913068.3",
"avg_h6": "868291.7",
"avg_h12": "793525.8",
"avg_h24": "910253.8"
}
]
}

You can implement it with use of python json, telepot and requests libs
1. Receive json file from nanopool api via requests lib
2. Parse it via json lib
3. Create bot via botfather
4. Send it via telepot library as message to yourself from created bot

Related

Autodesk Construction Cloud API unavailable endpoints

Our team is working with Autodesk Construction Cloud and it's Docs module quite heavily. Because of that we're trying to develop some internal tools which would automate some work that they do, mostly around copying files.
In ACC Docs you can easily copy files from one folder to another. From our investigation it looks like the ACC internally uses an endpoint like this to copy the files:
https://developer.api.autodesk.com/dm/v3/projects/{{projectId}}/documents:copy?targetFolder={{targetFolder}}
By using the authentication token from ACC requests (obtained from the browser), we can easily use this call from Postman or even an AWS Lambda function. But when we're using the auth tokens obtained from 3-legged auth process as described in the documentation, the same API call fails.
Is it even possible right now to obtain an auth token which works with that endpoint for copying ACC Docs files? Or is this not available right now as this API is still not really "public"?
Happy New Year!
Those APIs are internal APIs. Please do not try to use them. even if it may work, you would use it on your own risk..
Regarding with copy files files from one folder to the other, you can use the public API. After you get the version urn of the original file, call the endpoint below with the parameter
POST https://developer.api.autodesk.com/data/v1/projects/{PROJECT_ID}/items?copyFrom=urn%3Aadsk.wipprod%3Afs.file%3Avf.rH_L4XJsTmeiYA4ixCVNAA%3Fversion%3D1
with the payload, in which specify the target folder.
{
"jsonapi": {
"version": "1.0"
},
"data": {
"type": "items",
"relationships": {
"tip":{
"data":{
"type":"versions",
"id":"1"
}
},
"parent": {
"data": {
"type": "folders",
"id": "urn:adsk.wipprod:fs.folder:co.0xaYa2rVTJuFiz7rxLCOQQ"
//!<<< The folder we want to put this file
}
}
}
},
"included":[
{
"type":"versions",
"id":"1",
"attributes":{
"name":"rac_basic_sample_project.rvt" //!<<< Version name
}
}
]
}

London AvailabilityDomain could not be inferred from the Request

I am pretty sure this is something trivial, but I am a bit stuck with this.
I am trying to create an instance in Oracle Cloud in uk-london-1 region via OCI CLI tool.
I am getting
"code": "InvalidParameter",
"message": "AvailabilityDomain could not be inferred from the Request",
The command I am trying to use:
oci compute instance launch --availability-domain lMrS:UK-LONDON-1-AD-1 --compartment-id <myid> --shape VM.Standard.E2.1.Micro --subnet-id <subnetid> --image-id Canonical-Ubuntu-22.04-2022.06.16-0
I got the list of AD's via CLI
~$ oci iam availability-domain list
{
"data": [
{
"compartment-id": "ocid1.tenancy.oc1..###",
"id": "ocid1.availabilitydomain.oc1..###",
"name": "lMrS:UK-LONDON-1-AD-1"
},
{
"compartment-id": "ocid1.tenancy.oc1..###",
"id": "ocid1.availabilitydomain.oc1..###",
"name": "lMrS:UK-LONDON-1-AD-2"
},
{
"compartment-id": "ocid1.tenancy.oc1..###",
"id": "ocid1.availabilitydomain.oc1..###",
"name": "lMrS:UK-LONDON-1-AD-3"
}
]
}
And it is the same list of AD names I see in the Web UI.
Also I have similar error when trying to follow Oracle Cloud "Terraform: Create a Compute Instance" tutorial.
Any help will be appreciated!
Thanks to #urawesome, my compartment-id was wrong and the error returned is a bit misleading as well.
I used actual Compartment name from web UI, when it should have been ocid1.tenancy.### Mainly focused on availability-domain thinking that other parameters will throw different errors if they are invalid.
Correct compartment-id aka tenancy-id solved the issue.
Thanks!

Send an already existing json file as embed using discord.py

I'm working on my first python discord bot and it's turning out to be pretty decent but I wanted to use embeds for certain responses. One of them includes sending all the features of the bots which uses many embeds. I don't have any experience about Javascript or JSON so I used a website "https://discohook.org/" to create an embed as it's GUI based. But as a result, I only get the JSON file and I couldn't find a way where I could load a JSON file and send it as an embed.
The JSON file looks something like this -
{
"content": "Bot Name",
"embeds": [
{
"description": "This command lists all the possible commands which can be used to interact with the bot.",
"author": {
"name": "Help",
"icon_url": "http://4.bp.blogspot.com/-wuUbc-OPOt4/T3ioPh2pAAI/AAAAAAAAAdM/BFFvS5fxVMY/w1200-h630-p-k-no-nu/Questionmark.jpg"
}
},
{
"description": "Bot blesses you. ",
"author": {
"name": "Bless ",
"icon_url": "https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fwallpapercave.com%2Fwp%2Fwp4775695.jpg&f=1&nofb=1"
}
},
{
"description": "Set status as idle",
"color": 16777215,
"author": {
"name": "Go Sleep",
"icon_url": "https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fmedia.forgecdn.net%2Favatars%2F170%2F652%2F636723641550179947.png&f=1&nofb=1"
}
}
]
You could probably just load the individual variables.
with open(“JSON_FILE.txt”) as json_file:
data = json.load(json_file)
data = data[“embeds”]
Then you can have some way to get the specific dictionary.
for embed in data:
pass
Then just have data defined as the dictionary you want to use.
embed = discord.Embed(description = data[“description”])
embed.set_author(name = data[“author”][“name”], icon_url = data[“author”][“icon_url”]
Maybe it've been a long time, but I have exactly the same problem and I found my own solution. Here it is:
from json import loads
from discord import Embed
# Just for our convinience let's make a function
def parse_embed_json(json_file):
embeds_json = loads(json_file)['embeds']
for embed_json in embeds_json:
embed = Embed().from_dict(embed_json)
yield embed
# And the main code looks like this
with open("bot/embeds/temp_ban_embeds.json", "r") as file:
temp_ban_embeds = parse_embed_json(file.read())
for embed in temp_ban_embeds:
await ctx.send(embed=embed)
So I found a special method from_dict. And it seems like it works with dicts we can get from json.loads method. So you can find the documentation here.

OAuth consent screen - ability to remove application logo: old solution is no longer working

Question: how to remove an application logo.
Solution: previous solution from this answer, https://stackoverflow.com/a/57168008/1992004, is no longer working.
Google changed the format of "iconUrl" to "icon", and uses now the Base64-encoded data stream, like "icon":"iVBORw0KGgoAAAAN..., instead of the image URL, previously written as "iconUrl":"https://...".
I've tried "icon":"" and many Base64-encoded values like "icon":"IA", "icon":"Lw", and some of other - no success. I get console messages like
for "icon":""
{
"error": {
"code": 400,
"message": "The request failed because one of the field of the resource is invalid.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.PreconditionFailure",
"violations": [
{
"type": "client_auth_config",
"subject": "?error_code=9&error_field_name=UpdateIconRequest.icon&error_field_value=%3CByteString#3eeee81e+size%3D0+contents%3D%22%22%3E"
}
]
}
]
}
}
or
{
"error": {
"code": 400,
"message": "Request contains an invalid argument.",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.identity.clientauthconfig.v1.ClientAuthConfigError",
"code": "ICON_STORAGE_FAILURE"
},
{
"#type": "type.googleapis.com/google.identity.clientauthconfig.v1.IconStorageError",
"reason": "INVALID_IMAGE"
}
]
}
}
or
{
"error": {
"code": 400,
"message": "Invalid value at 'icon' (TYPE_BYTES), Base64 decoding failed for \" \"",
"status": "INVALID_ARGUMENT",
"details": [
{
"#type": "type.googleapis.com/google.rpc.BadRequest",
"fieldViolations": [
{
"field": "icon",
"description": "Invalid value at 'icon' (TYPE_BYTES), Base64 decoding failed for \" \""
}
]
}
]
}
}
Does somebody know, what should be inserted here to remove the logo image from the app?
Answer:
Unfortunately, there is no way for this to be done.
More Information:
Once an OAuth Application Logo has been uploaded there isn't a supported way of removing it - in the question that you linked the way that this was done is a bit hacky, inspecting the network requests and building a new request from the previous JSON object sent via the UI really shows this.
As the icon URL has changed to need a Base-64 encoded value this has been deprecated. Whether this was intentional by Google or not is hard to say, but now an empty value will always return INVALID_ARGUMENT. Any data in the value for icon will also just replace the image data and so this isn't a viable workaround, as as far as the validation process goes, image data exists and so will need to be verified.
If it's not too much of a arduous process, the only workaround here is to create a new GCP project with a new OAuth consent screen without uploading an image. Of course, you will need to reactivate all the relevant APIs and link the relevant scripts and projects to the new set-up.
Feature Request:
You can however let Google know that this is a feature that is important and that you would like to request they implement it. Google's Issue Tracker is a place for developers to report issues and make feature requests for their development services. I would suggest using the feature request template for G Suite Add-ons as this is a component for which GCP Projects could be used.
Update: The feature request for this is viewable here, to increase visibility on this, hit the ☆ at the top of the page.
Relevant Questions:
OAuth consent screen - ability to remove application logo [Obsolete]
May 2021 - It is still possible to completely delete the consent screen (and thus allowing to create it again). See my updated answer in https://stackoverflow.com/a/57168008/1992004

Is there any documentation for EasyPost that shows the raw JSON for the requests, including headers? Or e.g. a PostMan collection?

I'm just doing the preparation for an integration with EasyPost's Shipping API, which will be server side C#, but we always build a PostMan collection for new integrations, so that we can test data separately from the application if there's an issue.
While I do love the fact that EP provide C# libraries and examples, I'm struggling to find anything that just gives me a list of required headers and the raw JSON format for the body of any requests. It feels a bit like they're just being a little too helpful.
I'll be looking at the Orders endpoint probably.
I've got an account, I've checked all their documentation and searched the internet but haven't found anything so I'm hoping I'm not the first developer to want to use a client application for testing outside my code.
Update:
EasyPost now does have a public workspace https://www.postman.com/easypost-api
with at least 1 public collection
The curl examples are basically the same as json:
For the Address creation example:
-d "address[street1]=417 MONTGOMERY ST"
is the equivalent of
{ "address": { "street1": "417 MONTGOMERY ST" } }
(you might have to escape some characters to be valid json).
Check out How to stimulate cURL request to a request using postman for postman with HTTP Basic Auth.
EasyPost does not provide a public Postman collection; however, here is an example of a shipment Postman body (raw) that could be used. You can adjust the values, actions, objects, etc to your needs.
Using the following, you shouldn't need to pass any headers. You'll pass your API key under the username field with the Basic Auth authorization type.
{
"shipment": {
"to_address": {
"id": "adr_123..."
},
"from_address": {
"id": "adr_123..."
},
"parcel": {
"id": "prcl_123..."
},
"carrier_accounts": {
"id": "ca_123..."
},
"options": {
"address_validation_level": "0"
}
},
"format": "json",
"controller": "shipments",
"action": "create"
}