API Beginner Tips

I want to create a series of websites focusing on Life. My first experiment uses ITIS’ database. You can see an example of what I’m trying to achieve at http://gaia.geobop.com/life/ursus-maritimus/

Now I’d like to try something similar using Catalogue of Life’s database. I normally use WordPress, but I was told that Drupal is better for projets of this nature.

I tentatively want to create separate subdomains for animals, plants, fungi, each vertebrate class, insects, and microbes. I created the first one at mammalia.geobop.com and installed Drupal. Now I need to figure out how to use your API to connect to your database. I hired someone from Fiverr to do it for me, but they couldn’t figure it out. Can you give me some tips that I can share with another developer?

The structure will be very simple . . .

The primary information I need initially is scientific names, common names, rank (e.g family, order, etc.), and parent-child relationships. That will enable me to display bread-crumbs navigation links and lists of children.

Is there a simple way to do that? Or is there a good reference I can share with a developer?

Thank you.

David Blomstrom

@GeoBear

Our API is documented here: GBIF API Reference :: Technical Documentation (see also here the API for checklist bank which is what’s behind the Catalogue of Life website https://api.checklistbank.org).
I suggest checking these two Data Use Club recoded webinars:

1 Like

I was asking ChatGPT for help, but I couldn’t figure it out. Then I hired two different people from Fiverr, but neither one of them could do it either. I’ll check the webinars, though. Thanks.

Is there anything in particular you are struggling with? If you have a specific question it’ll be more easy to answer.

I want to create separate websites focusing on plants, mammals, birds, etc. I’m using WordPress. The first step is to simply display a hierarchy of pages.

On my website aves.geobop.com, for example, I have just one static page - index.php - with a parent template and a child template. The first page - class Aves - should display at mysite/V2, right? Galliformes should display at mysite/38Z, etc.

However, nothing displays at all. Below is the code in my child template. Thank you.

<?php /* Template Name: Life Section Child */ // AVES // Get the slug from the query variable $slug = get_query_var('taxonomy_slug'); // Query the Catalogue of Life API for the taxon ID using the slug $search_api_url = "https://api.checklistbank.org/name/search?q={$slug}"; $search_response = wp_remote_get($search_api_url); $search_data = json_decode(wp_remote_retrieve_body($search_response), true); // Handle errors or no results if (is_wp_error($search_response) || empty($search_data['result'])) { echo "

404 Not Found

"; echo "

The taxon '{$slug}' could not be found in the Catalogue of Life database.

"; exit; } // Get the first result's taxon ID $taxon = $search_data['result'][0]; $taxon_id = $taxon['id']; // Query the classification for this taxon ID $classification_api_url = "https://api.checklistbank.org/dataset/9910/taxon/{$taxon_id}/classification"; $class_response = wp_remote_get($classification_api_url); $class_data = json_decode(wp_remote_retrieve_body($class_response), true); // Handle errors in classification response if (is_wp_error($class_response) || empty($class_data)) { echo "

Classification Not Found

"; echo "

Unable to retrieve classification information for '{$slug}' (ID: {$taxon_id}).

"; exit; } // Display taxon verification and classification echo "

Matched Taxon: {$taxon['scientificName']}

"; echo "

Taxon ID: {$taxon_id}

"; echo "

Rank: {$taxon['rank']}

"; echo "

Status: {$taxon['status']}

"; echo "

Classification

"; echo "
    "; foreach ($class_data as $item) { echo "
  • "; echo "Name: " . $item['name'] . "
    "; echo "Rank: " . $item['rank'] . "
    "; echo "
  • "; } echo "
"; ?>