Skip to content

caltechlibrary/crossrefapi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

7796b4f · Jan 16, 2025
Jul 5, 2018
Sep 18, 2023
Jan 12, 2022
Feb 18, 2021
Jan 16, 2025
Jan 16, 2025
Mar 29, 2023
Jun 6, 2023
Feb 26, 2024
Jan 16, 2025
Jul 9, 2024
Jul 9, 2024
Mar 29, 2023
Jul 9, 2024
Jan 16, 2025
Jan 16, 2025
Jan 16, 2025
Feb 26, 2024
Jul 9, 2024
Mar 23, 2023
Jul 9, 2024
Jun 6, 2023
Jan 16, 2025
Jun 6, 2023
Jan 16, 2025
Jan 10, 2025
Jan 14, 2025
Jan 10, 2025
Jan 10, 2025
Jan 16, 2025
Jan 16, 2025
Jan 16, 2025
Mar 29, 2023
Jul 5, 2018
Jul 5, 2018
Mar 29, 2023
Jul 5, 2018
Jan 10, 2025
Jun 6, 2023
Mar 29, 2023
Jul 13, 2018
Jul 13, 2018
Jun 6, 2023
Mar 29, 2023
Jan 16, 2025
Feb 26, 2024
Jan 14, 2025
Jan 14, 2025
Jan 14, 2025
Mar 29, 2023

Repository files navigation

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, "[email protected]")
    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, "[email protected]")
    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="[email protected]" works "10.1037/0003-066x.59.1.29"

Reference