Optidash Blog

Get And Process Social Media Profile Pictures

Retrieve user avatar images easily from Twitter, Facebook, Instagram, GitHub, and Gravatar with our 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 Optidash 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.

Quick Example

Avatars can be easily transformed with the vast array of operations the Optidash 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.optidash.ai/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 Optidash = require("optidash");

/**
* Instantiate `opti`
*/

const opti = new Optidash("your-api-key");

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

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

        console.log(meta);
    });

Wrapping Up

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.