https://github.com/sno2/pex
An unofficial JavaScript (+ TypeScript) wrapper for the Pexels API.
https://github.com/sno2/pex
api-wrapper library nodejs pexels-api
Last synced: about 1 month ago
JSON representation
An unofficial JavaScript (+ TypeScript) wrapper for the Pexels API.
- Host: GitHub
- URL: https://github.com/sno2/pex
- Owner: sno2
- License: mit
- Created: 2021-04-06T03:13:56.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-03-16T20:10:22.000Z (over 2 years ago)
- Last Synced: 2025-10-01T12:59:47.766Z (9 months ago)
- Topics: api-wrapper, library, nodejs, pexels-api
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@sno2/pex
- Size: 1.71 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Pex
An unofficial JavaScript (+ TypeScript) wrapper for the Pexels API.
## Why?
You might be wondering why the heck we would have another Pexels wrapper if there already is an [official one](https://github.com/pexels/pexels-javascript). The answer to that is that the development for the main one is not that fast and I wanted to implement better types such as string literals `"small" | "medium" | "large"` instead of just `string`. Also, they don't have any documentation on how to actually use their API wrapper. Furthermore, their code is lacking JSDoc (or TSDoc) to provide tooltips for properties/methods/classes on how to use certain things and what they actually do.
## Getting Started
Pex has browser and Node.js support. You can check out how to use Pex for each of these runtimes below.
### Web Usage
To use Pex on the web, you can just load your corresponding script type located in the `dist` folder after running `npm run build`. However, if you want to just load it via a CDN such as unpkg you can include the following HTML before your JavaScript that uses `window.pex`:
```html
```
After that, you can just load in the `Pex` class as a UMD library on the `window` object:
```js
const { Pex } = window.pex; // sorta like require("@sno2/pex")
const pex = new Pex({ key: "YOUR_KEY" });
```
### Node.js Usage
It is extremely easy to use Pex on Node.js because all you need to do is run the following command to install Pex into your project:
```bash
npm i @sno2/pex
```
After that, you can import Pex like regular:
```js
const { Pex } = require("@sno2/pex"); // CommonJS
import { Pex } from "@sno2/pex"; // ES Module
```
## Docs
Check out the [full API docs](./docs/modules/index.md).
## License
[MIT](./LICENSE)