check ethereum wallet on via api blockchain.info - python

i am using https://blockchain.info/ api For checking my balance i use this link :
https://blockchain.info/rawaddr/16****
Is there something similar for ethereum wallet ?
i want to know sender's address and history of my ethereum wallet in blockchain info

If I understand well, you're looking for an api to check balance of ethereum accounts ?
Check this : https://etherscan.io/apis

Amberdata.io has an API with a bunch of data on addresses. Something unique is that they have Historical Account Balances, as well as, the ability to list all transactions by address.
Here's an example response from the addresses/:hash/statistics endpoint:
curl \
-X "GET" \
-H "accept: application/json" \
-H "x-api-key: <api_key>" \
"https://web3api.io/api/v1/addresses/0x06012c8cf97bead5deae237070f9587f8e7a266d/statistics"
Response:
{
"status": 200,
"title": "OK",
"description": "Successful request",
"payload": {
"balance": "43625340634292316919",
"balanceIn": "2.714245071508029334975e+22",
"balanceOut": "2.7098825374446001032831e+22",
"addressType": "contract",
"contractTypes": [
"ERC721"
],
"decimals": "0",
"name": "CryptoKitties",
"numHolders": "72506",
"numTokens": "1421403",
"numTransfers": "1356726",
"symbol": "CK",
"totalSupply": "1421403.0000000000000000",
"totalValueUSD": null,
"unitValueUSD": null
}
}
Let me know if any of that is helpful! šŸ˜„

Related

Post method returns 422 using Requests but working fine with CURL and Postman

I am using Python with Requests module to connect to an EasyRedmine API. I'm having trouble creating a project using the post method in order to post a JSON. It returns "[Unprocessable Entity
<Response [422]>]". I have tried the same request using Postman and Curl and it works perfectly. Does anyone know what could be causing this problem? The following curl command works fine.
curl -X 'POST'
'https://cafte.easyredmine.com/projects.json?key=0224b4238XXXX'
-H 'accept: application/json'
-H 'X-Redmine-API-Key: 0224b4238XXX'
-H 'Content-Type: application/json'
-d '{
"project": {
"easy_external_id": "external-system-1",
"name": "Blue 2",
"homepage": "blue-7",
"description": "I canā€™t abide these Jawas. Disgusting creatures.",
"author_id": 0,
"is_planned": true,
"easy_is_easy_template": true,
"easy_currency_code": "EUR"
}
This is the methode code:
def create_project(self, name: str, description="", external_id="", homepage="", parent_id="", author_id="",
is_planned= 'false', is_easy_template= "true", start_date="", due_date="", custom_fields=[],
tag_list=[], currency='EUR'):
print(name)
data = {"project": {
"easy_external_id": external_id,
"name":name,
"homepage": homepage,
"description": description,
"parent_id": parent_id,
"author_id": author_id,
"is_planned": is_planned,
"easy_is_easy_template": is_easy_template,
"easy_start_date": start_date,
"easy_due_date": due_date,
"custom_fields": custom_fields,
"tag_list": tag_list,
"easy_currency_code": currency
}
}
endpoint_path = "/projects"
endpoint = f'{self.base_url}{endpoint_path}'
headers = {'X-Redmine-API-Key': f'{self.api_key}',
'accept': 'application/json',
'Content-Type': 'application/json'
}
r = requests.post(endpoint, headers=headers, json= data)

Python flask API POST request - JSON data after key

I'm very new to development, I'm writing a Python Flask app which is executing a POST request to log a new ticket on a system, I just need someone to verify how I structure this request as I'm really not sure.
The documentation says, for example:
curl api/v3/requests
-X POST
-H "Accept: application/vnd.manageengine.sdp.v3+json"
-H "Authorization: Zoho-Oauthtoken 1000.7xxx98976ab0xxxxxx19901e7551be57.bxxxx921ed64c04f79622bebcfxxxxxx"
-H "Content-Type: application/x-www-form-urlencoded"
-d input_data= '{
"request": {
"subject": "Need an External Monitor",
"resolution": {
"add_to_linked_requests": false,
"content": "The following is the resolution to the above request"
}
}
It's expecting input_data key, followed by the JSON array of info to submit.
The documentation is (here)
My code:
#app.route("/log", methods=["GET"])
def log():
"""Fetching a protected resource using an OAuth 2 token.
"""
servicedesk = OAuth2Session(client_id, token=session['oauth_token'])
headers = {"Authorization": "Bearer " + token, "Accept": "application/vnd.manageengine.sdp.v3+json", "Content-Type": "application/x-www-form-urlencoded"}
data = {
"request": {
"subject": "New Incident",
"mode": {
"name": "E-Mail",
},
"group": {
"name": "Incident"
},
"requester": {
"name": "Sarah Curtis Test"
},
"status": {
"name": "Open",
},
"template": {
"name": "Report an Incident"
},
"request_type": {
"name": "Incident",
},
"description": "This is a test. please ignore",
"category": {
"name": "Incident"
}
}
}
requests.post('https://sdpondemand.manageengine.eu/api/v3/requests?input_data=', data=data, headers=headers)
I don't have access to logs on the server to see what it is receiving either as it's a cloud service (unless there's a way to echo back the original raw POST request?)
The ticket isn't being logged when I try and do so via my app. It does work through Postman app to test the API request, when I add the JSON above into the x-www-form-urlencoded section on the body tab and put input_data into the key.
I need to know how to structure the POST request in my code. Any help appreciated! Thanks

Forming a request.post from a curl on python

I have a small project i need a tempmail for, so i found this site https://mail.tm/en, so i was trying to acess the post via the api and instructions given here https://api.mail.tm/.
As I am new at working with curl and so on I have a lot of problems authorizing into an account there.
First of all i got an CURL link on site like this one:
curl -X POST "https://api.mail.tm/accounts" -H "accept: application/ld+json" -H "Authorization: testing" -H "Content-Type: application/ld+json" -d "{\"address\":\"test\",\"password\":\"stackoverflow\"}"
I tried to form it all in a post request, so i did this
headers = {"accept": "application/ld+json", "Authorization": "header", "Content-Type": "application/ld+json"}
data = "{\"address\":\"zashyganii\",\"password\":\"chertila\"}"
mail = requests.post("https://api.mail.tm/accounts", data = data, headers = headers)
print(mail.status_code)
the error code is 400, noted on the api site like this.
400 Error:
Response body
Download
{
"#context": "/contexts/ConstraintViolationList",
"#type": "ConstraintViolationList",
"hydra:title": "An error occurred",
"hydra:description": "address: This value is not a valid email address.\naddress: The domain \"\" is not valid.",
"violations": [
{
"propertyPath": "address",
"message": "This value is not a valid email address."
},
{
"propertyPath": "address",
"message": "The domain \"\" is not valid."
}
]
}
Could you please turn this curl in to a request.post on python so it will work for this api
Seems like there are not any problem with the request. It's a validation fail.

Requests on a api doesn't work (Curl and python)

So, I try to make a program who tell me the schedule of my bus, i take this real time information on an Api:
https://api-lab-trone-stif.opendata.stif.info/service/tr-vianavigo/departures?line_id=100100385%3A385&stop_point_id=StopPoint%3A59%3A6195786
but when i lunch it there is an error :
"error": "Unknown dataset: tr-vianavigo"
I have a token to use I think but how ?
the Curl for this api is :
curl -X GET --header "Accept: application/json" "https://api-lab-trone-
stif.opendata.stif.info/service/tr-vianavigo/departures?
line_id=100100020%3A20&stop_point_id=59%3A4726914"
when i use the first url on my web browser it work and show me :
[
{
"lineDirection": "Juvisy RER",
"code": "duration",
"time": "12"
},
{
"lineDirection": "Savigny Toulouse-Lautrec",
"code": "duration",
"time": "20"
},
{
"lineDirection": "Juvisy RER",
"code": "duration",
"time": "38"
},
{
"lineDirection": "Savigny Toulouse-Lautrec",
"code": "duration",
"time": "45"
}
]
but in python if i just test :
import requests
#my token
apikey = 'ef169369dfd911b01371b73e975ed88adce881bc92dbbd9720551c94'
#url of the api
url ='https://api-lab-trone-stif.opendata.stif.info/service/tr-vianavigo/departures?line_id=100100385%3A385&stop_point_id=StopPoint%3A59%3A6195786'
#requests
r = requests.get(url, apikey)
print(r.text)
it make the error :
"error": "Unknown dataset: tr-vianavigo"
You must use one of your API keys for this purpose. An API key is obtained via your user account in My API keys. Once generated, the key must be inserted as a query parameter (apikey) in the URL of your
call. For your example:
curl -X GET --header "Accept: application/json" "https://api-lab-trone-stif.opendata.stif.info/service/tr-vianavigo/departures?line_id=100100020%3A20&stop_point_id=59%3A4726914&apikey=<YOUR-API-KEY>"
FYI, the scope of the real-time data available on the dataset tr-unitaire-stif is avalaible here.

Dialogflow v2 error ā€œMalformedResponse 'final_response' must be setā€

I am getting this error only when using the simulator/google assistant. When I use the Slack integration or test within DialogFlow then it works perfectly.
I checked this question about settings in DialogFlow, but that wasn't my issue. I checked this question but because I use python in my webhook, I can't be sure whether that would solve it for me or not.
I am doing the following:
First, the user invokes any one of my intents which are connected through a webhook to my python code. Call this intent1.
Second, I check to see what the response (response1) would be for intent1 in my code.
Third, I send response1 to another intent intent2 via a followup-event event2.
The reason why I'm doing this just for interest is that I'm allowing multiple types of conversation flows. The first being FAQs and the second being a directed conversation.
The JSON I'm sending back is:
"followupEventInput":{
"name":"EventName",
"parameters":{
"speech": str(speech)
}
}
EventName is event2.
speech is response1
I also tried adding this to the JSON, but it didn't change anything:
,"payload": {"google":{"expectUserResponse": False}}
The Debug from the simulator shows:
{
"response": "",
"expectUserResponse": false,
"conversationToken": "GidzaW11bG...",
"audioResponse": "//NExAASWK...",
"debugInfo": {
"assistantToAgentDebug": {
"curlCommand": "curl -v 'https://api.api.ai/api/integrations/google?token=2b0fcc112a9b40c48f7a7182a29f6b2f' -H 'Content-Type: application/json;charset=UTF-8' -H 'Google-Actions-API-Version: 2' -H 'Authorization: eyJhbGciOiJSUzI1NiIsImtpZCI6IjQxMjlkYjJlYTE4NjBkMmU4NzFlZTQ4NTA2Mjg3ZmIwNWIwNGNhM2YifQ.eyJhdWQiOiJkbmFmaXQtZmFxIiwiZXhwIjoxNTMwODU5MzIzLCJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJqdGkiOiJiNDcwZjdhODYyYWJiMzI0NjRjNGY5MmU4MTQ1ZWU5NTFlYTA1MWY5IiwiaWF0IjoxNTMwODU5MjAzLCJuYmYiOjE1MzA4NTg5MDN9.XMAmItiH9SEo1I24T5xEPvSfP7dPX21AYHvVqZZReayNoR396ZQ1JdHZiY9rwGfp49qSwn2ea9EDkNVCQ-PK8NIKdTdxG-L0HuhY7r8nEMfzO4PjJKU6bI-Ry1OwL3A90WGK0l8rwJpByHSfA1gTsS7PU983yyR51PCJFkVnd2KQfX1ZKPIqpcEzKkCvexh9mwOx8cH6iVYuBzmHctH1FRLqhzzRb9zcx3Qq2mDFB8cVbl8SluXLyV4hBeKSeFe-HnkWEzqE3zvgIbAZha2rAOMb2xx1ta_M86hmwET4woAB-hBlR77cyNZV49Y5GmFrF5DozvQWEw1GNoRxcZCLhA' -A 'Mozilla/5.0 (compatible; Google-Cloud-Functions/2.1; +http://www.google.com/bot.html)' -X POST -d '{\"user\":{\"userId\":\"ABwppHEpW9IVOkzk8egeV0A0NHO5Ug4wqLj3ney3hdwx_iPW4cMeayYws8m-fzoFiYksk7JsnDmi-g\",\"locale\":\"en-US\",\"lastSeen\":\"2018-07-05T15:54:50Z\"},\"conversation\":{\"conversationId\":\"1530859188209\",\"type\":\"ACTIVE\",\"conversationToken\":\"[]\"},\"inputs\":[{\"intent\":\"actions.intent.TEXT\",\"rawInputs\":[{\"inputType\":\"KEYBOARD\",\"query\":\"what are the best recipes for oranges\"}],\"arguments\":[{\"name\":\"text\",\"rawText\":\"what are the best recipes for oranges\",\"textValue\":\"what are the best recipes for oranges\"}]}],\"surface\":{\"capabilities\":[{\"name\":\"actions.capability.MEDIA_RESPONSE_AUDIO\"},{\"name\":\"actions.capability.WEB_BROWSER\"},{\"name\":\"actions.capability.AUDIO_OUTPUT\"},{\"name\":\"actions.capability.SCREEN_OUTPUT\"}]},\"isInSandbox\":true,\"availableSurfaces\":[{\"capabilities\":[{\"name\":\"actions.capability.WEB_BROWSER\"},{\"name\":\"actions.capability.AUDIO_OUTPUT\"},{\"name\":\"actions.capability.SCREEN_OUTPUT\"}]}],\"requestType\":\"SIMULATOR\"}'",
"assistantToAgentJson": "{\"user\":{\"userId\":\"ABwppHEpW9IVOkzk8egeV0A0NHO5Ug4wqLj3ney3hdwx_iPW4cMeayYws8m-fzoFiYksk7JsnDmi-g\",\"locale\":\"en-US\",\"lastSeen\":\"2018-07-05T15:54:50Z\"},\"conversation\":{\"conversationId\":\"1530859188209\",\"type\":\"ACTIVE\",\"conversationToken\":\"[]\"},\"inputs\":[{\"intent\":\"actions.intent.TEXT\",\"rawInputs\":[{\"inputType\":\"KEYBOARD\",\"query\":\"what are the best recipes for oranges\"}],\"arguments\":[{\"name\":\"text\",\"rawText\":\"what are the best recipes for oranges\",\"textValue\":\"what are the best recipes for oranges\"}]}],\"surface\":{\"capabilities\":[{\"name\":\"actions.capability.MEDIA_RESPONSE_AUDIO\"},{\"name\":\"actions.capability.WEB_BROWSER\"},{\"name\":\"actions.capability.AUDIO_OUTPUT\"},{\"name\":\"actions.capability.SCREEN_OUTPUT\"}]},\"isInSandbox\":true,\"availableSurfaces\":[{\"capabilities\":[{\"name\":\"actions.capability.WEB_BROWSER\"},{\"name\":\"actions.capability.AUDIO_OUTPUT\"},{\"name\":\"actions.capability.SCREEN_OUTPUT\"}]}],\"requestType\":\"SIMULATOR\"}"
},
"agentToAssistantDebug": {
"agentToAssistantJson": "{\n \"responseMetadata\": {\n \"status\": {\n \"code\": 10,\n \"message\": \"Failed to parse Dialogflow response into AppResponse because of empty speech response\",\n \"details\": [{\n \"#type\": \"type.googleapis.com/google.protobuf.Value\",\n \"value\": \"{\\\"id\\\":\\\"63a2647e-43fc-4c36-9067-5c48b51626bb\\\",\\\"timestamp\\\":\\\"2018-07-06T06:40:04.014Z\\\",\\\"lang\\\":\\\"en-us\\\",\\\"result\\\":{},\\\"status\\\":{\\\"code\\\":200,\\\"errorType\\\":\\\"success\\\"},\\\"sessionId\\\":\\\"1530859188209\\\"}\"\n }]\n }\n }\n}"
},
"sharedDebugInfoList": [
{
"name": "ResponseValidation",
"debugInfo": "",
"subDebugEntryList": [
{
"name": "MalformedResponse",
"debugInfo": "'final_response' must be set.",
"subDebugEntryList": []
}
]
}
]
},
"visualResponse": {
"visualElementsList": [],
"suggestionsList": [],
"agentLogoUrl": ""
},
"clientError": 0,
"is3pResponse": 1
}
The value of the agentToAssistantJson field includes the message "Failed to parse Dialogflow response into AppResponse because of empty speech response". As it suggests, whatever you're sending in your response is missing speech information.
You don't specify what Event2 is doing, what it is sending back, or what it is doing with the parameter (if anything), but the likely issue is that it isn't sending back anything. Just including the speech as a parameter doesn't do anything - parameters are just information, not replies.
While there are some uses for followup events, most of the time they aren't what you really want. If you want to reply with a message from the fulfillment - just reply with the message.

Categories