Skip to content

wikipathways/wikipathways-iri-resolver

Repository files navigation

WikiPathways IRI Resolver

CI License: MIT

A lightweight Flask app that makes http://rdf.wikipathways.org/ IRIs resolvable by proxying requests as SPARQL DESCRIBE queries against the WikiPathways Virtuoso endpoint.

Features

  • HTTP content negotiation (HTML for browsers, RDF serializations for clients)
  • Syntax-highlighted HTML view with clickable IRIs
  • Multiple RDF formats: Turtle, JSON-LD, RDF/XML, N-Triples
  • File extension overrides (.ttl, .jsonld, .rdf, .nt)
  • In-memory response caching with configurable TTL
  • HTTP caching (ETag, If-None-Match → 304, Cache-Control, Vary: Accept)
  • CORS headers (Access-Control-Allow-Origin: *)
  • Prometheus metrics endpoint
  • Rate limiting per IP
  • Health check endpoint

Quick Start

pip

pip install -r requirements.txt
python app.py
# Dev server running on http://localhost:3000

Docker

docker build -t wpiri . && docker run -p 3000:3000 wpiri

Docker Compose

docker compose up

Usage

Browse in a browser

Open any IRI path to get a syntax-highlighted HTML view with clickable links:

Fetch RDF from the command line

# Turtle via Accept header
curl -H "Accept: text/turtle" http://localhost:3000/Pathway/WP4846_r140186/WP/Interaction/a273b

# Turtle via file extension
curl http://localhost:3000/Pathway/WP4846_r140186/WP/Interaction/a273b.ttl

# JSON-LD
curl http://localhost:3000/Pathway/WP4846_r140186/Complex/a4fdf.jsonld

# RDF/XML
curl http://localhost:3000/Pathway/WP4846_r140186.rdf

# N-Triples
curl http://localhost:3000/Pathway/WP4846_r140186.nt

Content Negotiation

Format Accept Header File Extension
HTML (default) text/html
Turtle text/turtle .ttl
JSON-LD application/ld+json .jsonld
RDF/XML application/rdf+xml .rdf
N-Triples application/n-triples .nt

Environment Variables

Variable Default Description
SPARQL_ENDPOINT https://sparql.wikipathways.org/sparql Virtuoso SPARQL endpoint URL
BASE_IRI http://rdf.wikipathways.org IRI prefix prepended to request path
SPARQL_TIMEOUT 30 SPARQL request timeout in seconds
CACHE_TTL 300 In-memory cache TTL in seconds
CACHE_MAXSIZE 1024 Maximum number of cached responses
CACHE_CONTROL_MAX_AGE 300 HTTP Cache-Control max-age in seconds
RATE_LIMIT 60/minute Rate limit per IP address

API Endpoints

Endpoint Description
/ Landing page with documentation and examples
/<path> Resolve an IRI and return RDF data
/_health Health check (returns 200 OK)
/metrics Prometheus metrics

Development

# Install dev dependencies
pip install -r requirements.txt
pip install pytest responses ruff

# Run tests
pytest -v

# Lint
ruff check .

Built With

This service was built with the help of Claude Code.

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published