The 4 clients represent the 4 authentication methods available, but you can also just call the action you want to perform directly and provide the appropriate connection options yourself. You'll notice in the docs for each action that there is a first parameter, connectionOptions, which isn't required when using the clients since they provide this for you based on the information used during instantiation. When using the action functions directly however, you need to provide the options yourself. Here is how these parameters were created for use in the examples of clientless usage below:

From ./examples/fixtures.ts#1~53

import { DEFAULT_API_URL, COMMON_HEADERS } from 'hypothesis-rest'
// ...
export const apiKeyHeaders = {
Authorization: `Bearer ${YOUR_API_KEY}`
}
export const authClientHeaders = {
Authorization: `Bearer ${AUTH_CLIENT_TOKEN}`
}
export const authClientForwardedUserHeaders = {
'X-Forwarded-User': AUTH_CLIENT_FORWARDED_USER_TOKEN
}

export const unauthenticatedConnectionOptions = {
apiUrl: DEFAULT_API_URL,
headers: COMMON_HEADERS
}
export const apiKeyConnectionOptions = {
apiUrl: DEFAULT_API_URL,
headers: { ...COMMON_HEADERS, ...apiKeyHeaders }
}
export const authClientConnectionOptions = {
apiUrl: DEFAULT_API_URL,
headers: { ...COMMON_HEADERS, ...authClientHeaders }
}
export const authClientForwardedUserConnectionOptions = {
apiUrl: DEFAULT_API_URL,
headers: { ...COMMON_HEADERS, ...authClientForwardedUserHeaders }
}

Examples

Fetch an Annotation unauthenticated

From ./examples/clientless/unauthenticated.test-d.ts#40~44

    expectType<Annotation>(
await fetchAnnotation(unauthenticatedConnectionOptions, ANNOTATION_ID)
)

Create an Annotation using an API key

From ./examples/clientless/apiKey.test-d.ts#60~64

    expectType<Annotation>(
await createAnnotation(apiKeyConnectionOptions, NEW_ANNOTATION)
)

Fetch a Group using an Auth Client

From ./examples/clientless/authClient.test-d.ts#40~44

    expectType<Group>(
await fetchGroup(authClientConnectionOptions, GROUP_ID)
)

Fetch the API root using an Auth Client Forwarded User

From ./examples/clientless/authClientForwardedUser.test-d.ts#20~24

    expectType<IndexResponse>(
await root(authClientForwardedUserConnectionOptions)
)

Generated using TypeDoc