This script allows you to interact with your personal collections on Pexels. You can list all your collections and download all images from a specified collection with proper attributions.
- Node.js installed on your machine
- Pexels API key
-
Clone the repository:
git clone <repository_url> cd <repository_directory>
-
Install the required packages:
npm install
-
Copy the
.env.examplefile to.envin the root directory:cp .env.example .env
Then, open the
.envfile and add your Pexels API key:PEXELS_API_KEY=your_pexels_api_key_here
To list all your collections with their IDs and titles, run:
node index.js collectionsTo download all images from a specified collection, run:
node index.js pull <collection_id> <image_size><collection_id>: The ID of the collection you want to download.<image_size>: The size of the images you want to download (e.g.,original,large2x,large,medium,small,portrait,landscape,tiny).
Example:
node index.js pull 123456 large2x- Images will be downloaded to the
downloadsdirectory. - An
attributions.txtfile will be created in thedownloadsdirectory with a list of attributions to use, if needed.
- The script handles pagination to ensure all images from the collection are downloaded.
- Ensure you have sufficient API request limits to download large collections.
This project is licensed under the MIT License.