Downloading Employee Profile Pictures with the TribeHR API

In TribeHR, each employee profile can have a picture associated with it. You can use the TribeHR API to retrieve the profile picture, also known as the avatar, for any employee.

Note: You cannot upload employee profile pictures to TribeHR using the API.

TribeHR stores avatars using the Amazon Simple Storage Service (Amazon S3). Downloading avatars using the API is a two-step process:

1. Retrieve a list of all users in your account.

2. Retrieve the avatar for the employee(s) you want.

Retrieve a List of Users in Your Account

Make a GET request for the API endpoint, using either JSON or XML:

http://[username]:[APIKEY]@accountname.mytribehr.dev/users.json
http://[username]:[APIKEY]@accountname.mytribehr.dev/users.xml

where:

  • username is the TribeHR administrator user name
  • APIKEY is the API key
  • accountname is the account name. This is the string that appears before “.mytribehr.com” in the URL for your TribeHR account.

NOTE: You will need to specify X-API-VERSION as 2.0.0 in the header of the request.

This returns a JSON- or XML-formatted list of each user in the system. Here is a JSON-formatted example of a response:

[
{
"id": "1",
"username": “auser",
"avatar": {
"url": "https://s3.amazonaws.com/tribeapp-prod/shortname/avatars/
f5d3b492bc09db02508413956ab9.jpg" },
"email": “auser@example.com",
"display_name": “Anthony User",
"employee_record": {
    "first_name": “Anthony",
    "last_name": “User",
    "url": "/employee_records/view/3"
},
              "url": "/users/view/1"
          },
... ]

NOTE: Since employees are not required to have a profile picture, the url parameter for a particular user could be empty:

"url": null

Retrieve the avatar(s) for the employee(s) you want

Using the JSON response, you can retrieve the image at the URL indicated. In the example above, it would be the one shown here:

"url": "https://s3.amazonaws.com/tribeapp-prod/shortname/avatars/ f5d3b492bc09db02508413956ab9.jpg"

To retrieve many or all avatars, iterate over the JSON response to extract that URL and retrieve the image by whatever means best suits your use case (for example, wget, curl, etc).

Still have questions about downloading employee profile pictures using the TribeHR API? Submit a help request and the TribeHR support team will be happy to help!

Have more questions? Submit a request

Comments

Powered by Zendesk