# Gbif Species Occurrence Scraper (`kawsar/gbif-species-occurrence-scraper`) Actor

Search species records and observation data worldwide. Export clean datasets including coordinates, dates, and taxonomy as JSON, CSV, or Excel.

- **URL**: https://apify.com/kawsar/gbif-species-occurrence-scraper.md
- **Developed by:** [Kawsar](https://apify.com/kawsar) (community)
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.99 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## GBIF Scraper: Species & Occurrence Records

<p align="center">
  <img src="https://imgur.com/Gl5ZH2h.png" alt="GBIF Scraper" style="max-width:100%; border-radius:14px; width:680px;" />
</p>

Search and extract taxonomic records and biodiversity observation data directly from global biodiversity registries. Gather detailed taxonomic classifications, geographic coordinates, country codes, event dates, and ecological attributes into structured datasets ready for export as JSON, CSV, or Excel.

Instead of navigating complex database web interfaces, you can collect species checklists and occurrence records in bulk for research, analysis, and mapping projects.

### Use Cases

- **Taxon lookup:** Retrieve species matches and taxonomy data (such as kingdom, phylum, family, and genus) for targeted search terms.
- **Occurrence export:** Download species observation records complete with precise coordinates, country details, and event dates.
- **Country filtering:** Restrict occurrence extractions to specific ISO country codes for localized ecological studies.
- **Checklist cleanup:** Compare taxonomic status, rank, synonyms, and vernacular names across queries.
- **Research handoffs:** Collect structured biodiversity samples to share with colleagues or incorporate directly into analytical pipelines.

### Extracted Data Points

#### Species Records

- GBIF keys, dataset keys, and parent taxonomic references
- Scientific names, taxonomic ranks, and statuses
- Higher taxonomy classification (kingdom, phylum, class, family, genus)
- Checklist details including habitats, vernacular names, and descriptions

#### Occurrence Records

- Observation keys and scientific names
- Geographic coordinates (latitude and longitude)
- Country names, ISO codes, and event dates
- Basis of record and publishing dataset metadata

### Input Parameters

| Parameter | Type | Default | Description |
| --- | --- | --- | --- |
| `mode` | String | `species` | Operating mode (`species` to search taxa, `occurrences` to search observation records). |
| `query` | String | `python` | Search query (`q` in species mode, `scientificName` in occurrences mode). |
| `country` | String | empty | ISO 3166-1 alpha-2 country code (used exclusively in occurrences mode). |
| `maxItems` | Integer | `100` | Maximum number of data rows to save (up to 1,000). |
| `timeoutSecs` | Integer | `300` | Overall execution limit in seconds. |

#### Example Input

```json
{
  "mode": "occurrences",
  "query": "Python regius",
  "country": "BJ",
  "maxItems": 100,
  "timeoutSecs": 300
}

```

### Output Format

#### Species Output Example

```json
{
  "key": 315153173,
  "nameKey": 9591111,
  "datasetKey": "258e2ff4-0eae-4146-9a2b-4b411ee9c802",
  "nubKey": 2454645,
  "parentKey": 315153172,
  "parent": "Pythonidae",
  "kingdom": "Animalia",
  "phylum": "Chordata",
  "family": "Pythonidae",
  "genus": "Python",
  "recordKind": "species"
}

```

### How It Works

1. Processes configuration parameters, applying species or occurrence search criteria and country filters.
2. Paginates through query results efficiently while automatically skipping duplicate record keys.
3. Handles temporary network disruptions using structured retry intervals.
4. Records any unresolvable requests as clean error entries without interrupting the overall execution flow.
5. Generates export-ready datasets available instantly in JSON, CSV, or Excel formats.

### Frequently Asked Questions

**Can I filter occurrence records by country?**

Yes. Set the `country` parameter to a valid ISO 3166-1 alpha-2 code when running in `occurrences` mode.

**What happens if a query yields no results?**

An empty result set logs a completion note without generating error rows, allowing your workflow to finish cleanly.

**Can I export datasets directly to CSV or Excel?**

Yes. Completed datasets can be downloaded instantly in JSON, CSV, or Excel formats from your run overview.

***

### Legal & Compliance

#### Trademark Notice

GBIF Species Occurrence and related names, logos, and trademarks belong to their respective owners. Their mention in this documentation is strictly to identify data compatibility and utility, and does not imply affiliation, sponsorship, or endorsement.

#### Disclaimer

This tool is an independent utility and is not affiliated with, endorsed by, or officially connected to third-party biodiversity database providers. Users are responsible for ensuring their usage complies with relevant terms of service, attribution requirements, and local regulations.

#### Is web scraping legal?

This tool collects publicly available biodiversity records without bypassing access controls. Collecting public data is standard practice, but proper compliance requires considering how the data is used:

- **Personal data:** Ensure dataset usage respects regional privacy regulations (such as GDPR or CCPA) when combining outputs with personal user records.
- **Copyright & Terms:** Respect the terms of use, usage limits, and licensing terms set by data providers.
- **Legal advice:** This summary is provided for general informational purposes and does not constitute formal legal counsel.

To learn more, read Apify's guide: [Is web scraping legal?](https://blog.apify.com/is-web-scraping-legal/)

# Actor input Schema

## `mode` (type: `string`):

Which GBIF search to run. species returns taxon records. occurrences returns observation records with coordinates, country, and date when GBIF has them.

## `query` (type: `string`):

Search text. Species mode sends it as the q parameter. Occurrences mode sends it as scientificName, for example Python regius.

## `country` (type: `string`):

ISO 3166-1 alpha-2 country code used only in occurrences mode, for example KE or US. Leave empty to search all countries. Species mode ignores this field.

## `maxItems` (type: `integer`):

Maximum number of data rows to save. Values above 1000 are clamped to 1000.

## `timeoutSecs` (type: `integer`):

Stop the run after this many seconds, even if more pages remain.

## `requestTimeoutSecs` (type: `integer`):

How long to wait for a single GBIF response before retrying or recording an error.

## `proxyConfiguration` (type: `object`):

Optional proxy for GBIF requests. Leave Apify Proxy off. GBIF asks clients to identify themselves and to avoid rapid queries, so the actor does not use a proxy unless you turn one on.

## Actor input object example

```json
{
  "mode": "species",
  "query": "Python regius",
  "country": "BJ",
  "maxItems": 100,
  "timeoutSecs": 300,
  "requestTimeoutSecs": 30,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}
```

# Actor output Schema

## `datasetUrl` (type: `string`):

Default dataset API URL for this run.

## `overview` (type: `string`):

Table of saved species and occurrence rows.

## `occurrences` (type: `string`):

Occurrence rows with coordinates, country, and event date.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "mode": "species",
    "query": "python",
    "maxItems": 100,
    "timeoutSecs": 300,
    "requestTimeoutSecs": 30,
    "proxyConfiguration": {
        "useApifyProxy": false
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("kawsar/gbif-species-occurrence-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "mode": "species",
    "query": "python",
    "maxItems": 100,
    "timeoutSecs": 300,
    "requestTimeoutSecs": 30,
    "proxyConfiguration": { "useApifyProxy": False },
}

# Run the Actor and wait for it to finish
run = client.actor("kawsar/gbif-species-occurrence-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "mode": "species",
  "query": "python",
  "maxItems": 100,
  "timeoutSecs": 300,
  "requestTimeoutSecs": 30,
  "proxyConfiguration": {
    "useApifyProxy": false
  }
}' |
apify call kawsar/gbif-species-occurrence-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,kawsar/gbif-species-occurrence-scraper"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/dO5KucQMQUgTUHLP5/builds/4pXh5A4rSXLxEGck8/openapi.json
