Skip to content

bibliofabric.osfpreprints

The OSF Preprints client (bibliofabric.osfpreprints) reads the preprint corpus and the provider network of the Open Science Framework: preprint records with files, citations, versions, contributors, and subjects, plus the preprint providers with their licenses, citation styles, subjects, and taxonomies. Every call returns typed Pydantic models, and an async client ships with a generated sync twin that exposes the same methods.

The upstream reference is the OSF APIv2 documentation.

Credentials

Public reads need no credentials. Pass an OSF personal token as api_key (environment variable OSFPREPRINTS_API_KEY) to read private preprints and provider moderation data; the token travels as Authorization: Bearer. The token-backed routes wrapped here (review_actions, moderators, subscriptions, withdraw_requests) answered 401 during development, so their response shapes are modeled from the API description only. The API documentation names the OSF terms of use (https://osf.io/terms_of_use/) as the governing terms and states no data license. The client paces itself at one request per second; the OSF API publishes no rate-limit contract.

Quick start

import asyncio

from bibliofabric.osfpreprints import OsfPreprintsClient, PreprintFilters


async def main() -> None:
    async with OsfPreprintsClient() as client:
        record = await client.preprints.get("muryv_v2")
        print(record.title, "-", record.provider_id)
        print("doi:", record.doi, "| landing page:", record.html_url)

        page = await client.preprints.search(
            PreprintFilters(provider="psyarxiv"),
            sort="-date_published",
            page_size=25,
        )
        print(f"{page.total} PsyArXiv preprints")
        for record in page.results[:2]:
            print(" ", record.id, "-", record.title)

        citation = await client.preprints.styled_citation("muryv_v2", "apa")
        print(citation.citation)

        providers = await client.providers.collect()
        print(
            f"{len(providers)} providers, e.g.", providers[0].id, "-", providers[0].name
        )

        provider_page = await client.providers.preprints("osf", page_size=25)
        print(f"osf provider serves {provider_page.total} preprints")


asyncio.run(main())
Free recall is sculpted by naturalistic event structure - psyarxiv
doi: 10.1017/S136672892610159X | landing page: https://osf.io/preprints/psyarxiv/muryv_v2/
67132 PsyArXiv preprints
  muryv_v2 - Free recall is sculpted by naturalistic event structure
  fmv6g_v1 - When I Create With Generative AI, Does It Still Feel Like Mine? Psychological Ownership in Human–AI Co-Creation: A Systematic Review and Meta-Analysis
Mavrou, I., Mavrou, S., & Kyriakou, A. (2026, November 29). Moral identity and language jointly influence how bilinguals feel and decide. https://doi.org/10.1017/S136672892610159X
32 providers, e.g. acctrt - Accounting Research & Thought
osf provider serves 78304 preprints

Totals move as new preprints arrive; the exact numbers above come from one run. search(page=) walks numbered pages (up to 100 records per page), and iterate() and collect() page through a whole result set, including past the first 100,000 records of a filter.

Sync quick start

OsfPreprintsSyncClient is generated from the async client and behaves the same: same resources, parameters, errors, and rate limits. It never starts or needs an event loop, so it works in scripts, Jupyter, and threads.

from bibliofabric.osfpreprints import OsfPreprintsSyncClient

with OsfPreprintsSyncClient() as client:
    record = client.preprints.get("muryv_v2")
    print(record.title, record.doi)

What the client covers

  • client.preprints: list and detail routes, plus the files, osfstorage file listing, citation, styled citation, contributors, identifiers, subjects, versions, institutions, and review actions of one preprint.
  • client.providers: the provider list and detail routes, plus each provider's preprints, licenses, citation styles, subjects, highlighted subjects, taxonomies, highlighted taxonomies, moderators, subscriptions, and withdrawal requests.

The API carries no server-side full-text search; narrowing happens through filters (see PreprintFilters). See upstream quirks for the details that shape these calls.