Skip to main content

Figshare API v2 Python client with CLI

Project description

figshare-oai-pmh

PyPI - Version PyPI - Python Version PyPI - Downloads

Python client for the Figshare API v2 with a feature-rich command-line interface.

The library (openapi_client Python package) is auto-generated by OpenAPI Generator v7.9.0 and provides full coverage of the Figshare REST API (articles, collections, projects, authors, institutions, etc.).

On top of the generated client, this project adds a hand-written CLI (figshare command) for common tasks:

  • Fetch article metadata (JSON or TSV)
  • Download files by ID, by article, or in batch from a TSV file
  • Upload files to articles
  • MD5 verification and progress bars

NOTE: Do not edit files under openapi_client/, test/, or docs/ by hand — regenerate from the OpenAPI spec instead.

  • API version: 2.0
  • Package version: 1.0.3

Requirements

Python 3.8+

Installation

From PyPI

pip install figshare-oai-pmh

From source (Gitee)

pip install git+https://gitee.com/Billsfriend/figshare_oai_pmh.git

Editable (development)

git clone https://gitee.com/Billsfriend/figshare_oai_pmh.git
cd figshare_oai_pmh
pip install -e .

The package is then importable as openapi_client:

import openapi_client

Tests

pytest

CLI

A figshare command-line tool is installed as a console script. Auth via --token flag or FIGSHARE_TOKEN environment variable.

figshare metadata 123456                         # article metadata (JSON)
figshare metadata 123456 --files                 # file list as TSV
figshare download 789                            # single file by ID
figshare download 789 --article 123456           # with filename + MD5 check
figshare download --all 123456                   # all files in an article
figshare download --tsv files.tsv                # batch from TSV file
figshare metadata 123456 -f | figshare download --tsv -   # pipe TSV
figshare upload 123456 ~/paper.pdf               # upload (requires --token)

Run figshare --help for full usage.

Getting Started

Please follow the installation procedure and then run the following:

import openapi_client
from openapi_client.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to https://api.figshare.com/v2
# See configuration.py for a list of all supported configuration parameters.
configuration = openapi_client.Configuration(
    host = "https://api.figshare.com/v2"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

configuration.access_token = os.environ["ACCESS_TOKEN"]


# Enter a context with an instance of the API client
with openapi_client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = openapi_client.ArticlesApi(api_client)
    article_id = 56 # int | Article unique identifier

    try:
        # Private Article Publish
        api_response = api_instance.account_article_publish(article_id)
        print("The response of ArticlesApi->account_article_publish:\n")
        pprint(api_response)
    except ApiException as e:
        print("Exception when calling ArticlesApi->account_article_publish: %s\n" % e)

Documentation for API Endpoints

All URIs are relative to https://api.figshare.com/v2

Class Method HTTP request Description
ArticlesApi account_article_publish POST /account/articles/{article_id}/publish Private Article Publish
ArticlesApi account_article_report GET /account/articles/export Account Article Report
ArticlesApi account_article_report_generate POST /account/articles/export Initiate a new Report
ArticlesApi account_article_unpublish POST /account/articles/{article_id}/unpublish Public Article Unpublish
ArticlesApi article_details GET /articles/{article_id} View article details
ArticlesApi article_file_details GET /articles/{article_id}/files/{file_id} Article file details
ArticlesApi article_files GET /articles/{article_id}/files List article files
ArticlesApi article_version_confidentiality GET /articles/{article_id}/versions/{version_id}/confidentiality Public Article Confidentiality for article version
ArticlesApi article_version_details GET /articles/{article_id}/versions/{version_id} Article details for version
ArticlesApi article_version_embargo GET /articles/{article_id}/versions/{version_id}/embargo Public Article Embargo for article version
ArticlesApi article_version_files GET /articles/{article_id}/versions/{version_id}/files Public Article version files
ArticlesApi article_version_partial_update PATCH /account/articles/{article_id}/versions/{version_id} Partially update article version
ArticlesApi article_version_update PUT /account/articles/{article_id}/versions/{version_id} Update article version
ArticlesApi article_version_update_thumb PUT /account/articles/{article_id}/versions/{version_id}/update_thumb Update article version thumbnail
ArticlesApi article_versions GET /articles/{article_id}/versions List article versions
ArticlesApi articles_list GET /articles Public Articles
ArticlesApi articles_search POST /articles/search Public Articles Search
ArticlesApi private_article_author_delete DELETE /account/articles/{article_id}/authors/{author_id} Delete article author
ArticlesApi private_article_authors_add POST /account/articles/{article_id}/authors Add article authors
ArticlesApi private_article_authors_list GET /account/articles/{article_id}/authors List article authors
ArticlesApi private_article_authors_replace PUT /account/articles/{article_id}/authors Replace article authors
ArticlesApi private_article_categories_add POST /account/articles/{article_id}/categories Add article categories
ArticlesApi private_article_categories_list GET /account/articles/{article_id}/categories List article categories
ArticlesApi private_article_categories_replace PUT /account/articles/{article_id}/categories Replace article categories
ArticlesApi private_article_category_delete DELETE /account/articles/{article_id}/categories/{category_id} Delete article category
ArticlesApi private_article_confidentiality_delete DELETE /account/articles/{article_id}/confidentiality Delete article confidentiality
ArticlesApi private_article_confidentiality_details GET /account/articles/{article_id}/confidentiality Article confidentiality details
ArticlesApi private_article_confidentiality_update PUT /account/articles/{article_id}/confidentiality Update article confidentiality
ArticlesApi private_article_create POST /account/articles Create new Article
ArticlesApi private_article_delete DELETE /account/articles/{article_id} Delete article
ArticlesApi private_article_details GET /account/articles/{article_id} Article details
ArticlesApi private_article_download GET /account/articles/{article_id}/download Private Article Download
ArticlesApi private_article_embargo_delete DELETE /account/articles/{article_id}/embargo Delete Article Embargo
ArticlesApi private_article_embargo_details GET /account/articles/{article_id}/embargo Article Embargo Details
ArticlesApi private_article_embargo_update PUT /account/articles/{article_id}/embargo Update Article Embargo
ArticlesApi private_article_file GET /account/articles/{article_id}/files/{file_id} Single File
ArticlesApi private_article_file_delete DELETE /account/articles/{article_id}/files/{file_id} File Delete
ArticlesApi private_article_files_list GET /account/articles/{article_id}/files List article files
ArticlesApi private_article_partial_update PATCH /account/articles/{article_id} Partially update article
ArticlesApi private_article_private_link GET /account/articles/{article_id}/private_links List private links
ArticlesApi private_article_private_link_create POST /account/articles/{article_id}/private_links Create private link
ArticlesApi private_article_private_link_delete DELETE /account/articles/{article_id}/private_links/{link_id} Disable private link
ArticlesApi private_article_private_link_update PUT /account/articles/{article_id}/private_links/{link_id} Update private link
ArticlesApi private_article_reserve_doi POST /account/articles/{article_id}/reserve_doi Private Article Reserve DOI
ArticlesApi private_article_reserve_handle POST /account/articles/{article_id}/reserve_handle Private Article Reserve Handle
ArticlesApi private_article_resource POST /account/articles/{article_id}/resource Private Article Resource
ArticlesApi private_article_update PUT /account/articles/{article_id} Update article
ArticlesApi private_article_upload_complete POST /account/articles/{article_id}/files/{file_id} Complete Upload
ArticlesApi private_article_upload_initiate POST /account/articles/{article_id}/files Initiate Upload
ArticlesApi private_articles_list GET /account/articles Private Articles
ArticlesApi private_articles_search POST /account/articles/search Private Articles search
ArticlesApi public_article_download GET /articles/{article_id}/download Public Article Download
ArticlesApi public_article_version_download GET /articles/{article_id}/versions/{version_id}/download Public Article Version Download
AuthorsApi private_author_details GET /account/authors/{author_id} Author details
AuthorsApi private_authors_search POST /account/authors/search Search Authors
CollectionsApi collection_articles GET /collections/{collection_id}/articles Public Collection Articles
CollectionsApi collection_details GET /collections/{collection_id} Collection details
CollectionsApi collection_version_details GET /collections/{collection_id}/versions/{version_id} Collection Version details
CollectionsApi collection_versions GET /collections/{collection_id}/versions Collection Versions list
CollectionsApi collections_list GET /collections Public Collections
CollectionsApi collections_search POST /collections/search Public Collections Search
CollectionsApi private_collection_article_delete DELETE /account/collections/{collection_id}/articles/{article_id} Delete collection article
CollectionsApi private_collection_articles_add POST /account/collections/{collection_id}/articles Add collection articles
CollectionsApi private_collection_articles_list GET /account/collections/{collection_id}/articles List collection articles
CollectionsApi private_collection_articles_replace PUT /account/collections/{collection_id}/articles Replace collection articles
CollectionsApi private_collection_author_delete DELETE /account/collections/{collection_id}/authors/{author_id} Delete collection author
CollectionsApi private_collection_authors_add POST /account/collections/{collection_id}/authors Add collection authors
CollectionsApi private_collection_authors_list GET /account/collections/{collection_id}/authors List collection authors
CollectionsApi private_collection_authors_replace PUT /account/collections/{collection_id}/authors Replace collection authors
CollectionsApi private_collection_categories_add POST /account/collections/{collection_id}/categories Add collection categories
CollectionsApi private_collection_categories_list GET /account/collections/{collection_id}/categories List collection categories
CollectionsApi private_collection_categories_replace PUT /account/collections/{collection_id}/categories Replace collection categories
CollectionsApi private_collection_category_delete DELETE /account/collections/{collection_id}/categories/{category_id} Delete collection category
CollectionsApi private_collection_create POST /account/collections Create collection
CollectionsApi private_collection_delete DELETE /account/collections/{collection_id} Delete collection
CollectionsApi private_collection_details GET /account/collections/{collection_id} Collection details
CollectionsApi private_collection_patch PATCH /account/collections/{collection_id} Partially update collection
CollectionsApi private_collection_private_link_create POST /account/collections/{collection_id}/private_links Create collection private link
CollectionsApi private_collection_private_link_delete DELETE /account/collections/{collection_id}/private_links/{link_id} Disable private link
CollectionsApi private_collection_private_link_details GET /account/collections/{collection_id}/private_links/{link_id} View collection private link
CollectionsApi private_collection_private_link_update PUT /account/collections/{collection_id}/private_links/{link_id} Update collection private link
CollectionsApi private_collection_private_links_list GET /account/collections/{collection_id}/private_links List collection private links
CollectionsApi private_collection_publish POST /account/collections/{collection_id}/publish Private Collection Publish
CollectionsApi private_collection_reserve_doi POST /account/collections/{collection_id}/reserve_doi Private Collection Reserve DOI
CollectionsApi private_collection_reserve_handle POST /account/collections/{collection_id}/reserve_handle Private Collection Reserve Handle
CollectionsApi private_collection_resource POST /account/collections/{collection_id}/resource Private Collection Resource
CollectionsApi private_collection_update PUT /account/collections/{collection_id} Update collection
CollectionsApi private_collections_list GET /account/collections Private Collections List
CollectionsApi private_collections_search POST /account/collections/search Private Collections Search
InstitutionsApi account_group_custom_fields GET /account/groups/{group_id}/metadata/item Group custom fields
InstitutionsApi account_institution_curation GET /account/institution/review/{curation_id} Institution Curation Review
InstitutionsApi account_institution_curations GET /account/institution/reviews Institution Curation Reviews
InstitutionsApi custom_fields_list GET /account/institution/custom_fields Private account institution group custom fields
InstitutionsApi custom_fields_upload POST /account/institution/custom_fields/{custom_field_id}/items/upload Custom fields values files upload
InstitutionsApi get_account_institution_curation_comments GET /account/institution/review/{curation_id}/comments Institution Curation Review Comments
InstitutionsApi institution_articles GET /institutions/{institution_string_id}/articles/filter-by Public Institution Articles
InstitutionsApi institution_hrfeed_upload POST /institution/hrfeed/upload Private Institution HRfeed Upload
InstitutionsApi post_account_institution_curation_comments POST /account/institution/review/{curation_id}/comments POST Institution Curation Review Comment
InstitutionsApi private_account_institution_user GET /account/institution/users/{account_id} Private Account Institution User
InstitutionsApi private_categories_list GET /account/categories Private Account Categories
InstitutionsApi private_group_embargo_options_details GET /account/institution/groups/{group_id}/embargo_options Private Account Institution Group Embargo Options
InstitutionsApi private_institution_account GET /account/institution/accounts/{account_id} Private Institution Account information
InstitutionsApi private_institution_account_group_role_delete DELETE /account/institution/roles/{account_id}/{group_id}/{role_id} Delete Institution Account Group Role
InstitutionsApi private_institution_account_group_roles GET /account/institution/roles/{account_id} List Institution Account Group Roles
InstitutionsApi private_institution_account_group_roles_create POST /account/institution/roles/{account_id} Add Institution Account Group Roles
InstitutionsApi private_institution_accounts_create POST /account/institution/accounts Create new Institution Account
InstitutionsApi private_institution_accounts_list GET /account/institution/accounts Private Account Institution Accounts
InstitutionsApi private_institution_accounts_search POST /account/institution/accounts/search Private Account Institution Accounts Search
InstitutionsApi private_institution_accounts_update PUT /account/institution/accounts/{account_id} Update Institution Account
InstitutionsApi private_institution_articles GET /account/institution/articles Private Institution Articles
InstitutionsApi private_institution_details GET /account/institution Private Account Institutions
InstitutionsApi private_institution_embargo_options_details GET /account/institution/embargo_options Private Account Institution embargo options
InstitutionsApi private_institution_groups_list GET /account/institution/groups Private Account Institution Groups
InstitutionsApi private_institution_roles_list GET /account/institution/roles Private Account Institution Roles
OauthApi create_token POST /token Create OAuth token
OauthApi get_token_info GET /token Get OAuth token information
OtherApi categories_list GET /categories Public Categories
OtherApi file_download GET /file/download/{file_id} Public File Download
OtherApi item_types_list GET /item_types Item Types
OtherApi licenses_list GET /licenses Public Licenses
OtherApi private_account GET /account Private Account information
OtherApi private_funding_search POST /account/funding/search Search Funding
OtherApi private_licenses_list GET /account/licenses Private Account Licenses
ProfilesApi update_user_profile PUT /account/profile Update public profile
ProfilesApi update_user_profile_picture POST /account/profile/{user_id}/picture Update public profile picture
ProjectsApi private_project_article_delete DELETE /account/projects/{project_id}/articles/{article_id} Delete project article
ProjectsApi private_project_article_details GET /account/projects/{project_id}/articles/{article_id} Project article details
ProjectsApi private_project_article_file GET /account/projects/{project_id}/articles/{article_id}/files/{file_id} Project article file details
ProjectsApi private_project_article_files GET /account/projects/{project_id}/articles/{article_id}/files Project article list files
ProjectsApi private_project_articles_create POST /account/projects/{project_id}/articles Create project article
ProjectsApi private_project_articles_list GET /account/projects/{project_id}/articles List project articles
ProjectsApi private_project_collaborator_delete DELETE /account/projects/{project_id}/collaborators/{user_id} Remove project collaborator
ProjectsApi private_project_collaborators_invite POST /account/projects/{project_id}/collaborators Invite project collaborators
ProjectsApi private_project_collaborators_list GET /account/projects/{project_id}/collaborators List project collaborators
ProjectsApi private_project_create POST /account/projects Create project
ProjectsApi private_project_delete DELETE /account/projects/{project_id} Delete project
ProjectsApi private_project_details GET /account/projects/{project_id} View project details
ProjectsApi private_project_leave POST /account/projects/{project_id}/leave Private Project Leave
ProjectsApi private_project_note GET /account/projects/{project_id}/notes/{note_id} Project note details
ProjectsApi private_project_note_delete DELETE /account/projects/{project_id}/notes/{note_id} Delete project note
ProjectsApi private_project_note_update PUT /account/projects/{project_id}/notes/{note_id} Update project note
ProjectsApi private_project_notes_create POST /account/projects/{project_id}/notes Create project note
ProjectsApi private_project_notes_list GET /account/projects/{project_id}/notes List project notes
ProjectsApi private_project_partial_update PATCH /account/projects/{project_id} Partially update project
ProjectsApi private_project_publish POST /account/projects/{project_id}/publish Private Project Publish
ProjectsApi private_project_update PUT /account/projects/{project_id} Update project
ProjectsApi private_projects_list GET /account/projects Private Projects
ProjectsApi private_projects_search POST /account/projects/search Private Projects search
ProjectsApi project_articles GET /projects/{project_id}/articles Public Project Articles
ProjectsApi project_details GET /projects/{project_id} Public Project
ProjectsApi projects_list GET /projects Public Projects
ProjectsApi projects_search POST /projects/search Public Projects Search
SymplecticApi symplectic_account_articles GET /symplectic/accounts/{external_user_id}/articles Get articles for a specific account
SymplecticApi symplectic_accounts_ids GET /symplectic/accounts Get changed accounts for Symplectic Elements
SymplecticApi symplectic_article GET /symplectic/articles/{article_id} Get article details for Symplectic Elements
SymplecticApi symplectic_changed_articles GET /symplectic/articles Get changed articles for Symplectic Elements
SymplecticApi symplectic_user_id GET /symplectic/users/{user_id} Get institutional user ID for a user

Documentation For Models

Documentation For Authorization

Authentication schemes defined for the API:

OAuth2

Author

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

figshare_oai_pmh-1.0.4.tar.gz (160.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

figshare_oai_pmh-1.0.4-py3-none-any.whl (285.4 kB view details)

Uploaded Python 3

File details

Details for the file figshare_oai_pmh-1.0.4.tar.gz.

File metadata

  • Download URL: figshare_oai_pmh-1.0.4.tar.gz
  • Upload date:
  • Size: 160.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for figshare_oai_pmh-1.0.4.tar.gz
Algorithm Hash digest
SHA256 7bd43281fed54e40690547b8080dc92d71e7ac5a6c170b444fa7466759a38eb2
MD5 6d8cb810c24fb570e095a406686654f4
BLAKE2b-256 6e108b28c7e438bdf25cfd98b00f1442094febc142ebe2d523c0636f7c641dfc

See more details on using hashes here.

File details

Details for the file figshare_oai_pmh-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: figshare_oai_pmh-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 285.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.18 {"installer":{"name":"uv","version":"0.11.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for figshare_oai_pmh-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 005923fe37c0167a9baa48459d3f9fd6f0cd109f102781c0fc0e552e6bf0ce82
MD5 e3f1d8abc4d68a39b43c53835f20c903
BLAKE2b-256 ce08c281b209109154cb822ae3b74c04f5e97e3108261cc4175ef6635dd60862

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page