How to call API successfully and parse results

webapi

#1

Hi Thunkers,

I am writing hoping for some assistance with an app I am wanting to make.

I have found an API for a plants database: https://github.com/sckott/usdaplantsapi however I am having difficulties successfully calling this API in my app and parsing the results in a manner I want to.

I have tried reading Domhnall’s tutorial (Introduction to APIs) but I haven’t been able to solve my issues.

What I would really like to have happen is a call made to the API which brings back a random plant from the plants database and the Species, Genus and Scientific Name are displayed for the random plant selected.

Is anyone able to help me out with how to achieve this?

Thanks in advance!


#2

what did you try? the API does not offer to return a random plant…

It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

example call to get 5 plants (limit) skipping the first 10 plants (offset) and returning the fields id, Genus, Species, AcceptedSymbol
https://plantsdb.xyz/search?offset=10&limit=5&fields=id,Genus,Species,AcceptedSymbol

{"count":92161,"returned":5,"citation":"USDA, NRCS. 2016. The PLANTS Database (http://plants.usda.gov, 12 July 2016). National Plant Data Team, Greensboro, NC 27401-4901 USA.","terms":"Our plant information, including the distribution maps, lists, and text, is not copyrighted and is free for any use.","data":[{"id":11,"Species":"ammophila","Genus":"Abronia"},{"id":12,"Species":"americana","Genus":"Abama"},{"id":13,"Species":"americanum","Genus":"Abutilon"},{"id":14,"Species":"angustifolia","Genus":"Abronia"},{"id":15,"Species":"angustifolia","Genus":"Abronia"}],"error":null}

Taifun