Skip to content

Figshare

The Figshare client (bibliofabric.figshare) is a Python client for the Figshare API v2. It covers public articles (every item kind: datasets, figures, preprints, and so on), collections, projects, the vocabulary routes, downloads, and the public institution article filter. Every call returns a typed Pydantic model. It ships an async client and a generated sync twin with the same API. Install follows the setup guide.

Credentials

Public reads need no token. The optional FIGSHARE_API_TOKEN environment variable unlocks private item reads; the client sends it as an Authorization: token header. You can also pass it as a constructor argument, FigshareClient(api_token=...); an explicit argument wins over the environment value, and api_token="" forces anonymous access. The write routes (create, update, publish) need the token too and stay out of scope of this client. See settings for the FIGSHARE_ variables.

Quick start

import asyncio

from bibliofabric.figshare import FigshareClient, ITEM_TYPE_IDS


async def main():
    async with FigshareClient() as client:
        page = await client.articles.search(
            {"item_type": ITEM_TYPE_IDS["dataset"]},
            query="penguin tracking",
            sort="published_date:desc",
            page_size=5,
        )
        for article in page.results:
            print(article.id, article.doi, article.title)

        first = page.results[0]
        article = await client.articles.get(first.id)
        print("license:", article.license.name if article.license else None)
        print("authors:", [a.full_name for a in article.authors])

        newest = await client.articles.latest(page_size=3)
        print("newest:", [a.id for a in newest.results])

        collections = await client.collections.search(page_size=2)
        for collection in collections.results:
            articles = await client.collections.articles(collection.id, page_size=2)
            print("collection", collection.id, "->", len(articles.results), "articles")


asyncio.run(main())

The get() call accepts a bare id, a Figshare DOI (10.6084/m9.figshare.35160265 or the c. spelling of collection DOIs), a doi.org URL, or a figshare.com page URL, and returns a FigshareArticle. search() posts the flat search body of /articles/search; latest() walks the plain GET /articles list. Each item carries its license in the license field (for example CC BY 4.0); slim list entries leave it empty, so fetch the record for the license.

The script prints:

32664411 10.6084/m9.figshare.32664411.v1 Data from: Influence of Intrinsic Factors on At-Sea Behavior of Late Chick-Rearing Emperor Penguins (Aptenodytes forsteri) at Cape Crozier, Antarctica
32071113 10.3389/fmars.2026.1794894.s001 Supplementary file 3_Integrating climate storylines and time of emergence on vulnerability assessments: the case of crested penguins.docx
32071074 10.3389/fmars.2026.1794894.s002 Supplementary file 1_Integrating climate storylines and time of emergence on vulnerability assessments: the case of crested penguins.docx
32071038 10.3389/fmars.2026.1794894.s003 Supplementary file 2_Integrating climate storylines and time of emergence on vulnerability assessments: the case of crested penguins.docx
30384820 10.6084/m9.figshare.30384820.v1 <b>Navigating unpredictable oceans: Mapping fine-scale temporal and spatial variability in little penguin foraging areas</b>
license: CC BY 4.0
authors: ['Parker Forman', 'David R Thompson', 'Kimberly T. Goetz', 'Markus Horning', 'Matt H. Pinkerton', 'Birgitte I. McDonald']
newest: [35155510, 35139505, 35160622]
collection 8875231 -> 2 articles
collection 8875228 -> 1 articles

Datasets are item type 3

There is no /datasets route. Figshare serves every item kind through the article routes, and the kind travels in item_type (search and list) and defined_type (records). The ITEM_TYPE_IDS mapping names the ids, so ITEM_TYPE_IDS["dataset"] is 3.

Files and downloads

files = await client.articles.files(35160265)
for entry in files:
    print(entry.name, entry.size, entry.computed_md5)

dest = await client.articles.download_file(files[0].id, "penguino.zip")

download_file(), download(), and download_version() stream to disk through a redirect chain across ndownloader.figshare.com to the storage host and create parent directories. A download that fails midway leaves no partial file.

Sync quick start

FigshareSyncClient is generated from the async source and takes the same calls without async:

from bibliofabric.figshare import FigshareSyncClient

with FigshareSyncClient() as client:
    article = client.articles.get(35160265)
    print(article.title)

Deep paging

The offset wall sits at 5000: the start offset (page - 1) * page_size must stay at or under 5000, and the client rejects deeper requests with ConfigurationError before sending anything. Responses to the list and search routes carry an x-cursor header with an opaque token, and sending it back bypasses the wall and the documented 9,000-item retrieval limit. It only works as a request header: the same value as a query parameter or body key answers 400 "Cursor query context does not match". The client does not drive the cursor; walk it yourself through client.request():

import asyncio

from bibliofabric.figshare import FigshareClient


async def main():
    async with FigshareClient() as client:
        cursor = None
        seen = 0
        while seen < 400:
            headers = {"x-cursor": cursor} if cursor else None
            response = await client.request(
                "GET", "articles", params={"page_size": 100}, headers=headers
            )
            seen += len(response.json())
            cursor = response.headers.get("x-cursor")
        print(seen, "records")


asyncio.run(main())

Each round fetches 100 records; the loop reads the x-cursor header of each answer and sends it back as a header on the next request.

Pacing

Figshare enforces no automatic rate limit and asks callers to stay under one request per second. The client paces itself at 0.9 requests per second with concurrency 4 by default; both are tunable through the FIGSHARE_ settings. There are no totals: the list and search routes answer bare JSON arrays, so Page.total is always None and count() raises ConfigurationError. Use iterate() with a limit and count what you received.