A CLI tool for searching and retrieving data from the Metropolitan Museum of Art API
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.
Documentation
Detailed documentation for this project is available on our GitLab Pages site:
https://cgs2824870.gitlab.io/mets/
Visit the documentation for in-depth information on installation, usage, API reference, and contribution guidelines.
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
- Primary method is to just install mets from PyPi:
pip install mets
- The alternative is to 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:
MetroSearch
: Handles API interactions with the Metropolitan Museum.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
- Clone the repository:
git clone https://gitlab.com/cgs2824870/mets.git cd mets
- Install the package in editable mode with development dependencies:
pip install -e .[test]
- Run tests:
pytest
License
This project is licensed under the MIT License - see the LICENSE file for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file mets-0.1.3.tar.gz
.
File metadata
- Download URL: mets-0.1.3.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d0cfcd2cfa28220615be5d1efe69c87a4a3c0de72eaadad25ba34b5b47283eaa |
|
MD5 | 092abad03050620f4f6f269519309930 |
|
BLAKE2b-256 | e658d97cb7cc57e8c0267a6c7ac1fae3c4816a7287f7bb79b839433feaece7a4 |
File details
Details for the file mets-0.1.3-py3-none-any.whl
.
File metadata
- Download URL: mets-0.1.3-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.4
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7ee05a9ced723e92c3baf11dba91c254676a461b9bec7acfd65e25aa5aa1ce6e |
|
MD5 | 38de2d9cc2e3f03acde7dedcb0c39db1 |
|
BLAKE2b-256 | 32849d834a606d59e99821ca645dadeb9eb3e5df4545fb7f46921484c91ee10e |