Pixaven Blog

Get Social Media Profile Pictures With Enhanced Fetch Endpoint

Get Social Media Profile Pictures With Enhanced Fetch Endpoint

If you’re dealing with users’ social media accounts and are in the need of their profile pictures, we’ve got great news for you. With our enhanced Fetch Endpoint you can now retrieve avatar images from Twitter, Facebook, Instagram, GitHub, and Gravatar platforms.

To use this new feature simply modify image url passed to the Pixaven API as a part of Image Fetch request. The pattern used for social media profile pictures is platform:user. For example, to fetch GitHub profile picture of user mitchellh provide github:mitchellh as url in the fetch parameters.

Avatars can be easily transformed with the vast array of operations the Pixaven API offers. Say you would like to get GitHub profile picture of TJ Holowaychuk (username tj), resize that image to a maximum of 200px and give it a light sepia treatment. A cURL request would look like this:

curl https://api.pixaven.com/1.0/fetch -X POST -u your-api-key: \
-H "Content-Type: application/json" \
-d '{
    "url": "github:tj",
    "resize": {
        "width": 200
    },
    "filter": {
        "sepia": {
            "value": 20
        }
    }
}'

Now let’s try the same set of transformations on Sharika’s Instagram profile picture. This time we will use instagram:shakira as URL for the Fetch endpoint. With our official Node integration, the request would look like this:

const Pixaven = require("pixaven");

/**
* Instantiate `pix`
*/

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

/**
* Fetch Shakira's Instagram profile picture,
* resize it to 200px, and apply mild Sepia effect
*/

pix
    .fetch("instagram:shakira")
    .resize({
        width: 200
    })
    .filter({
        sepia: {
            value: 20
        }
    })
    .toJSON((err, meta) => {
        if (err) {
            return console.log(err);
        }

        console.log(meta);
    });

As previously stated, we support all major social media outlets. However, it’s worth keeping in mind that due to privacy concerns, Facebook only supports accessing user’s profile pictures by user IDs (and not their full display names). For the full reference, please check out updated API docs for Social Media Profile Pictures.

Should you have questions about fetching social media profile pictures or requests for other features do not hesitate to contact us anytime.

About the author

Przemek Matylla is the Founder and CEO of Pixaven currently living in Berlin. You can follow him on Twitter or connect with him on LinkedIn.