A Python application for exploring Swedish bird observations from Artportalen with dual API support: Real-time data via Artportalen API or historical data via GBIF API.
- π Search 116+ million bird observations from across Sweden
- β‘ Real-time data via Artportalen API (when configured)
- π Historical data via GBIF API (always available)
- π Smart API selection - automatically chooses the best API based on date range
- π Filter by date range and location (province/county)
- π View observation statistics and metrics
- πΊοΈ Interactive map showing observation locations
- πΎ Export observations to CSV format
- π― User-friendly Streamlit interface
- π GBIF API requires no API key - works out of the box!
For troubleshooting API issues, see:
docs/API_TROUBLESHOOTING.md- Complete guide for API discovery, format, and debuggingdocs/API_CHANGES_LOG.md- Log of API-related changes and fixes
Quick API Info:
- API Info Endpoint:
https://api.artdatabanken.se/species-observation-system/v1/api/ApiInfo - GitHub Documentation: https://github.com/biodiversitydata-se/SOS
- Search Filter Docs: https://github.com/biodiversitydata-se/SOS/blob/master/Docs/SearchFilter.md
This application accesses the Artportalen dataset, Sweden's national species observation system, through two APIs:
-
Artportalen API (Real-time)
- Update Frequency: ~10 minutes (near real-time)
- Coverage: Current day + recent observations
- Authentication: Required (API key from api-portal.artdatabanken.se)
- Best for: Recent observations (last 7-14 days)
-
GBIF API (Historical)
- Update Frequency: Weekly updates
- Coverage: Historical data (older than ~1 week)
- Authentication: None required (public API)
- Best for: Historical observations and when Artportalen API is not configured
- 116+ million observations of plants, animals, and fungi
- Open data (CC0 license) - ~93% of observations freely accessible
- Managed by SLU Artdatabanken (Swedish University of Agricultural Sciences)
- Dataset ID:
38b4c89f-584c-41bb-bd8f-cd1def33e92f
View on GBIF: https://www.gbif.org/dataset/38b4c89f-584c-41bb-bd8f-cd1def33e92f
- Python 3.11 or higher
- UV package manager
-
Clone the repository:
git clone <repository-url> cd birding-vibing
-
Install dependencies using UV:
uv sync
If you don't have UV installed, install it first:
curl -LsSf https://astral.sh/uv/install.sh | sh -
Configure Artportalen API (Optional):
For real-time data access, create a
.streamlit/secrets.tomlfile in the project root:mkdir -p .streamlit
Then create
.streamlit/secrets.tomlwith your API key:ARTPORTALEN_SLU_API_KEY = "your_api_key_here"
To obtain an API key:
- Register at api-portal.artdatabanken.se
- Subscribe to the observation API product
- Copy your API key to the
.streamlit/secrets.tomlfile
Note:
- The application works without the Artportalen API key - it will automatically use GBIF API for all queries. Artportalen API is only needed for real-time recent observations.
- Using
secrets.tomlis the recommended approach for Streamlit apps and simplifies deployment to Streamlit Community Cloud (you can paste the secrets directly in the deployment settings). - For backward compatibility, the app also checks environment variables if
secrets.tomlis not available.
Option 1: Using the run script (Linux/Mac)
./run.shOption 2: Using UV directly
uv run streamlit run src/app.py --server.port 8502Option 3: Manual activation
source .venv/bin/activate
streamlit run src/app.py --server.port 8502The application will open in your default web browser at http://localhost:8502.
-
Select Data Source (Optional):
- Auto: Automatically selects Artportalen for recent dates (last 7 days), GBIF for older dates
- Artportalen: Force use of Artportalen API (real-time data)
- GBIF: Force use of GBIF API (weekly updates)
-
Select Date Range:
- Choose start and end dates for your search
- Recent dates will automatically use Artportalen API if configured
-
Configure Search:
- Adjust the maximum number of results (10-300 for GBIF, up to 1000 for Artportalen)
- Optionally filter by Swedish province/county (e.g., "SkΓ₯ne", "Stockholm")
- Optionally filter by locality (city/town name)
-
Search and Explore:
- Click "π Search" to retrieve observations
- View which API was used (shown in results)
- View summary metrics (total observations, unique species, etc.)
- Browse the interactive table of observations
- View observation locations on the map
- Download results as CSV
birding-vibing/
βββ src/
β βββ __init__.py # Package initialization
β βββ app.py # Main Streamlit application
β βββ config.py # Configuration (dataset ID, API endpoints)
β βββ api/
β βββ __init__.py # API package initialization
β βββ gbif_client.py # GBIF API client
β βββ artportalen_client.py # Artportalen API client
β βββ unified_client.py # Smart API router
β βββ data_adapter.py # Data normalization adapter
βββ .streamlit/
β βββ secrets.toml # API keys (gitignored) - use secrets.toml.example as template
βββ .gitignore # Git ignore rules
βββ pyproject.toml # Project dependencies and metadata
βββ run.sh # Convenience script to run the app
βββ README.md # This file
This application uses the GBIF API for historical bird observation data:
- Base URL: https://api.gbif.org/v1
- Authentication: None required (public API)
- Rate Limits: Fair use policy, no hard limits for basic queries
- Max Results: 300 per request
- Update Frequency: Weekly
Key Parameters:
- datasetKey:
38b4c89f-584c-41bb-bd8f-cd1def33e92f(Artportalen dataset) - taxonKey:
212(Aves - all birds in GBIF backbone taxonomy) - country:
SE(Sweden)
For real-time observations, the application can use the Artportalen API:
- Base URL: https://api.artdatabanken.se/species-observation-system/v1
- Authentication: Required (API key via subscription)
- Update Frequency: ~10 minutes (near real-time)
- Max Results: Up to 1000 per request
- Coverage: Recent observations (typically last 7-14 days)
Setup:
- Register at api-portal.artdatabanken.se
- Subscribe to the observation API product
- Add API key to
.streamlit/secrets.tomlfile asARTPORTALEN_SLU_API_KEY(recommended) or as an environment variable for backward compatibility
- GBIF API Documentation
- GBIF API Beginner's Guide
- Artportalen Developer Portal
- Artportalen API Documentation
- Artportalen Website
uv add package-nameThe application is organized into modular components:
- config.py - Configuration constants (API URLs, dataset IDs, environment variables)
- api/gbif_client.py - GBIF API client
- api/artportalen_client.py - Artportalen API client
- api/unified_client.py - Smart API router that selects appropriate API
- api/data_adapter.py - Normalizes Artportalen responses to GBIF format
- app.py - Streamlit web interface
-
All birds in current year:
- Time Period: "Current year"
- Province: (leave empty)
- Click Search
-
Birds in Stockholm last 5 years:
- Time Period: "Last 5 years"
- Province: "Stockholm"
- Click Search
-
Birds in specific month:
- Time Period: "Custom range"
- Year: 2024-2024
- Month: "May"
- Click Search
"No observations found"
- Try expanding your date range
- Remove location filters
- Check that you're searching within valid years (data availability varies)
"Search failed: HTTP error"
- Check your internet connection
- API may be temporarily unavailable
- If using Artportalen API, verify your API key is correct and active
- Try again in a few moments
"Artportalen API not configured"
- This is normal if you haven't set up the Artportalen API key
- The app will automatically use GBIF API instead
- To enable real-time data, follow the Artportalen API setup instructions above
Application won't start
- Ensure all dependencies are installed:
uv sync - Check that you're using Python 3.11+:
python --version - Try running with
uv run streamlit run src/app.py
Map not showing
- Some observations may not have coordinate data
- Check if the results include Latitude/Longitude columns
- GBIF API limits results to 300 per request
- Artportalen API supports up to 1000 results per request
- For large datasets, use specific filters to narrow your search
- Download options are available for further analysis
- The dataset contains 116+ million observations, so filtering is essential
- Recent dates (last 7 days) automatically use Artportalen API for faster, real-time data
Contributions are welcome! Please feel free to submit issues or pull requests.
This project is open source. Please check the LICENSE file for details.
The data accessed through this application is published under CC0 1.0 (public domain dedication) by SLU Artdatabanken.
- Data provided by Artportalen and SLU Artdatabanken
- Data accessed via GBIF public API and Artportalen API
- Built with Streamlit
- Package management by UV
If you use this data in research or publications, please cite:
Artportalen (Swedish Species Observation System).
SLU Artdatabanken, Swedish University of Agricultural Sciences.
Accessed via GBIF.org on [date].
Dataset: https://www.gbif.org/dataset/38b4c89f-584c-41bb-bd8f-cd1def33e92f
For questions or support, please open an issue on the repository.
- GBIF Dataset: https://www.gbif.org/dataset/38b4c89f-584c-41bb-bd8f-cd1def33e92f
- Artportalen: https://www.artportalen.se/
- Artportalen Developer Portal: https://api-portal.artdatabanken.se/
- SLU Artdatabanken: https://www.artdatabanken.se/
- GBIF: https://www.gbif.org/