The API


A simple GET request

api.friendlyrobot.fr/v1/nicknames/william

That returns a beautiful JSON :)


{
  "name": "william",
  "gender": "M",
  "nicknames": [
    {
      "nickname": "Bill",
      "intimacy": "1"
    },
    {
      "nickname": "Willy",
      "intimacy": "2"
    }
  ]
}
		


Just copy-paste this PHP code ;)

NPM and Composer coming soon

// Friendliness powered by www.FriendlyRobot.fr
$curl = curl_init();
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_URL,
  "http://api.friendlyrobot.fr/v1/nicknames/" . $firstname
);
$result = curl_exec($curl);
$nicknamesArray = json_decode($result, true);

// We pick a random nickname
if ($nicknamesArray != null) {
	$rand = rand(0, (sizeof($nicknamesArray["nicknames"])-1) );
	$nickname = $nicknamesArray["nicknames"][$rand]["nickname"];
}
else { $nickname = $firstName; }

// And we print a beautiful friendly message to our user :)
echo "Hey " . $nickname . ", how are you doing today ? :D ";
		


Let's propose new nicknames !

Of course, every first name hasn't a nickname right now. FriendlyRobot is an open API, enriched by the community. So feel free to propose new nicknames :)

api.friendlyrobot.fr/v1/propose/bill/for/william