Skip to content

API reference

Generated from the source with mkdocstrings.

Client

bibliofabric.osfpreprints.OsfPreprintsClient

Client for the OSF Preprints API (JSON:API, base /v2/).

Public reads need no credentials. Pass api_key (an OSF personal token) to read private preprints and provider moderation data; the token goes out as Authorization: Bearer.

preprints: PreprintsResource cached property

The preprints resource client.

providers: ProvidersResource cached property

The preprint provider resource client.

The sync twin OsfPreprintsSyncClient mirrors the client method for method and exports from the same module: from bibliofabric.osfpreprints import OsfPreprintsSyncClient.

Settings

bibliofabric.osfpreprints.OsfPreprintsSettings

OSF Preprints-specific client settings.

Inherits timeout, max_retries, max_retry_wait, max_requests_per_second, max_concurrency, user_agent and mailto from :class:bibliofabric.config.BaseApiSettings and sets OSF defaults (1 request per second, concurrency 2). Public reads need no credentials; the client never sends them without an api_key.

Resources

Each resource inherits the generic operations from bibliofabric.Resource (get, exists, search, iterate, collect, first, count; batch_get is disabled on the sub-resource clients). Only the members that OSF changes or adds are shown here.

Preprints

bibliofabric.osfpreprints.PreprintsResource

Client for the /preprints/ endpoint.

search(), iterate(), count(), and get() cover the list and detail routes. The sub-resource methods each walk their route to a full list; every one of them is small except where noted.

files(id: str) -> list[OsfFile] async

Return the storage root folders of one preprint.

The primary file record itself lives under storage_files() or the primary_file_id relationship.

storage_files(id: str) -> list[OsfFile] async

Return the files in the osfstorage root of one preprint.

The primary file (preprint.pdf and friends) appears here with its size, hashes, and version count.

citation(id: str) -> OsfCitation async

Return the citation facts of one preprint.

For a rendered citation string in a specific style, use styled_citation().

styled_citation(id: str, style: str = 'apa') -> OsfStyledCitation async

Return one preprint citation rendered in the given style id.

style is a citation style id such as "apa"; the ids a provider offers come from client.providers.citation_styles().

contributors(id: str) -> list[OsfContributor] async

Return every contributor entry of one preprint.

bibliographic_contributors(id: str) -> list[OsfContributor] async

Return the bibliographic contributor entries of one preprint.

Upstream serves the same records as contributors() for the preprints probed; the route exists separately for permission filtering.

identifiers(id: str) -> list[OsfIdentifier] async

Return the identifier records of one preprint.

The collection stays empty until the preprint's DOI is registered; the doi attribute of the preprint carries the DOI either way.

subjects(id: str) -> list[OsfSubject] async

Return the subject records of one preprint.

versions(id: str) -> list[OsfPreprint] async

Return every version record of one preprint, newest first.

Each version is a full preprint record with its own id suffix (muryv_v1, muryv_v2).

institutions(id: str) -> list[OsfInstitution] async

Return the affiliated institutions of one preprint.

The collection is empty for the preprints probed.

review_actions(id: str) -> list[OsfReviewAction] async

Return the review actions of one preprint.

Needs an api_key; the route answers 401 without credentials. The attribute shape is unverified against a live answer.

Preprint providers

bibliofabric.osfpreprints.ProvidersResource

Client for the /providers/preprints/ endpoints.

The list route serves all providers on one page (1000 records per page upstream). The sub-resource methods walk their route to a full list; taxonomies() walks about 13 pages of 100 for a provider with the full bepress tree.

preprints(id: str, filters: Filters = None, *, sort: str | Sequence[str] | None = None, page: int | None = None, page_size: int | None = None, on_error: OnError = 'raise', failures: list[ValidationError] | None = None, params: Mapping[str, Any] | None = None) -> Page[OsfPreprint] async

Fetch one page of one provider's preprints.

The filters and sorts are the same as the global /preprints/ route; pass PreprintFilters from this package.

citation_styles(id: str, *, default: bool | None = None) -> list[OsfCitationStyle] async

Return the citation styles one provider offers.

default=True narrows to the styles the provider marks as default; the flag's effect is unverified beyond a 200 answer.

licenses(id: str) -> list[OsfLicense] async

Return the licenses one provider accepts.

subjects(id: str) -> list[OsfSubject] async

Return the subject records one provider uses for submission.

highlighted_subjects(id: str) -> list[OsfSubject] async

Return the subjects one provider highlights on its discovery page.

taxonomies(id: str) -> list[OsfTaxonomy] async

Return the full bepress taxonomy tree entries of one provider.

highlighted_taxonomies(id: str) -> list[OsfTaxonomy] async

Return the taxonomy entries one provider highlights.

moderators(id: str) -> list[OsfModerator] async

Return the moderators of one provider.

Needs an api_key; the route answers 401 without credentials. The attribute shape is unverified against a live answer.

subscriptions(id: str) -> list[OsfSubscription] async

Return the notification subscriptions of one provider.

Needs an api_key; the shape is unverified against a live answer.

withdraw_requests(id: str) -> list[OsfWithdrawRequest] async

Return the withdrawal requests of one provider.

Needs an api_key; the shape is unverified against a live answer.

Filters

bibliofabric.osfpreprints.PreprintFilters

Filter model for the /preprints/ and provider preprint routes.

Every field here answered 200 in a live probe; the API rejects anything else with 400. subjects matches subject ids. Sequence values join with commas, booleans serialize lowercase.

bibliofabric.osfpreprints.ProviderFilters

Filter model for the /providers/preprints/ list route.

The API rejects unknown filters on this route too; name matched exactly in a live probe (osf does not match Open Science Framework).

Models

Record models the client returns; every attribute is optional, and attributes the API adds stay available as extras.

bibliofabric.osfpreprints.OsfPreprint

One OSF preprint record (one entry of a versions list too).

has_data_links and has_prereg_links are upstream strings with the values "yes", "no", "available", or "partially", not booleans.

provider_id: str | None property

The id of the preprint provider hosting this record.

primary_file_id: str | None property

The id of the primary file record.

node_id: str | None property

The id of the OSF project node backing this preprint, if any.

html_url: str | None property

The public landing page of the newest version.

bibliofabric.osfpreprints.OsfPreprintProvider

One OSF preprint provider (the legacy /preprint_providers/ alias serves the full attribute set).

The documented route /providers/preprints/ answers the same record minus banner_path, email_contact, header_text, logo_path, social_facebook, social_instagram, social_twitter, and subjects_acceptable; those fields are None there.

footer_links is an empty string when the provider has none and a list of link objects otherwise.

bibliofabric.osfpreprints.OsfFile

One OSF file or storage folder record.

Folder records carry kind="folder" with node, preprint, and provider naming the owner; file records carry kind="file" with size, guid, and current_version.

bibliofabric.osfpreprints.OsfCitation

The citation facts of one preprint (route /preprints/{id}/citation/).

The attributes carry type (the citation type, for example "webpage") in the same key the JSON:API envelope uses for its own resource type, so the attribute survives as citation_type.

bibliofabric.osfpreprints.OsfStyledCitation

One rendered citation string (route /preprints/{id}/citation/{style}/).

bibliofabric.osfpreprints.OsfContributor

One contributor entry of a preprint.

The contributor record carries the position and permission; the person record lives behind the users relationship and is not wrapped here.

user_id: str | None property

The id of the user record behind this contributor.

bibliofabric.osfpreprints.OsfSubject

One subject entry of a preprint or provider.

parent_id: str | None property

The id of the parent subject, if any.

bibliofabric.osfpreprints.OsfTaxonomy

One bepress taxonomy entry of a provider (route .../taxonomies/).

bibliofabric.osfpreprints.OsfLicense

One license a provider accepts (route .../licenses/).

bibliofabric.osfpreprints.OsfCitationStyle

One citation style a provider offers (route .../citation_styles/).

bibliofabric.osfpreprints.OsfIdentifier

One identifier record of a preprint (usually its registered DOI).

The collection is empty for most preprints; the doi attribute of the preprint itself carries the DOI whether or not this collection has entries. The attribute shape follows the API description and is unverified against a populated collection.

bibliofabric.osfpreprints.OsfInstitution

One institution affiliated with a preprint.

Every preprint probed answered an empty collection, so only name is modeled; the rest stays available as extras.

bibliofabric.osfpreprints.OsfReviewAction

One review action of a preprint (route needs a personal token).

The route answers 401 without credentials, so no attribute is modeled; validated fields stay available as extras. The shape is unverified against a live answer.

bibliofabric.osfpreprints.OsfModerator

One moderator entry of a provider (route needs a personal token).

The route answers 401 without credentials, so no attribute is modeled; validated fields stay available as extras. The shape is unverified against a live answer.

bibliofabric.osfpreprints.OsfSubscription

One notification subscription of a provider (route needs a token).

The shape is unverified against a live answer.

bibliofabric.osfpreprints.OsfWithdrawRequest

One withdrawal request of a provider (route needs a token).

The shape is unverified against a live answer.