Skip to main content

A CLI tool for searching and retrieving data from the Metropolitan Museum of Art API

Reason this release was yanked:

obsolete

Project description

mets (MetroSearch)

mets is a command-line interface (CLI) tool for searching and retrieving data from the Metropolitan Museum of Art's public API.

User Documentation

Features

  • Search by title or tags only
  • Optional JSON output
  • Ascending / descending sort order by objectBeginDate
  • Asynchronous image downloading
  • Customizable image download path
  • Progress bar for downloads

Installation

  1. Clone the repository and build the package:
    git clone https://gitlab.com/cgs2824870/mets.git
    cd mets
    pip install .
    

Usage

python -m mets <search_term> [options]

Options:

  • -i, --images: Only return objects with images. Default: True
  • -n, --num: Maximum number of results to return. Default: 80
  • -s, --sort: Sort results by date (0: ascending, 1: descending, other: no sort). Default: 0
  • -o, --output: Output JSON filename. Prints to stdout if not provided.
  • -m, --time: Delay between API requests in seconds. Default: 0.001
  • -d, --download: Download object images
  • -p, --path: Folder to save downloaded images. Default: 'images'
  • -t, --title: Search in title only
  • -g, --tags: Search in tags only

Defaults:

  • Search performed by classification string by default
  • Only search for objects with images
  • Maximum number of objects to return is 80
  • Sort results by date ascending
  • Images are NOT downloaded by default
  • Default images output folder is 'images'

Example

python -m mets paintings
python -m mets sunflower -o out -d

This searches for objects containing "sunflower", returns up to 5 results sorted by date descending, saves the output to out.json, and downloads the associated images.

Developer Documentation

Project Structure

mets/
├── src/
│   └── mets/
│       ├── __init__.py
│       └── mets.py
├── tests/
│   └── test_mets.py
├── pyproject.toml
└── README.md

Architecture

mets consists of two main classes:

  1. MetroSearch: Handles API interactions with the Metropolitan Museum.
  2. MetroCLI: Manages the command-line interface and user interactions.

API Endpoints

  • Search: https://collectionapi.metmuseum.org/public/collection/v1/search
  • Object details: https://collectionapi.metmuseum.org/public/collection/v1/objects/[objectID]

Dependencies

  • httpx: For making HTTP requests
  • argparse: For parsing command-line arguments
  • asyncio: For asynchronous operations
  • aiofiles: For asynchronous file operations
  • tqdm: For progress bars

Development Setup

  1. Clone the repository:

    git clone https://gitlab.com/cgs2824870/mets.git
    cd mets
    
  2. Install the package in editable mode with development dependencies:

    pip install -e .[test]
    
  3. Run tests:

    pytest
    

License

This project is licensed under the MIT License - see the LICENSE file for details.

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

mets-0.1.2.tar.gz (8.0 kB view details)

Uploaded Source

Built Distribution

mets-0.1.2-py3-none-any.whl (7.6 kB view details)

Uploaded Python 3

File details

Details for the file mets-0.1.2.tar.gz.

File metadata

  • Download URL: mets-0.1.2.tar.gz
  • Upload date:
  • Size: 8.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for mets-0.1.2.tar.gz
Algorithm Hash digest
SHA256 49383e56fd5ee76be8b60ce7fac52048b2201584a02b46191bab5601d947a9b5
MD5 abbf3a7cbd952dd87a92e9650b5e5609
BLAKE2b-256 168822f717600c1142303ba09babfdf1ccacda62cff87d06df25958deb574efe

See more details on using hashes here.

File details

Details for the file mets-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: mets-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.4

File hashes

Hashes for mets-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a072eff2e768f505422d609222368124e800b925cc174e7fc1408432cf08adba
MD5 3e8a000988877d0b75fbb57e64b4698c
BLAKE2b-256 c8bdca312c84d45438c18bc45c5b2e253eafbfae653884dc6770c8104f0b969b

See more details on using hashes here.

Supported by

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