Image Fetch

HTTP Requests / Image Fetch

On this page:
Intro ▾
{{activeSubMenu.text}} ▾
POST https://api.pixaven.com/1.0/fetch
Description
No POST fields are expected by this endpoint. Body of the request must consist of serialized JSON data.

Image Fetch uses the https://api.pixaven.com/1.0/fetch endpoint and allows you to provide a publicly available image URL for processing. That endpoint only accepts serialized JSON data with image processing steps along with a url property pointing to the image you want to process. Please be sure to set application/json as the Content-Type of your requests to the Image Fetch endpoint.

Requests fetching your images will come from the following IP address range: 212.224.84.128/26 and will have Pixaven/1.0 User-Agent set in the headers.

If your assets are protected with HTTP Basic Auth, you may include a username and password as part of the image URL: https://user:pass@www.website.com/image.jpg

An example cURL request to the Image Fetch endpoint would look like the following:

curl https://api.pixaven.com/1.0/fetch -X POST -u your-api-key: \
-H "Content-Type: application/json" \
-d '{
    "url": "https://www.website.com/image.jpg",
    "resize": {
        "width": 100,
        "height": 75
    }
}'

Social Media Profile Pictures

The Pixaven API allows you to easily fetch social media profile pictures and transform them with the vast array of operations the API offers. Currently we support Facebook, Twitter, Instagram, GitHub and Gravatar platforms. We never cache requested images so you can be sure you're always getting the most actual profile picture the user set on their social media account.

To use this feature simply modify the image url passed to the Pixaven API. The pattern used for social media profile pictures is platform:user. For example, to fetch and transform GitHub profile picture of user matylla provide github:matylla as url in the fetch parameters:

curl https://api.pixaven.com/1.0/fetch -X POST -u your-api-key: \
-H "Content-Type: application/json" \
-d '{
    "url": "github:matylla",
    "resize": {
        "width": 100,
        "height": 75
    }
}'
PlatformAcceptable User Names
facebookNumeric user ID, for example 10092511675
twitterUser name, for example taylorswift
instagramUser name, for example cristiano
githubUser name, for example torvalds
gravatarUser email, for example user@domain.com
Please note that due to security concerns, Facebook only supports accessing user's profile pictures by user IDs and not their full display names.

Thumbnails of Public Videos

You can also easily fetch thumbnail images of videos from video delivery platforms. We currently support YouTube, Vimeo, and Dailymotion.

To use this feature simply modify the image url passed to the Pixaven API. The pattern used for thumbnails of public videos is platform:video_id. For example, to fetch and transform thumbnail image of YouTube video represented by ID dQw4w9WgXcQ use youtube:dQw4w9WgXcQ as url in the fetch parameters:

curl https://api.pixaven.com/1.0/fetch -X POST -u your-api-key: \
-H "Content-Type: application/json" \
-d '{
    "url": "youtube:dQw4w9WgXcQ",
    "resize": {
        "width": 100,
        "height": 75
    }
}'
PlatformAcceptable User Names
youtubeVideo ID, for example dQw4w9WgXcQ
vimeoVideo ID, for example 148751763
dailymotionVideo ID, for example x4vmj52
The Pixaven API will always try to fetch the highest resolution thumbnail from a list of available thumbnails for a given video on a given video platform.

Code Examples for Image Fetch

Below, you'll find examples of how to use the Image Fetch method from the Pixaven API:

<?php

/**
* Instantiate new `$pix` by calling a constructor
*/

$pix = new Pixaven\Pixaven('your-api-key');


/**
* Provide a publicly available image URL with fetch(string) method,
* resize the image to 100 x 75 and parse the output metadata
*/

$pix
    ->fetch('https://www.website.com/image.jpg')
    ->resize(array(
        'width' => 100,
        'height' => 75
    ))
    ->toJSON(function ($error, $meta) {
        if (!empty($error)) {
            throw new Exception($error);
        }

        /**
        * You'll find the full JSON metadata array within the `$meta` variable.
        * Remember to always check if the `success` property is set to `true`.
        */

        if ($meta['success'] == true) {
            print ($meta['output']['url']);
        } else {
            print ($meta['message']);
        }
    });
/**
* Module dependencies
*/

const Pixaven = require("pixaven");


/**
* Instantiate new `pix` by calling a constructor
*/

const pix = new Pixaven("your-api-key");


/**
* Provide a publicly available image URL with fetch(string) method,
* resize the image to 100 x 75 and parse the output metadata
*/

pix
    .fetch("https://www.website.com/image.jpg")
    .resize({
        width: 100,
        height: 75
    })
    .toJSON((err, meta) => {
        if (err) {
            return console.log(err);
        }

        /**
        * You'll find the full JSON metadata hash within the `meta` variable.
        * Remember to always check if the `success` property is set to `true`.
        */

        if (meta.success) {
            console.log(meta.output.url);
        } else {
            console.log(meta.message);
        }
    });
##
# Require dependencies

require "pixaven"


##
# Instantiate new `pix` by calling a constructor

pix = Pixaven.new("your-api-key")


##
# Provide a publicly available image URL with fetch(string) method,
# resize the image to 100 x 75 and parse the output metadata

err, meta = pix
    .fetch("https://www.website.com/image.jpg")
    .resize(
        width: 100,
        height: 75
    )
    .to_json

abort(err) if err


##
# You'll find the full JSON metadata hash within the `meta` variable.
# Remember to always check if the `success` property is set to `true`.

if meta["success"]
    puts meta["output"]["url"]
else
    puts meta["message"]
end
package main

import (
    "fmt"
    "github.com/pixaven/pixaven-go"
)

func main() {

    /**
    * Instantiate new `pix` by calling a constructor
    */

    pix, err := pixaven.NewClient("your-api-key")

    if err != nil {
        panic(err)
    }


    /**
    * Provide a publicly available image URL with Fetch(string) method,
    * resize the image to 100 x 75 and parse the output metadata
    */

    meta, err := pix.
        Fetch("https://www.website.com/image.jpg").
        Resize(pixaven.P{
            "width": 100,
            "height": 75
        }).
        ToJSON()

    if err != nil {
        panic(err)
    }


    /**
    * You'll find the full JSON metadata hash within the `meta` variable.
    * Remember to always check if the `success` property is set to `true`.
    */

    if meta["success"].(map[string]interface{})["success"].(bool) {
        fmt.Println(meta["output"].(map[string]interface{})["url"])
    } else {
        fmt.Println(meta["message"])
    }
}
##
# Import dependencies

from pixaven import pixaven


##
# Instantiate new `client` by calling a constructor

client = pixaven('your-api-key')


##
# Provide a publicly available image URL with fetch(string) method,
# resize the image to 100 x 75 and parse the output metadata

err, meta = (
    client
        .fetch('https://www.website.com/image.jpg')
        .resize({
            'width': 100,
            'height': 75
        })
        .toJSON()
)

if err is not None:
    raise StandardError(err)


##
# You'll find the full JSON metadata hash within the `meta` variable.
# Remember to always check if the `success` property is set to `true`.

if meta['success'] is True:
    print (meta['output']['url'])
else:
    print (meta['message'])
package com.pixaven.examples;

/**
* Import dependencies
*/

import static com.pixaven.OperationConfiguration.settings;
import com.pixaven.Pixaven;
import com.pixaven.Fetch;
import com.pixaven.Response;

public class ImageFetch {
    public static void main(String[] args) {

        /**
        * Instantiate new `pix` by calling a constructor
        */

        Pixaven pix = new Pixaven("your-api-key");

        /**
        * Provide a publicly available image URL with fetch(string) method,
        * resize the image to 100 x 75 and parse the output metadata
        */

        final Fetch fetch = pix.fetch("https://www.website.com/image.jpg");

        fetch.resize(
            settings()
                .set("width", 100)
                .set("height", 75)
        );

        final Response response = fetch.toJson();

        /**
        * You'll find the full JSON metadata hash within the `Response#getMetadata()` property.
        * Remember to always check if the `Response#successful` property is set to `true`.
        */

        if (response.isSuccessful()) {
            System.out.println(response.getMetadata().getOutput().get("url"));
        } else {
            System.out.println(response.getMessage());
        }
    }
}

We use both proprietary and third-party cookies to improve your browsing experience and to provide you with a better service. By continuing to use this site you consent our use of cookies as described in our Cookie Policy×