https://github.com/datacite/pekingese
API for the Metadata Completeness Dashboard
https://github.com/datacite/pekingese
Last synced: 5 months ago
JSON representation
API for the Metadata Completeness Dashboard
- Host: GitHub
- URL: https://github.com/datacite/pekingese
- Owner: datacite
- Created: 2025-09-10T15:23:41.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2026-01-21T20:37:39.000Z (5 months ago)
- Last Synced: 2026-01-22T04:35:43.646Z (5 months ago)
- Language: Go
- Size: 55.7 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Metadata Completenesss API
API for the Metadata Completeness Dashboard
## Running Locally
### Set up OpenSearch Tunnel
The API requires a tunnel into OpenSearch. This can be set up using the instructions here: https://datacite.atlassian.net/wiki/spaces/DAT/pages/1038811137/How+to+SSH+tunnel+to+ElasticSearch.
You may need to prepend `0.0.0.0` to your local forward in the `.ssh/config` to allow Docker to connect to OpenSearch:
```
Host es-stage
...
LocalForward 0.0.0.0:9202 ...
```
### Start the API
1. `ssh es-stage`
2. `docker-compose --profile dev up` (in a separate terminal)
### Using the API
The API is served on `http://localhost:8080/`
_Currently there is only one endpoint at the root_
Example URL that fetches `present` and `distribution` aggregations for DataCite, along with a test query:
http://localhost:8080/?client_id=datacite.datacite&present=creators,creators.name&distribution=types.resourceTypeGeneral&query=test
**_Supported Query Parameters_**
- `client_id`: string
- `provider_id`: string
- `consortium_id`: string
- `query`: string
- `present`: []string - _comma separated list of fields for which to fetch the present/absent counts_
- `distribution`: []string - _comma separated list of fields for which to fetch the distribution values_
- `distribution_size`: number - _specifies the number of top results to return for each distribution field_
---
## Design Choices
### [net/http](https://pkg.go.dev/net/http) (Standard library for API routing)
I chose to use the standard `net/http` library because the needs for thes project are minimal. If it needs more features in the future - such as middleware or auth - I would switch to the [Chi](https://go-chi.io/#/) framework
### [defensestation/osquery](https://github.com/defensestation/osquery) (An idiomatic Go query builder for OpenSearch)
Without this package, writing OpenSearch queries in Go is quite tedious, especially if you need to do anything conditionally.