Skip to content

jamesgopsill/gtr-client

Repository files navigation

A TS client for the GtR API

GitHub package.json version GitHub repo size GitHub

GitHub package.json dynamic

GitHub package.json dynamic

This client is a fully-typed Typescript client for the UKRI's Gateway to Research GtR-2 API. It runs both on server (Node.js v18+) and client-side (Browser) javascript providing both ESM and CommonJS modules.

Contents

Getting Started

To install the package, use the following code (npm, pnpm or yarn).

pnpm install @jamesgopsill/gtr-client

You can then use package in your code like so (see the examples folder for more implementations):

Typescript

import {
	FundsQuery,
	FundsSearchFields,
	GtrClient,
} from "@jamesgopsill/gtr-client"

const client = new GtrClient(true)

const query: FundsQuery = {
	query: "epsrc",
	searchFields: [FundsSearchFields.FUNDER_ORGANISATION_NAME],
	pageSize: 10,
}

const r = await client.getFunds(query)
if (r.ok) console.log(r.data)

Javascript (ESM)

import { GtrClient, FundsSearchFields } from "@jamesgopsill/gtr-client"

const client = new GtrClient(true)

const query = {
	query: "epsrc",
	searchFields: [FundsSearchFields.FUNDER_ORGANISATION_NAME],
	pageSize: 10,
}

const r = await client.getFunds(query)
if (r.ok) console.log(r.data)

Javascript (CommonJS)

const gtr = require("@jamesgopsill/gtr-client")

const performQuery = async () => {
	const client = new gtr.GtrClient(true)

	const query = {
		query: "epsrc",
		searchFields: [gtr.FundsSearchFields.FUNDER_ORGANISATION_NAME],
		pageSize: 10,
	}

	const r = await client.getFunds(query)
	if (r.ok) console.log(r.data)
}

performQuery()

Docs

The docs have been produced using TypeDoc and can be accessed here.

Roadmap

Version Content Status
0.0.1 Repo up and running
0.2.0 /funds implemented.
0.3.0 /organisations implemented.
0.4.0 /outcomes implemented.
0.5.0 /persons implemented.
0.6.0 /projects implemented.
0.7.0 Simplified client using interface conditionals.
0.8.0 Refactored again to use programmatically defined functions.
0.9.0 Custom Filtering Param Interfaces
0.11.0 Changing how the response is handled.
1.0.0 Spec complete.
1.1.0 Updating types and supporting ESM and CommonJS.

Contributing

We would love to have additional contributors to the project to help us maintain and add functionality to the project. Please use pnpm pre-add before committing to the repository.

Note. if wanting to run the examples as you develop the repo. Use pnpm link . to link the repo to your available packages.

Support the Project

If you like this project, please consider sponsoring the developers so they can continue to maintain and improve the package.

References