<commit_before># Unsplash Source JS

A javascript wrapper for the Unsplash Source API. Get random Unsplash photos by keyword, category, user, or ID.

[ ![Codeship Status for CrewLabs/unsplash-source-js](https://codeship.com/projects/668ef1e0-6255-0133-355b-1af77e49650b/status?branch=master)](https://codeship.com/projects/112623)

## Usage

Include `unsplash-source.js` or `unsplash-source.min.js` in your page:

```html
<script src="/js/unsplash-source.js"></script>
```

Then build the photo you want using any of the options below.

Method | Arguments | Example | Description
-------|-----------|---------|------------
`find`|`"publicId"`|`photo.find("oMpAz-DN-9I")`|Finds a photo by its specific public ID
`width`|`width`|`photo.width(2000)`|Sets the width of the photo in pixels
`height`|`height`|`photo.height(2000)`|Sets the height of the photo in pixels
`size`|`width, height`|`photo.size(1080,800)`|Shorthand for setting the width and height of the photo in pixels
`randomize`|`null || "daily" || "weekly"`|`photo.randomize("weekly")`|Sets the randomization interval
`fromUser`|`"username"`|`photo.fromUser("erondu")`|Limits the photos to a specific photographer
`fromCategory`|`"category"`|`photo.fromCategory("nature")`|Limits the photos to a specific category

*Note*: Not all methods are compatible with each other. For example, trying to randomize a specific photo doesn't make sense. The wrapper will ignore incompatible methods and only construct URLs compatible with the Unsplash Source API.

## Examples

Get a random photo (the Unsplash Source API defaults to a width of 1080px):

```js<commit_msg>Simplify README's methods table<commit_after># Unsplash Source JS

A javascript wrapper for the Unsplash Source API. Get random Unsplash photos by keyword, category, user, or ID.

[ ![Codeship Status for CrewLabs/unsplash-source-js](https://codeship.com/projects/668ef1e0-6255-0133-355b-1af77e49650b/status?branch=master)](https://codeship.com/projects/112623)

## Usage

Include `unsplash-source.js` or `unsplash-source.min.js` in your page:

```html
<script src="/js/unsplash-source.js"></script>
```

Then build the photo you want using any of the chainable methods below.

Method | Arguments | Example | Description
-------|-----------|---------|------------
`find`|`"publicId"`|`photo.find("oMpAz-DN-9I")`|Finds a photo by its ID
`width`|`width`|`photo.width(2000)`|Sets the width in pixels
`height`|`height`|`photo.height(2000)`|Sets the height in pixels
`size`|`width, height`|`photo.size(1080,800)`|Shorthand for setting the width and height in pixels
`randomize`|`null || "daily" || "weekly"`|`photo.randomize("weekly")`|Sets the randomization interval
`fromUser`|`"username"`|`photo.fromUser("erondu")`|Limits to a specific photographer
`fromCategory`|`"category"`|`photo.fromCategory("nature")`|Limits to a specific category

*Note*: Not all methods are compatible with each other. For example, trying to randomize a specific photo doesn't make sense. The wrapper will ignore incompatible methods and only construct URLs compatible with the Unsplash Source API.

## Examples

Get a random photo (the Unsplash Source API defaults to a width of 1080px):

```js
{'fraction_non_alphanumeric': 0.15218073423282083, 'fraction_numerical': 0.031377470975839344, 'mean_word_length': 5.154440154440154, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1235219', 'n_tokens_mistral': 1080, 'n_tokens_neox': 984, 'n_words': 312}