Read Profiles

After you've completed the steps in Get Ready to Use the People API , you are ready to read data for profiles.

The following code samples demonstrate how to send a few simple requests. For a full list of methods, see the reference documentation .

Get the person for the authenticated user

To get the user's profile , use the following code:

Protocol

 GET 
 /v1/people/me?personFields=names,emailAddresses 
 HTTP 
 / 
 1.1 
 Host 
 : 
 people.googleapis.com 

Java

 Person 
  
 profile 
  
 = 
  
 peopleService 
 . 
 people 
 (). 
 get 
 ( 
 "people/me" 
 ) 
  
 . 
 setPersonFields 
 ( 
 "names,emailAddresses" 
 ) 
  
 . 
 execute 
 (); 

Python

 profile 
 = 
 people_service 
 . 
 people 
 () 
 . 
 get 
 ( 
 'people/me' 
 , 
 personFields 
 = 
 'names,emailAddresses' 
 ) 

PHP

 $profile = $people_service->people->get( 
 'people/me', array('personFields' => 'names,emailAddresses')); 

.NET

 PeopleResource 
 . 
 GetRequest 
  
 peopleRequest 
  
 = 
  
 peopleService 
 . 
 People 
 . 
 Get 
 ( 
 "people/me" 
 ); 
 peopleRequest 
 . 
 PersonFields 
  
 = 
  
 "names,emailAddresses" 
 ; 
 Person 
  
 profile 
  
 = 
  
 peopleRequest 
 . 
 Execute 
 (); 

To get the person information for a Google Account ID , use the following code:

Protocol

 GET 
 /v1/people/ account_id 
?personFields=names,emailAddresses 
 HTTP 
 / 
 1.1 
 Host 
 : 
 people.googleapis.com 

Java

 Person 
  
 profile 
  
 = 
  
 peopleService 
 . 
 people 
 (). 
 get 
 ( 
 "people/ account_id 
" 
 ) 
  
 . 
 setPersonFields 
 ( 
 "names,emailAddresses" 
 ) 
  
 . 
 execute 
 (); 

Python

 profile 
 = 
 people_service 
 . 
 people 
 () 
 . 
 get 
 ( 
 'people/ account_id 
' 
 , 
 personFields 
 = 
 'names,emailAddresses' 
 ) 

PHP

 $profile = $people_service->people->get( 
 'people/ account_id 
', array('personFields' => 'names,emailAddresses')); 

.NET

 PeopleResource 
 . 
 GetRequest 
  
 peopleRequest 
  
 = 
  
 peopleService 
 . 
 People 
 . 
 Get 
 ( 
 "people/ account_id 
" 
 ); 
 peopleRequest 
 . 
 PersonFields 
  
 = 
  
 "names,emailAddresses" 
 ; 
 Person 
  
 profile 
  
 = 
  
 peopleRequest 
 . 
 Execute 
 (); 
Create a Mobile Website
View Site in Mobile | Classic
Share by: