treflehq / trefle-api

🍀 Trefle is a botanical JSON REST API for plants species, allowing you to search and query over all the registered species, and build the next gardening apps and farming robots.
https://trefle.io
GNU Affero General Public License v3.0
476 stars 50 forks source link

Not receiving all the fields in the data #85

Open ayezinzu opened 3 years ago

ayezinzu commented 3 years ago

Hey guys m using the trefle api. this is my code


const fetchData = async () => {
 const response = await fetch(`https://trefle.io/api/v1/plants?token=T_uA0qXw0b6uLOiVNsXf7Dns8h5iwLr-MYHgD4fidaA&filter[common_name]=wheat`);
  const json = await response.json();
  return json
}
const fetchedData = fetchData().then((data) => {
    console.log(data.data)
})```
this is the data I get 
```[
  {
    id: 190066,
    common_name: 'Wheat',
    slug: 'triticum-urartu',
    scientific_name: 'Triticum urartu',
    year: 1972,
    bibliography: 'Bot. Zhurn. (Moscow & Leningrad) 57: 176 (1972)',
    author: 'Thumanjan ex Gandilyan',
    status: 'accepted',
    rank: 'species',
    family_common_name: 'Grass family',
    genus_id: 134,
    image_url: 'https://d2seqvvyy3b8p2.cloudfront.net/138572776e13fbd25318bb29988915bf.jpg',
    synonyms: [
      'Triticum urartu var. libanicum',
      'Crithodium urartu',
      'Triticum urartu var. pubescentinigrum',
      'Triticum urartu var. pubescentiurartu',
      'Triticum urartu var. turcicum',
      'Triticum urartu var. binarturutriru'
    ],
    genus: 'Triticum',
    family: 'Poaceae',
    links: {
      self: '/api/v1/species/triticum-urartu',
      plant: '/api/v1/plants/triticum-urartu',
      genus: '/api/v1/genus/triticum'
    }
  }
]```
but in the docs, these is all the fields https://docs.trefle.io/docs/advanced/plants-fields

like why does my data only some fields from the one mentioned in there
sarahbayley commented 3 years ago

[Apologies for reposting this; I realised later I was not on my personal account.]

@ayezinzu If I'm understanding your issue correctly, you're getting a filtered list of results (though there is only 1 result for filter[common_name]=wheat), so you're getting the basic "front page" data. To get all the fields described in the docs, you then need to go to that plant's page, either using one of the links:

https://trefle.io/api/v1/plants/triticum-urartu?token=T_uA0qXw0b6uLOiVNsXf7Dns8h5iwLr-MYHgD4fidaA https://trefle.io/api/v1/species/triticum-urartu?token=T_uA0qXw0b6uLOiVNsXf7Dns8h5iwLr-MYHgD4fidaA

Or its ID:

https://trefle.io/api/v1/species/190066?token=T_uA0qXw0b6uLOiVNsXf7Dns8h5iwLr-MYHgD4fidaA

Does that make sense, or am I misunderstanding your question? I'm able to access all the fields described.

mmeyers3 commented 3 years ago

Hi. I am struggling to pull information about the plants like their minimum temperature. I think this is the data that is missing when making calls to the API.