iceqi / pexels
Pexels API Client for www.pexels.com
Installs: 9
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 12
pkg:composer/iceqi/pexels
Requires
- php: >=5.4.0
- guzzlehttp/guzzle: ~5.1
This package is auto-updated.
Last update: 2025-10-04 18:52:37 UTC
README
Install
Install the Pexels API Client with Composer.
"require": { "glooby/pexels": "~0.1" },
Usage
Create an instance of the Pexels API Client by passing in your API token as parameter.
$pexels = new \Glooby\Pexels\Client("xxxxx");
Perform a search, the response gets returned as an array
$response = $pexels->search('london');
Loop trough photos and display them
$images = json_decode($pexels->search('london')->getBody())->images; foreach ($images as $image) { echo "<img src='{$image->src->small}' width='{$image->width}' heigth='{$image->height}'>" }
Example response
{
"total_results":6,
"page":1,
"per_page":15,
"photos":[
{
"id":57456,
"width":4000,
"height":3000,
"url":"https://www.pexels.com/photo/brown-rocky-mountain-painting-57456/",
"photographer":"Pixabay",
"src":{
"original":"https://static.pexels.com/photos/57456/torres-del-paine-mountains-granite-granite-rock-57456.jpeg",
"large":"https://static.pexels.com/photos/57456/torres-del-paine-mountains-granite-granite-rock-57456-large.jpeg",
"medium":"https://static.pexels.com/photos/57456/torres-del-paine-mountains-granite-granite-rock-57456-medium.jpeg",
"small":"https://static.pexels.com/photos/57456/torres-del-paine-mountains-granite-granite-rock-57456-small.jpeg",
"portrait":"https://static.pexels.com/photos/57456/torres-del-paine-mountains-granite-granite-rock-57456-portrait.jpeg",
"square":"https://static.pexels.com/photos/57456/torres-del-paine-mountains-granite-granite-rock-57456-square.jpeg",
"landscape":"https://static.pexels.com/photos/57456/torres-del-paine-mountains-granite-granite-rock-57456-landscape.jpeg",
"tiny":"https://static.pexels.com/photos/57456/torres-del-paine-mountains-granite-granite-rock-57456-tiny.jpeg"
}
}
]
}