openalex

package
v0.35.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 24, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package openalex provides functions to convert Openalex metadata to the commonmeta metadata format.

Index

Constants

This section is empty.

Variables

View Source
var OAToCMMappings = map[string]string{
	"article":                 "Article",
	"book":                    "Book",
	"book-chapter":            "BookChapter",
	"dataset":                 "Dataset",
	"dissertation":            "Dissertation",
	"editorial":               "Document",
	"erratum":                 "Other",
	"grant":                   "Grant",
	"letter":                  "Article",
	"libguides":               "InteractiveResource",
	"other":                   "Other",
	"paratext":                "Component",
	"peer-review":             "PeerReview",
	"preprint":                "Article",
	"reference-entry":         "Other",
	"report":                  "Report",
	"retraction":              "Other",
	"review":                  "Article",
	"standard":                "Standard",
	"supplementary-materials": "Component",
}

OAToCMMappings maps OpenAlex types to Commonmeta types

View Source
var OpenAlexContainerTypes = map[string]string{
	"journal":       "Journal",
	"proceedings":   "Proceedings",
	"reference":     "Collection",
	"repository":    "Repository",
	"book-series":   "BookSeries",
	"book":          "Book",
	"report-series": "ReportSeries",
}

OpenAlexContainerTypes maps OpenAlex container types to Commonmeta container types

View Source
var OpenAlexIdentifierTypes = map[string]string{
	"openalex": "OpenAlex",
	"doi":      "DOI",
	"mag":      "MAG",
	"pmid":     "PMID",
	"pmcid":    "PMCID",
}

OpenAlexIdentifierTypes maps OpenAlex identifier types to Commonmeta identifier types

View Source
var OpenAlexLicenses = map[string]string{
	"cc-by": "CC-BY-4.0",
	"cc0":   "CC0-1.0",
}

OpenAlexLicenses maps OpenAlex license strings to SPDX licenseId

Functions

func GetAbstract

func GetAbstract(invertedIndex map[string][]int) string

GetAbstract extracts the abstract from OpenAlex's inverted index format

func GetContributors

func GetContributors(authorships []Authorship) []commonmeta.Contributor

GetContributors extracts contributor information from authorships

func GetFiles

func GetFiles(work *Work) []commonmeta.File

GetFiles extracts file information from a work

func GetRelated

func GetRelated(work *Work) commonmeta.Reference

GetRelated converts an OpenAlex work to a reference

Types

type Author

type Author struct {
	ID          string `json:"id"`
	DisplayName string `json:"display_name"`
	ORCID       string `json:"orcid"`
}

Author represents an author in OpenAlex

type Authorship

type Authorship struct {
	Author       Author        `json:"author"`
	Institutions []Institution `json:"institutions"`
}

Authorship represents author information in OpenAlex

type Biblio

type Biblio struct {
	Volume    string `json:"volume"`
	Issue     string `json:"issue"`
	FirstPage string `json:"first_page"`
	LastPage  string `json:"last_page"`
}

Biblio represents bibliographic information in OpenAlex

type Funder

type Funder struct {
	ID          string `json:"id"`
	DisplayName string `json:"display_name"`
	Ids         struct {
		ROR string `json:"ror"`
	} `json:"ids"`
}

Funder represents funder information in OpenAlex

type Grant

type Grant struct {
	Funder  string `json:"funder"`
	AwardID string `json:"award_id"`
}

Grant represents grant information in OpenAlex

type Institution

type Institution struct {
	ID          string `json:"id"`
	DisplayName string `json:"display_name"`
	ROR         string `json:"ror"`
}

Institution represents an institution in OpenAlex

type Location

type Location struct {
	LandingPageURL string `json:"landing_page_url"`
	PDFURL         string `json:"pdf_url"`
	Source         Source `json:"source"`
	License        string `json:"license"`
}

Location represents a location in OpenAlex

type Reader

type Reader struct {
	Email string // Email for polite pool of OpenAlex API
}

Reader struct to hold any configuration for the Openalex reader

func NewReader

func NewReader(email string) *Reader

NewReader creates a new OpenAlex reader

func (*Reader) APIURL

func (r *Reader) APIURL(id string, idType string) string

APIURL constructs a URL for accessing the OpenAlex API with a specific ID

func (*Reader) Fetch

func (r *Reader) Fetch(pid string) (commonmeta.Data, error)

Fetch retrieves and parses metadata from OpenAlex by ID

func (*Reader) FetchAll

func (r *Reader) FetchAll(number int, page int, publisher string, type_ string, sample bool, ids string, year string, ror string, orcid string, hasORCID bool, hasROR bool, hasReferences bool, hasRelation bool, hasAbstract bool, hasAward bool, hasLicense bool, hasArchive bool) ([]commonmeta.Data, error)

FetchAll retrieves and parses metadata from OpenAlex by query

func (*Reader) Get

func (r *Reader) Get(pid string) (*Work, error)

Get fetches a single work from OpenAlex based on ID

func (*Reader) GetAll

func (r *Reader) GetAll(number int, page int, publisher string, type_ string, sample bool, ids string, year string, ror string, orcid string, hasORCID bool, hasROR bool, hasReferences bool, hasRelation bool, hasAbstract bool, hasAward bool, hasLicense bool, hasArchive bool) ([]Work, error)

GetAll gets the metadata for a list of works from the OpenAlex API

func (*Reader) GetContainer

func (r *Reader) GetContainer(work *Work) commonmeta.Container

GetContainer extracts container information from a work

func (*Reader) GetFunders

func (r *Reader) GetFunders(ids []string) ([]Funder, error)

GetFunders fetches multiple funders from OpenAlex based on IDs

func (*Reader) GetSource

func (r *Reader) GetSource(sourceID string) (*Source, error)

GetSource fetches source information from OpenAlex

func (*Reader) GetWorks

func (r *Reader) GetWorks(ids []string) ([]Work, error)

GetWorks fetches multiple works from OpenAlex based on IDs

func (*Reader) ParseFunding

func (r *Reader) ParseFunding(grants []Grant) ([]commonmeta.FundingReference, error)

ParseFunding processes funding information from a work

func (*Reader) ParseReferences

func (r *Reader) ParseReferences(referencedWorks []string) ([]commonmeta.Reference, error)

ParseReferences fetches and processes references for a work

func (*Reader) QueryURL

func (r *Reader) QueryURL(number int, page int, publisher string, type_ string, sample bool, ids string, year string, orcid string, ror string, hasORCID bool, hasROR bool, hasReferences bool, hasRelation bool, hasAbstract bool, hasAward bool, hasLicense bool, hasArchive bool) string

QueryURL constructs a URL for querying the OpenAlex API

func (*Reader) Read

func (r *Reader) Read(work *Work) (commonmeta.Data, error)

Read OpenAlex response and return work struct in Commonmeta format

func (*Reader) ReadAll

func (r *Reader) ReadAll(works []Work) ([]commonmeta.Data, error)

ReadAll reads a list of OpenAlex JSON responses and returns a list of works in Commonmeta format

type Source

type Source struct {
	ID                   string `json:"id"`
	DisplayName          string `json:"display_name"`
	ISSN                 string `json:"issn_l"`
	Type                 string `json:"type"`
	HostOrganizationName string `json:"host_organization_name"`
	HomepageURL          string `json:"homepage_url"`
}

Source represents an OpenAlex source

type SubfieldTopic

type SubfieldTopic struct {
	DisplayName string `json:"display_name"`
}

SubfieldTopic represents a subfield topic in OpenAlex

type Topic

type Topic struct {
	ID       string        `json:"id"`
	Subfield SubfieldTopic `json:"subfield"`
}

Topic represents a topic in OpenAlex

type Work

type Work struct {
	ID                    string            `json:"id"`
	DOI                   string            `json:"doi"`
	Title                 string            `json:"title"`
	DisplayName           string            `json:"display_name"`
	Type                  string            `json:"type"`
	TypeCrossref          string            `json:"type_crossref"`
	PublicationDate       string            `json:"publication_date"`
	CreatedDate           string            `json:"created_date"`
	Language              string            `json:"language"`
	Version               string            `json:"version"`
	AbstractInvertedIndex map[string][]int  `json:"abstract_inverted_index"`
	AuthorShips           []Authorship      `json:"authorships"`
	Ids                   map[string]string `json:"ids"`
	PrimaryLocation       Location          `json:"primary_location"`
	BestOALocation        Location          `json:"best_oa_location"`
	Topics                []Topic           `json:"topics"`
	Biblio                Biblio            `json:"biblio"`
	ReferencedWorks       []string          `json:"referenced_works"`
	RelatedWorks          []string          `json:"related_works"`
	Grants                []Grant           `json:"grants"`
}

Work represents an OpenAlex work

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL