I'm using the Wolfram Simple API and it generates an image as a result. I want to show that image in an imageview but the problem is that I can't get the url of the image.I searched a lot but couldn't find anything.Can anybody help me and guide how do I get the url of the result image?
Asked
Active
Viewed 1,062 times
2
-
Wolfram Simple API returns image, not the image url. So, you will have to pass the received to image source directly. – abhijeet chimankar Apr 18 '18 at 12:36
-
@abhijeetchimankar could you please tell me how to do it? – Neha Apr 19 '18 at 04:33
2 Answers
0
Here's an example to find Natalie Portman's picture via wolframalpha:
http://api.wolframalpha.com/v2/query?appid=DEMO&input=natalie%20portman&includepodid=Image:PeopleData&output=json
This request specifically requests just the Image pod be returned (via JSON).
Result:
{
"queryresult": {
"success": true,
"error": false,
"numpods": 1,
"datatypes": "People",
"timedout": "",
"timedoutpods": "",
"timing": 1.489,
"parsetiming": 0.139,
"parsetimedout": false,
"recalculate": "",
"id": "MSP",
"host": "http://www5a.wolframalpha.com",
"server": "40",
"related": "http://www5a.wolframalpha.com",
"version": "2.6",
"pods": [
{
"title": "Image",
"scanner": "Data",
"id": "Image:PeopleData",
"position": 100,
"error": false,
"numsubpods": 1,
"subpods": [
{
"title": "",
"imagesource": "http://en.wikipedia.org/wiki/File:Natalie_Portman_at_TIFF_2009.jpg",
"img": {
"src": "http://www5a.wolframalpha.com",
"alt": "",
"title": "",
"width": 101,
"height": 150
},
"plaintext": ""
}
]
}
],
"sources": {
"url": "http://www.wolframalpha.com/sources/PeopleDataSourceInformationNotes.html",
"text": "People data"
}
}
}
To get at the URL using python for example:
image_url = json_result['queryresult']['pods'][0]['subpods'][0]['imagesource']
print(image_url)
image_url:
http://en.wikipedia.org/wiki/File:Natalie_Portman_at_TIFF_2009.jpg
http://en.wikipedia.org/wiki/File:Natalie_Portman_at_TIFF_2009.jpg

Jay Marm
- 556
- 5
- 12
-
actually I'm using it for calculating equation , so what should I pass in `includepodid` ? – Neha Apr 21 '18 at 05:35
-
For this query: http://api.wolframalpha.com/v2/query?input=\int_0^5 x^2 dx if you check the json result, the graph is returned in the pod id: "VisualRepresentationOfTheIntegral". – Jay Marm Apr 22 '18 at 10:09
-
I'm using this query : http://api.wolframalpha.com/v1/simple?appid=DEMO&i=(2x-3=5) and I get an image in response ,where do I check the json result ? – Neha Apr 23 '18 at 04:39
0
For Wolfram Simple API, you have to pass the url output directly to image.
http://api.wolframalpha.com/v1/simple?appid=DEMO&i=What+airplanes+are+flying+overhead%3F
You can refer to working sample here:
var url = 'http://api.wolframalpha.com/v1/simple?appid=DEMO&i=What+airplanes+are+flying+overhead%3F';
$(document).ready(function(){
$.ajax({
url : url,
}).always(function(){
$("#IMAGE_ID").attr("src", url);
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<body>
<img id='IMAGE_ID'>
</body>

abhijeet chimankar
- 66
- 6