Giter Site home page Giter Site logo

Comments (2)

gsmiguel2 avatar gsmiguel2 commented on May 5, 2024

Are there any examples of how to use this API for a beginner like myself? I could really use the help!

from trefle-api.

charitygrace avatar charitygrace commented on May 5, 2024

As someone who's just gotten started with Trefle, there's not much to getting started:
1- create an account to get your "Access token"
2- then review the documentation to determine the url to use to get the information you want

For example:

Once you have your access token you can use it directly in your browser url bar like so:
https://trefle.io/api/species?q=achillea%20borealis&token=YOUR-TOKEN-HERE

This will get you a JSON string of all results that match Achillea borealis.

To get more details on Achillea borealis, you have to look through the resulting string and find the specific plant id that you want. In this example, the id for the main_species is 101927 so you can then run the query:

https://trefle.io/api/plants/101927?token=YOUR-TOKEN-HERE

To get more detailed results specific for Achillea borealis.

I have a Chrome extension installed that makes it easier to view the resulting json string: https://chrome.google.com/webstore/detail/jsonview/chklaanhfefbnpoihckbnefhakgolnmc

To really use this data for a lot of plants you need to develop an app of some sort. I'm working in Javascript to loop through a number of plants, get the data I want and then store it on my side for future display (so I don't have to keep querying the api).

In my case of using javascript fetch rather than the browser, I have to run a terminal command every few hours so that Trefle will allow my app access to the data:
curl -i -X POST "https://trefle.io/api/auth/claim?token=YOUR-TOKEN-HERE"

Then my fetch url (for Achillea borealis) becomes:

https://trefle.io/api/species?q=achillea%20borealis&token=TOKEN-RETRIEVED-FROM-CURL-QUERY

Hope that helps you get started. That's about all I've figured out so far.

from trefle-api.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.