https://github.com/devkiran/unsplash-node
https://github.com/devkiran/unsplash-node
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/devkiran/unsplash-node
- Owner: devkiran
- Archived: true
- Created: 2021-07-03T09:57:58.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-07-03T15:39:30.000Z (almost 5 years ago)
- Last Synced: 2024-10-04T16:41:29.912Z (over 1 year ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
### Unsplash API
```javascript
const api = new Unsplash({
access_key : ACCESS_KEY || process.env.ACCESS_KEY
});
// Search photos by keyword
api.searchPhotos({ query : 'earth' }).then((photos) => {
for (photo of photos.results) {
console.log(photo.id);
}
});
// Get a random photo
api.randomPhoto().then((photo) => {
console.log(photo);
});
// Get a photo by id
api.getPhoto({ photo_id : 'x8ZStukS2PM' }).then((photo) => {
console.log(photo);
});
```
```javascript
let photo1 = new Photo();
console.log(photo1.fromUser('erondu').size(500, 700).fetch());
// Fixed daily/weekly photo
let photo2 = new Photo();
console.log(photo2.weekly().fetch());
// Random from a user
let photo3 = new Photo();
console.log(photo3.fromUser('erondu').weekly().fetch());
// Random from a search term
let photo4 = new Photo();
console.log(photo4.search('sea').weekly().fetch());
// Random search term
let photo5 = new Photo();
console.log(photo5.featured().search('nature').fetch());
// Specific photo
let photo6 = new Photo('WLUHO9A_xik');
console.log(photo6.size(1600, 900).fetch());
```