User profile functionality is an essential part of almost every application. The goal of this post is to present a short introduction to the Baasic user profile module and the accompanying REST API endpoints.

You will need to use your Baasic account to become familiar with the feature I am going to describe. You can open it in three easy steps, starting at the registration form. For more detailed description of the Baasic Dashboard and related features, please visit our introduction to the Baasic dashboard.

Profile REST API

User profile module provides access to the public user profile information and allows users to manage their profile data. This includes general information (first and last name, address, mobile phone), as well as the extended information, including education and work experience.

As in every other Baasic module, user profile built-in format can be extended to satisfy specific user requirements by simply posting extended JSON to the Baasic REST API. Customizing all user profile elements has never been easier, and that is one of the advantages of our platform.

Endpoints

There are several Baasic User Profile API endpoints that allow users to retrieve and manage the profile information, such as:

Full Baasic REST API documentation, including the REST API endpoints of User Profile lookups - such as skills, organizations and companies, can be found here.

Here are a couple of usage examples of the foregoing user profile endpoints.

Samples

Let’s start by creating a new user profile. A request made to the profile endpoint (using the HTTP POST method) will create a user profile, and it looks as follows:

curl -X POST -H "Content-Type: application/json" -d '{
    "address": "1403 Main Street", 
    "city": "London", 
    "country": "UK", 
    "displayName": "John", 
    "dob": "1980-05-03",  
    "firstName": "John", 
    "lastName": "Doe", 
    "zipCode": "WC2N", 
    "id": "dUze4lyo9s397kioAZ3SHn"
}' https://api.baasic.com/<version>/<apikey>/profiles

If the profile is created successfully, you should get a response similar to this:

{
    "aboutMySelf": null, 
    "address": "1403 Main Street", 
    "city": "London", 
    "country": "UK", 
    "displayName": "John", 
    "dob": "1980-05-03",  
    "firstName": "John", 
    "lastName": "Doe", 
    "mobilePhone": null, 
    "timestamp": null, 
    "timeZoneId": null, 
    "webSites": null, 
    "zipCode": "WC2N", 
    "dateCreated": "2015-08-21T13:15:31",
    "dateUpdated": null,
    "id": "dUze4lyo9s397kioAZ3SHn",
    "_embedded": {},
}

Once the profile is created, you can update it by making a request to the profile endpoint using the HTTP PUT method. Here is how a typical update scenario works:

curl -X PUT -H "Content-Type: application/json" -d '{
    "aboutMySelf": "", 
    "address":"850 Main Street",
    "city": "London", 
    "country": "UK", 
    "displayName": "John", 
    "dob": "1980-05-03",  
    "firstName": "John", 
    "lastName": "Doe", 
    "mobilePhone": "+44 20 7946 0780",
    "timestamp": "", 
    "timeZoneId": "", 
    "webSites": "", 
    "zipCode": "WC2N", 
    "dateCreated": "2015-08-21T13:15:31",
    "dateUpdated": "",
    "id": "dUze4lyo9s397kioAZ3SHn"
}' https://api.baasic.com/<version>/<apikey>/profiles/<id>

A successful update will result in a response similar to the one showed above, reflecting the changes we’ve just made.

The following request made to the profile endpoint using HTTP GET method will retrieve a list of the user profiles:

curl –H "Accept: application/hal+json" https://api.baasic.com/<version>/<apikey>/profiles

On success, the response will return an array of the user profile resources currently stored in the system. As we’ve created only one user profile, this is all we get:

{
"_embedded": {
    "profile": [
    {
        "aboutMySelf": null, 
        "address": "850 Main Street", 
        "city": "London", 
        "country": "UK", 
        "displayName": "John", 
        "dob": "1980-05-03",  
        "firstName": "John", 
        "lastName": "Doe", 
        "mobilePhone": "+44 20 7946 0780", 
        "timestamp": null, 
        "timeZoneId": null, 
        "webSites": null, 
        "zipCode": "WC2N", 
        "dateCreated": "2015-08-21T13:15:31",
        "dateUpdated": "2015-08-24T14:21:15",
        "id": "dUze4lyo9s397kioAZ3SHn",
        "_embedded":{}
    }
    ]
},   
"embed": null,
"page": 1,
"recordsPerPage": 10,
"searchQuery": null,
"sort": null,
"totalRecords": 1
}

To find more about user’s education, a request made to the education endpoint using the HTTP GET method should look as this:

curl –H "Accept: application/hal+json" https://api.baasic.com/<version>/<apikey>/profiles/<user-id>/education

The returned response will contain the existing user education information in the following format:

{
"_embedded": {
    "education": [
     {
        "degree": "MBA", 
        "endDate": "2003-09-18", 
        "grade": null, 
        "organizationId": "zNyn42lv7ul427sZvR7NUe",
        "organizationName": "London Business School",
        "startDate": "1998-10-05",
        "summary": null,
        "userId": "dUze4lyo9s397kioAZ3SHn",
        "dateCreated": "2015-08-21T13:19:23",
        "dateUpdated": "2015-08-22T12:30:21",
        "id": "zEan31io7vl397sZvR7NHk",
        "_embedded":{}
    }
    ]
},   
"embed": null,
"page": 1,
"recordsPerPage": 10,
"searchQuery": null,
"sort": null,
"totalRecords": 1
}

Similarly, to retrieve a list of user work experiences, a request is to be made to the work endpoint using the HTTP GET method:

curl –H "Accept: application/hal+json" https://api.baasic.com/<version>/<apikey>/profiles/<user-id>/work

Here is the returned response:

{
"_embedded": {
    "userWork": [
     {
        "position": "Marketing Analyst", 
        "location": "London", 
        "endDate": null, 
        "currentlyEmployed": null,
        "companyId": "zIny521o8s39kwOaN13Wa",
        "companyName": "Inmark Ltd.",
        "startDate": "2004-05-14",
        "summary": null,
        "userId": "dUze4lyo9s397kioAZ3SHn",
        "department": "Business Analysis Department",
        "dateCreated": "2015-08-21T13:22:43",
        "dateUpdated": "2015-08-22T11:25:41",
        "id": "sAv4nlyZ9os253ZH3kioSNd",
        "_embedded":{}
    },
    {
        "position": "Statistician", 
        "location": "London", 
        "endDate": 2009-05-14, 
        "currentlyEmployed": null,
        "companyId": "zIny521o8s39kwOaN13Wa",
        "companyName": "Inmark Ltd.",
        "startDate": "2004-01-11",
        "summary": null,
        "userId": "dUze4lyo9s397kioAZ3SHn",
        "department": "Business Analysis Department",
        "dateCreated": "2015-08-24T13:19:23",
        "dateUpdated": "2015-08-24T15:21:22",
        "id": "d23AnukE14s274ZH33zySAt",
        "_embedded":{}
    }
    ]
},   
"embed": null,
"page": 1,
"recordsPerPage": 10,
"searchQuery": null,
"sort": null,
"totalRecords": 2
}

Finally, if you want to access the user skills, the following request should be made to the skill endpoint:

curl –H "Accept: application/hal+json" https://api.baasic.com/<version>/<apikey>/profiles/<user-id>/skills

The response will contain the user’s skills in this format:

{
"_embedded": {
    "userSkill": [
     {
        "skillId": "lNuz7lvn4s327linAN3ZHt", 
        "skillName": "Digital Marketing", 
        "userId": "dUze4lyo9s397kioAZ3SHn", 
        "dateCreated": "2015-08-21T13:25:11",
        "dateUpdated": "2015-08-21T12:15:54",
        "id": "vU4lnzi9ol367kvn3SHvyn",
        "_embedded":{}
    },
    {
        "skillId": "kNlel81oys351hidWZ1Syl", 
        "skillName": "Data Analysis", 
        "userId": "dUze4lyo9s397kioAZ3SHn", 
        "dateCreated": "2015-08-21T13:27:12",
        "dateUpdated": "2015-08-22T13:02:17",
        "id": "nz15lvo7yAZ5lki391UZd",
        "_embedded":{}
    },
    {
        "skillId": "rUn1yl47ok365WZ1diySn4", 
        "skillName": "Data Mining", 
        "userId": "dUze4lyo9s397kioAZ3SHn", 
        "dateCreated": "2015-08-21T13:27:12",
        "dateUpdated": "2015-08-22T13:02:17",
        "id": "uN253sZ7aB45lw951nEcD",
        "_embedded":{}
    }
    ]
},   
"embed": null,
"page": 1,
"recordsPerPage": 10,
"searchQuery": null,
"sort": null,
"totalRecords": 3
}

In a nutshell, all aspects of the Baasic user profile module can be accessed through its REST API endpoints. In addition, the module itself can be easily customized to hold and display the extended information as needed in your specific scenarios. Stay tuned for the next part where we will use Baasic Profile AngularJS SDK to integrate it with your existing applications. In the meantime, feel free to contact us with any questions or comments you might have.

Feel free to leave a comment

comments powered by Disqus