crossrefapi

package module
v1.0.9 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2025 License: BSD-3-Clause Imports: 17 Imported by: 3

README

crossrefapi

This is a go package for working with the Crossref API. It is inspired by the an excellent CrossRefAPI Python package listed in the Crossref API docs. This package is meant to follow the "polite" guidelines for interacting with the public API at api.crossref.org.

Go package example

    appName := path.Base(os.Args[0])
    client, err := crossrefapi.NewCrossRefClient(appName, "jane.doe@library.example.edu")
    if err != nil {
        // handle error...
    }
    works, err := client.Works("10.1037/0003-066x.59.1.29")
   
    if err != nil {
        // handle error...
    }
    // continue processing your "works" result...

You can compare two copies of a "works" response and see what has changed.


    appName := path.Base(os.Args[0])
    client, err := crossrefapi.NewCrossRefClient(appName, "jane.doe@library.example.edu")
    if err != nil {
        // handle error...
    }
    newWorks, err := client.Works("10.1037/0003-066x.59.1.29")
    if err != nil {
        // handle error...
    }
    // Fetch our previously saved works document.
    src, err := os.ReadFile("0003-066x.59.1.29.json")
    if err != nil {
        // handle error...
    }
    oldWorks := new(crossrefapi.Works)
    if err := json.Unmarshal(src, &oldWorks); err != nil {
        // handle error...
    }
    src, err = oldWorks.DiffAsJSON(newWorks)
    if err != nil {
        // handle error...
    }
    fmt.Println("Diff for 10.1037/0003-066x.59.1.29")
    fmt.Printf("\n%s\n", src)

Command line example

    crossrefapi -mailto="jane.doe@library.example.edu" works "10.1037/0003-066x.59.1.29"

Reference

Documentation

Index

Constants

View Source
const (
	// Version number of release
	Version = "1.0.9"

	// ReleaseDate, the date version.go was generated
	ReleaseDate = "2025-01-16"

	// ReleaseHash, the Git hash when version.go was generated
	ReleaseHash = "dcaaa94"

	LicenseText = `` /* 1524-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func FmtHelp added in v1.0.3

func FmtHelp(src string, appName string, version string, releaseDate string, releaseHash string) string

FmtHelp lets you process a text block with simple curly brace markup.

func JsonDecode added in v1.0.6

func JsonDecode(src []byte, obj interface{}) error

Custom JSON decoder so we can treat numbers easier

func MarshalObject added in v1.0.6

func MarshalObject(obj interface{}, prefix string, indent string) ([]byte, error)

MarshalObject provide a custom json encoder to solve a an issue with HTML entities getting converted to UTF-8 code points by json.Marshal() in recent versions of go (~= go1.21).

Types

type Assertion added in v1.0.1

type Assertion struct {
	Group *Group `json:"group,omitempty"`
	Label string `json:"label,omitempty"`
	Name  string `json:"name,omitempty"`
	Value string `json:"value,omitempty"`
}

func (*Assertion) IsSame added in v1.0.1

func (a *Assertion) IsSame(t *Assertion) bool

type AwardFilter added in v1.0.8

type AwardFilter struct {
	Funder []string `key:"funder,omitempty"`
	Number []int    `key:"number,omitempty"`
}

type BoolParameter added in v1.0.8

type BoolParameter bool

BoolParameter overrides boolean text marshalling to comply with CrossRef API spec

func (BoolParameter) MarshalText added in v1.0.8

func (b BoolParameter) MarshalText() ([]byte, error)

type ClinicalTrailNumber added in v1.0.1

type ClinicalTrailNumber struct {
	ClinicalTrailNumber string `json:"clinical-trail-number,omitempty"`
	Registry            string `json:"registry,omitempty"`
	Type                string `json:"type,omitempty"`
}

func (*ClinicalTrailNumber) IsSame added in v1.0.1

type ContentDomain added in v1.0.1

type ContentDomain struct {
	Domain               []string `json:"domain,omitempty"`
	CrossmarkRestriction bool     `json:"crossmark-restriction,omitempty"`
}

func (*ContentDomain) IsSame added in v1.0.1

func (c *ContentDomain) IsSame(t *ContentDomain) bool

type CrossRefClient

type CrossRefClient struct {
	AppName           string
	MailTo            string `json:"mailto"`
	API               string `json:"api"`
	RateLimitLimit    int    `json:"limit"`
	RateLimitInterval int    `json:"interval"`
	LimitCount        int    `json:"limit_count"`
	Status            string
	StatusCode        int
	LastRequest       time.Time `json:"last_request"`
}

func NewCrossRefClient

func NewCrossRefClient(appName string, mailTo string) (*CrossRefClient, error)

NewCrossRefClient creates a client and makes a request and returns the JSON source as a []byte or error if their is a problem.

func (*CrossRefClient) QueryWorks added in v1.0.8

func (c *CrossRefClient) QueryWorks(query WorksQuery) (*WorksQueryResponse, error)

func (*CrossRefClient) Types

func (c *CrossRefClient) Types() (Object, error)

Types returns the list of supported types as a Object

func (*CrossRefClient) TypesJSON

func (c *CrossRefClient) TypesJSON() ([]byte, error)

TypesJSON return a list of types in JSON source

func (*CrossRefClient) Works

func (c *CrossRefClient) Works(doi string) (*Works, error)

Works return the Work unmarshaled into a Object (i.e. map[string]interface{})

func (*CrossRefClient) WorksJSON

func (c *CrossRefClient) WorksJSON(doi string) ([]byte, error)

WorksJSON return the work JSON source or error for a client and DOI

type DateObject added in v1.0.1

type DateObject struct {
	// DateParts holds a date an an array of Year, Month and Day integer values
	DateParts [][]int `json:"date-parts,omitempty"`
	// DateTime holds a date/time stamp, e.g. 2023-03-28T18:43:06.364Z
	DateTime string `json:"date-time,omitempty"`
	// Olds an integer representation of a timestamp, Unix epoch?
	Timestamp int64 `json:"timestamp,omitempty"`
}

DateObject is a date/timestamp/action timestamp of when something happened. It is used repeated in the message object

func (*DateObject) IsSame added in v1.0.1

func (do *DateObject) IsSame(t *DateObject) bool

IsSame checks if the date objects represent the same date. NOTE: if both objects are nil, they are considered the same.

type DateParameter added in v1.0.8

type DateParameter struct {
	Year  int32
	Month int32
	Day   int32
}

func (DateParameter) MarshalText added in v1.0.8

func (d DateParameter) MarshalText() ([]byte, error)

func (DateParameter) String added in v1.0.8

func (d DateParameter) String() string

type DateRange added in v1.0.1

type DateRange struct {
	StartDate *DateObject `json:"start-date,omitempty"`
	EndDate   *DateObject `json:"end-date,omitempty"`
}

func (*DateRange) IsSame added in v1.0.1

func (f *DateRange) IsSame(t *DateRange) bool

type FullTextFilter added in v1.0.8

type FullTextFilter struct {
	Type        []string `key:"type,omitempty"`
	Application []string `key:"application,omitempty"`
	Version     []string `key:"version,omitempty"`
}

type Funder added in v1.0.1

type Funder struct {
	Name          string   `json:"name,omitempty"`
	DOI           string   `json:"DOI,omitempty"`
	DoiAssertedBy string   `json:"doi-asserted-by,omitempty"`
	Award         []string `json:"award,omitempty"`
}

func (*Funder) IsSame added in v1.0.1

func (f *Funder) IsSame(t *Funder) bool

IsSame checks if two works object are the same. NOTE: if both objects are nil, they are considered the same.

type Group added in v1.0.1

type Group struct {
	Label string `json:"label,omitempty"`
	Name  string `json:"name,omitempty"`
}

func (*Group) IsSame added in v1.0.1

func (g *Group) IsSame(t *Group) bool

type Identifier added in v1.0.1

type Identifier struct {
	Label      string `json:"label,omitempty"`
	Name       string `json:"name,omitempty"`
	Type       string `json:"type,omitempty"`
	Value      string `json:"value,omitempty"`
	IdType     string `json:"id-type,omitempty"`
	Id         string `json:"id,omitempty"`
	AssertedBy string `json:"asserted-by,omitempty"`
}

func (*Identifier) IsSame added in v1.0.1

func (i *Identifier) IsSame(t *Identifier) bool

IsSame checks if two works object are the same. NOTE: if both objects are nil, they are considered the same.

type JournalIssue added in v1.0.1

type JournalIssue struct {
	Issue string `json:"issue,omitempty"`
}

func (*JournalIssue) IsSame added in v1.0.1

func (i *JournalIssue) IsSame(t *JournalIssue) bool

type License added in v1.0.1

type License struct {
	URL            string      `json:"URL,omitempty"`
	Start          *DateObject `json:"start,omitempty"`
	DelayInDays    int         `json:"delay-in-days,omitempty"`
	ContentVersion string      `json:"content-version,omitempty"`
}

func (*License) IsSame added in v1.0.1

func (lic *License) IsSame(t *License) bool

type LicenseFilter added in v1.0.8

type LicenseFilter struct {
	URL     []string `key:"url,omitempty"`
	Version []string `key:"version,omitempty"`
	Delay   []int    `key:"delay,omitempty"`
}

License represents license-specific filter parameters

type Link struct {
	URL                 string `json:"URL,omitempty"`
	ContentType         string `json:"content-type,omitempty"`
	ContentVersion      string `json:"content-version,omitempty"`
	IntendedApplication string `json:"intended-application,omitempty"`
}

func (*Link) IsSame added in v1.0.1

func (l *Link) IsSame(t *Link) bool

type Message added in v1.0.1

type Message struct {
	// Institutional information
	Institution []*Organization `json:"institution,omitempty"`
	// Indexed described when the work was last indexed
	Indexed *DateObject `json:"indexed,omitempty"`
	// Posted is when the work was posted to the API??
	Posted *DateObject `json:"posted,omitempty"`
	// PublisherLocation, where they are located as a string
	PublisherLocation string `json:"publisher-location,omitempty"`
	// UpdateTo ????
	UpdateTo []*Updated `json:"updated-to,omitempty"`
	// StandardsBody, ???
	StandardsBody       []*Organization        `json:"standards-body,omitempty"`
	EditionNumber       string                 `json:"edition-number,omitempty"`
	GroupTitle          string                 `json:"group-title,omitempty"`
	Publisher           string                 `json:"publisher,omitempty"`
	Issue               string                 `json:"issue,omitempty"`
	IsbnType            []*Identifier          `json:"isbn-type,omitempty"`
	License             []*License             `json:"license,omitempty"`
	Funder              []*Funder              `json:"funder,omitempty"`
	ContentDomain       *ContentDomain         `json:"content-domain,omitempty"`
	Chair               []*Person              `json:"chair,omitempty"`
	ShortContainerTitle []string               `json:"short-container-title,omitempty"`
	Accepted            *DateObject            `json:"accepted,omitempty"`
	ContentUpdated      *DateObject            `json:"content-updated,omitempty"`
	PublishedPrint      *DateObject            `json:"published-print,omitempty"`
	Abstract            string                 `json:"abstract,omitempty"`
	DOI                 string                 `json:"doi,omitempty"`
	Type                string                 `json:"type,omitempty"`
	Created             *DateObject            `json:"created,omitempty"`
	Approved            *DateObject            `json:"approved,omitempty"`
	Page                string                 `json:"page,omitempty"`
	UpdatePolicy        string                 `json:"update-policy,omitempty"`
	Source              string                 `json:"source,omitempty"`
	Title               []string               `json:"title,omitempty"`
	Prefix              string                 `json:"prefix,omitempty"`
	Volume              string                 `json:"volume,omitempty"`
	ClinicalTrailNumber *ClinicalTrailNumber   `json:"clinical-trail-number,omitempty"`
	Author              []*Person              `json:"author,omitempty"`
	Member              string                 `json:"member,omitempty"`
	ContentCreated      *DateObject            `json:"content-created,omitempty"`
	PublishedOnline     *DateObject            `json:"published-online,omitempty"`
	Reference           []*Reference           `json:"reference,omitempty"`
	ContainerTitle      []string               `json:"container-title,omitempty"`
	Review              *Review                `json:"review,omitempty"`
	OriginalTitle       []string               `json:"original-title,omitempty"`
	Language            string                 `json:"language,omitempty"`
	Link                []*Link                `json:"link,omitempty"`
	Deposited           *DateObject            `json:"deposited,omitempty"`
	Score               float32                `json:"score,omitempty"`
	Degree              string                 `json:"degree,omitempty"`
	SubTitle            []string               `json:"subtitle,omitempty"`
	Translator          []*Person              `json:"translator,omitempty"`
	FreeToRead          *DateRange             `json:"free-to-read,omitempty"`
	Editor              []*Person              `json:"editor,omitempty"`
	ComponentNumber     string                 `json:"component-number,omitempty"`
	ShortTitle          []string               `json:"short-title,omitempty"`
	Issued              *DateObject            `json:"issued,omitempty"`
	ISBN                []string               `json:"isbn,omitempty"`
	ReferenceCount      int                    `json:"reference-count,omitempty"`
	PartNumber          string                 `json:"part-number,omitempty"`
	JournalIssue        *JournalIssue          `json:"journal-issue,omitempty"`
	ArticleNumber       string                 `json:"article-number,omitempty"`
	AlternativeId       []string               `json:"alternative-id,omitempty"`
	URL                 string                 `json:"URL,omitempty"`
	Archive             []string               `json:"archive,omitempty"`
	Relation            map[string][]*Property `json:"relation,omitempty"`
	ISSN                []string               `json:"issn,omitempty"`
	IssnType            []*Identifier          `json:"issn-type,omitempty"`
	Subject             []string               `json:"subject,omitempty"`
	PublishedOther      *DateObject            `json:"published-other,omitempty"`
	Published           *DateObject            `json:"published,omitempty"`
	Assertion           []*Assertion           `json:"assertion,omitempty"`
}

func (*Message) Changes added in v1.0.1

func (msg *Message) Changes(t *Message) *Message

Changes takes the current Message, a new version of the Message and returns a Message object with the new Message object containing only the new elements.

func (*Message) Diff added in v1.0.1

func (msg *Message) Diff(t *Message) (*Message, *Message)

Diff takes the current Message, a new version of the Message and two Message objects one holding the old values and another holding the new values.

func (*Message) DiffAsJSON added in v1.0.1

func (msg *Message) DiffAsJSON(t *Message) ([]byte, error)

DiffAsJSON performs a Diff and returns the results as a JSON array where the first element (index 0) is the old object's values and the second (index 1) is the updated values

func (*Message) IsSame added in v1.0.1

func (msg *Message) IsSame(t *Message) bool

IsSame checks if two works object are the same. NOTE: if both objects are nil, they are considered the same.

type Object

type Object = map[string]interface{}

Object is the general holder of what get back after unmarshaling json

type Organization added in v1.0.1

type Organization struct {
	IDs        []*Identifier `json:"id,omitempty"`
	Name       string        `json:"name,omitempty"`
	Place      []string      `json:"place,omitempty"`
	Department []string      `json:"department,omitempty"`
	Acronym    []string      `json:"acronym,omitempty"`
}

func (*Organization) IsSame added in v1.0.1

func (org *Organization) IsSame(t *Organization) bool

IsSame checks if two works object are the same. NOTE: if both objects are nil, they are considered the same.

type Pagination added in v1.0.8

type Pagination struct {
	//The number of items returned in a single response (default is 20, and maximum is 1,000).
	Rows int64 `url:"rows,omitempty"`
	// offset parameter can be used to retrieve items starting from a specific index of the result list
	Offset int64 `url:"offset,omitempty"`
	// see "Deep-paging" section of CrossRef works API doc
	Cursor string `url:"cursor,omitempty"`
}

type Person added in v1.0.1

type Person struct {
	ORCID              string          `json:"ORCID,omitempty"`
	Suffix             string          `json:"suffix,omitempty"`
	Given              string          `json:"given,omitempty"`
	Family             string          `json:"family,omitempty"`
	Affiliation        []*Organization `json:"affiliation,omitempty"`
	Name               string          `json:"name,omitempty"`
	AuthenticatedOrcid bool            `json:"authenticated-orcid,omitempty"`
	Prefix             string          `json:"prefix,omitempty"`
	Sequence           string          `json:"sequence,omitempty"`
}

func (*Person) IsSame added in v1.0.1

func (p *Person) IsSame(t *Person) bool

type Property added in v1.0.1

type Property struct {
	IdType     string `json:"id-type,omitempty"`
	Id         string `json:"id,omitempty"`
	AssertedBy string `json:"asserted-by,omitempty"`
}

func (*Property) IsSame added in v1.0.1

func (p *Property) IsSame(t *Property) bool

type QuerySortOptions added in v1.0.8

type QuerySortOptions struct {
	Key   SortKey   `url:"sort,omitempty"`
	Order SortOrder `url:"order,omitempty"` // default is "desc"
}

type Reference added in v1.0.1

type Reference struct {
	ISSN               string `json:"issn,omitempty"`
	StandardsBody      string `json:"standards-body,omitempty"`
	Issue              string `json:"issue,omitempty"`
	Key                string `json:"key,omitempty"`
	SeriesTitle        string `json:"series-title,omitempty"`
	IsbnType           string `json:"isbn-type,omitempty"`
	DoiAssertedBy      string `json:"doi-asserted-by,omitempty"`
	FirstPage          string `json:"first-page,omitempty"`
	ISBN               string `json:"isbn,omitempty"`
	DOI                string `json:"doi,omitempty"`
	Component          string `json:"component,omitempty"`
	ArticleTitle       string `json:"article-title,omitempty"`
	VolumeTitle        string `json:"volume-title,omitempty"`
	Volume             string `json:"volume,omitempty"`
	Author             string `json:"author,omitempty"`
	StandardDesignator string `json:"standard-designator,omitempty"`
	Year               string `json:"year,omitempty"`
	Unstructured       string `json:"unstructured,omitempty"`
	Edition            string `json:"edition,omitempty"`
	JournalTitle       string `json:"journal-title,omitempty"`
	IssnType           string `json:"issn-type,omitempty"`
}

func (*Reference) IsSame added in v1.0.1

func (ref *Reference) IsSame(t *Reference) bool

IsSame checks of the reference object are the same. NOTE: if both objects are nil, they are considered the same.

type RelationFilter added in v1.0.8

type RelationFilter struct {
	Type       []string `key:"type,omitempty"`
	ObjectType []string `key:"object-type,omitempty"`
	Object     []string `key:"object,omitempty"`
}

Relation represents relation-specific filter parameters

type Review added in v1.0.1

type Review struct {
	Type                       string `json:"type,omitempty"`
	RunningNumber              string `json:"running-number,omitempty"`
	RevisionRound              string `json:"revision-round,omitempty"`
	Stage                      string `json:"stage,omitempty"`
	CompetingInterestStatement string `json:"competing-interest-statement,omitempty"`
	Recommendation             string `json:"recommendation,omitempty"`
	Language                   string `json:"language,omitempty"`
}

func (*Review) IsSame added in v1.0.1

func (r *Review) IsSame(t *Review) bool

type SortKey added in v1.0.8

type SortKey string
const (
	Created             SortKey = "created"
	Deposited           SortKey = "deposited"
	Indexed             SortKey = "indexed"
	IsReferencedByCount SortKey = "is-referenced-by-count"
	Issued              SortKey = "issued"
	Published           SortKey = "published"
	PublishedOnline     SortKey = "published-online"
	PublishedPrint      SortKey = "published-print"
	ReferencesCount     SortKey = "references-count"
	Relevance           SortKey = "relevance"
	Score               SortKey = "score"
	LastUpdate          SortKey = "updated" // renamed from `Updated` to avoid name collision
)

type SortOrder added in v1.0.8

type SortOrder string
const (
	Asc  SortOrder = "asc"
	Desc SortOrder = "desc"
)

type Updated added in v1.0.1

type Updated struct {
	Label   string      `json:"label,omitempty"`
	DOI     string      `json:"doi,omitempty"`
	Type    string      `json:"type,omitempty"`
	Updated *DateObject `json:"updated,omitempty"`
}

func (*Updated) IsSame added in v1.0.1

func (u *Updated) IsSame(t *Updated) bool

type Works added in v1.0.1

type Works WorksResponse[Message]

Works is a representation retrieved the CrossRef REST API using the Works path and a DOI. This is based on documentaiton at https://api.crossref.org/swagger-ui/index.html#/Works/get_works__doi_ Captured on 2023-03-28, RSD

NOTE: structure in documentation appears wrong, my test records indicate that some things listed as array of string are really just strings and visa versa.

func (*Works) Diff added in v1.0.1

func (work *Works) Diff(t *Works) (*Works, *Works)

Diff works returns the fields that differ

func (*Works) DiffAsJSON added in v1.0.1

func (work *Works) DiffAsJSON(t *Works) ([]byte, error)

DiffAsJSON performs a Diff and returns the results as a JSON array where the first element (index 0) is the old object's values and the second (index 1) is the updated values

func (*Works) IsSame added in v1.0.1

func (work *Works) IsSame(t *Works) bool

IsSame checks if two works object have the same content. NOTE: if both are nil then true is returned. Only compares the works' type and message attributes are compared.

type WorksFilter added in v1.0.8

type WorksFilter struct {
	AlternativeID  []string `key:"alternative-id,omitempty"`
	Archive        []string `key:"archive,omitempty"`
	ArticleNumber  []string `key:"article-number,omitempty"`
	Assertion      []string `key:"assertion,omitempty"`
	AssertionGroup []string `key:"assertion-group,omitempty"`

	// Award related fields
	Award *AwardFilter `key:"award,omitempty"`

	CategoryName        []string `key:"category-name,omitempty"`
	CitationID          []string `key:"citation-id,omitempty"`
	ClinicalTrialNumber []string `key:"clinical-trial-number,omitempty"`
	ContainerTitle      []string `key:"container-title,omitempty"`
	ContentDomain       []string `key:"content-domain,omitempty"`
	DOI                 []string `key:"doi,omitempty"`

	// From date fields
	FromAcceptedDate   []DateParameter `key:"from-accepted-date,omitempty"`
	FromApprovedDate   []DateParameter `key:"from-approved-date,omitempty"`
	FromAwardedDate    []DateParameter `key:"from-awarded-date,omitempty"`
	FromCreatedDate    []DateParameter `key:"from-created-date,omitempty"`
	FromDepositDate    []DateParameter `key:"from-deposit-date,omitempty"`
	FromEventEndDate   []DateParameter `key:"from-event-end-date,omitempty"`
	FromEventStartDate []DateParameter `key:"from-event-start-date,omitempty"`
	FromIndexDate      []DateParameter `key:"from-index-date,omitempty"`
	FromIssuedDate     []DateParameter `key:"from-issued-date,omitempty"`
	FromOnlinePubDate  []DateParameter `key:"from-online-pub-date,omitempty"`
	FromPostedDate     []DateParameter `key:"from-posted-date,omitempty"`
	FromPrintPubDate   []DateParameter `key:"from-print-pub-date,omitempty"`
	FromPubDate        []DateParameter `key:"from-pub-date,omitempty"`
	FromUpdateDate     []DateParameter `key:"from-update-date,omitempty"`

	// Full text related fields
	FullText *FullTextFilter `key:"full-text,omitempty"`

	// Other fields
	Funder              []string `key:"funder,omitempty"`
	FunderDoiAssertedBy []string `key:"funder-doi-asserted-by,omitempty"`
	GroupTitle          []string `key:"group-title,omitempty"`

	// Boolean flags
	// No point supporting multiple filter values as array here
	HasAbstract            *BoolParameter `key:"has-abstract"`
	HasAffiliation         *BoolParameter `key:"has-affiliation"`
	HasArchive             *BoolParameter `key:"has-archive"`
	HasAssertion           *BoolParameter `key:"has-assertion"`
	HasAuthenticatedOrcid  *BoolParameter `key:"has-authenticated-orcid"`
	HasAward               *BoolParameter `key:"has-award"`
	HasClinicalTrialNumber *BoolParameter `key:"has-clinical-trial-number"`
	HasContentDomain       *BoolParameter `key:"has-content-domain"`
	HasDescription         *BoolParameter `key:"has-description"`
	HasDomainRestriction   *BoolParameter `key:"has-domain-restriction"`
	HasEvent               *BoolParameter `key:"has-event"`
	HasFullText            *BoolParameter `key:"has-full-text"`
	HasFunder              *BoolParameter `key:"has-funder"`
	HasFunderDoi           *BoolParameter `key:"has-funder-doi"`
	HasLicense             *BoolParameter `key:"has-license"`
	HasOrcid               *BoolParameter `key:"has-orcid"`
	HasReferences          *BoolParameter `key:"has-references"`
	HasRelation            *BoolParameter `key:"has-relation"`
	HasRorID               *BoolParameter `key:"has-ror-id"`
	HasUpdate              *BoolParameter `key:"has-update"`
	HasUpdatePolicy        *BoolParameter `key:"has-update-policy"`
	IsUpdate               *BoolParameter `key:"is-update"`

	// ISBN/ISSN
	ISBN []string `key:"isbn,omitempty"`
	ISSN []string `key:"issn,omitempty"`

	// License fields
	License *LicenseFilter `key:"license,omitempty"`

	// Award amount
	GteAwardAmount int `key:"gte-award-amount,omitempty"`
	LteAwardAmount int `key:"lte-award-amount,omitempty"`

	// Member and identifiers
	Member []string `key:"member,omitempty"`
	ORCID  []string `key:"orcid,omitempty"`
	Prefix []string `key:"prefix,omitempty"`

	// Relation fields
	Relation *RelationFilter `key:"relation,omitempty"`

	// Type fields
	RorID    []string `key:"ror-id,omitempty"`
	Type     []string `key:"type,omitempty"`
	TypeName []string `key:"type-name,omitempty"`

	// Until date fields
	UntilAcceptedDate   []DateParameter `key:"until-accepted-date,omitempty"`
	UntilApprovedDate   []DateParameter `key:"until-approved-date,omitempty"`
	UntilAwardedDate    []DateParameter `key:"until-awarded-date,omitempty"`
	UntilCreatedDate    []DateParameter `key:"until-created-date,omitempty"`
	UntilDepositDate    []DateParameter `key:"until-deposit-date,omitempty"`
	UntilEventEndDate   []DateParameter `key:"until-event-end-date,omitempty"`
	UntilEventStartDate []DateParameter `key:"until-event-start-date,omitempty"`
	UntilIndexDate      []DateParameter `key:"until-index-date,omitempty"`
	UntilIssuedDate     []DateParameter `key:"until-issued-date,omitempty"`
	UntilOnlinePubDate  []DateParameter `key:"until-online-pub-date,omitempty"`
	UntilPostedDate     []DateParameter `key:"until-posted-date,omitempty"`
	UntilPrintPubDate   []DateParameter `key:"until-print-pub-date,omitempty"`
	UntilPubDate        []DateParameter `key:"until-pub-date,omitempty"`
	UntilUpdateDate     []DateParameter `key:"until-update-date,omitempty"`

	// Update fields
	UpdateType []string `key:"update-type,omitempty"`
	Updates    []string `key:"updates,omitempty"`
}

WorksFilter represents the available filter parameters for the /works endpoint

func (WorksFilter) Encode added in v1.0.8

func (f WorksFilter) Encode() string

type WorksQuery added in v1.0.8

type WorksQuery struct {
	// General query string
	// Note: as stated in CrossRef API docs,
	// Fields.Bibliographic SHOULD be preferred
	// whenever the search query is a partial or full reference
	// (e.g. including authors, date, title, ...)
	FreeFormQuery string
	// Structured query on specific metadata
	Fields *WorksQueryFields
	// Results pagination
	Pagination *Pagination
	// Results filtering
	// Filters on different keys are applied with AND semantic.
	// Filters on the same key are applied with OR semantic.
	Filters *WorksFilter
	// Results projection.
	// Restrict the API results to a subset of fields.
	// See API docs for available fields
	Elements []string
}

WorksQuery represents a query for works in the CrossRef API. See https://api.crossref.org/swagger-ui/index.html#/Works/get_works.

func (WorksQuery) Encode added in v1.0.8

func (q WorksQuery) Encode() (values url.Values, err error)

type WorksQueryFields added in v1.0.8

type WorksQueryFields struct {
	Affiliation          string `url:"query.affiliation,omitempty"`
	Author               string `url:"query.author,omitempty"`
	Bibliographic        string `url:"query.bibliographic,omitempty"`
	Chair                string `url:"query.chair,omitempty"`
	ContainerTitle       string `url:"query.container-title,omitempty"`
	Contributor          string `url:"query.contributor,omitempty"`
	Degree               string `url:"query.degree,omitempty"`
	Description          string `url:"query.description,omitempty"`
	Editor               string `url:"query.editor,omitempty"`
	EventAcronym         string `url:"query.event-acronym,omitempty"`
	EventLocation        string `url:"query.event-location,omitempty"`
	EventName            string `url:"query.event-name,omitempty"`
	EventTheme           string `url:"query.event-theme,omitempty"`
	FunderName           string `url:"query.funder-name,omitempty"`
	PublisherLocation    string `url:"query.publisher-location,omitempty"`
	PublisherName        string `url:"query.publisher-name,omitempty"`
	StandardsBodyAcronym string `url:"query.standards-body-acronym,omitempty"`
	StandardsBodyName    string `url:"query.standards-body-name,omitempty"`
	Title                string `url:"query.title,omitempty"`
	Translator           string `url:"query.translator,omitempty"`
}

WorksQueryFields represents the fields that can be queried in the CrossRef API

type WorksQueryMessage added in v1.0.8

type WorksQueryMessage struct {
	ItemsPerPage int64 `json:"items-per-page"`
	Query        struct {
		StartIndex  int64  `json:"start-index"`
		SearchTerms string `json:"search-terms"`
	} `json:"query"`
	TotalResults int64     `json:"total-results"`
	NextCursor   string    `json:"next-cursor,omitempty"`
	Items        []Message `json:"items,omitempty"`
}

type WorksQueryResponse added in v1.0.8

type WorksQueryResponse WorksResponse[WorksQueryMessage]

type WorksResponse added in v1.0.8

type WorksResponse[Message any] struct {
	Status         string   `json:"status,omitempty"`
	MessageType    string   `json:"message-type,omitempty"`
	MessageVersion string   `json:"message-version,omitempty"`
	Message        *Message `json:"message,omitempty"`
}

WorksResponse is a generic type to represent responsed from the /works endpoint

Directories

Path Synopsis
cmd
crossrefapi
crossrefapi.go is a command line tool for access the CrossRef API given a specific DOI.
crossrefapi.go is a command line tool for access the CrossRef API given a specific DOI.

Jump to

Keyboard shortcuts

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