Applications can retrieve or modify wave data by using operations. Some operations are read operations, like fetching a wave, while some are write operations, like adding tags to a wave.
You can use the API to search for waves in the user's account. For example, this Python code retrieves and logs the top 20 waves in the user's inbox:
search_results = service.search(query='in:inbox', num_results=20) for digest in search_results.digests: logging.info(digest.title)
You can also use the API to do other searches, using the search operations described in the Wave help guide.
You can use the API to do wave-level operations, like adding tags or participants, and also to fetch or create new waves.
For example, the following Python code snippets show how to do wave-level operations:
# Add a participant (making it public, in this case) wavelet.participants.add('email@example.com') # Change a participant role wavelet.participants.set_role('firstname.lastname@example.org', wavelet.participants.ROLE_READ_ONLY) # Add a tag wavelet.tags.append('coolwave') # Set a data document wavelet.data_documents['status'] = 'approved'
To create a new wave, you must specify the desired domain of the wave and the starting set of participants. The following code snippets show how to create a new wave in Python or Java:
# Python wave = robot.new_wave(domain='wavesandbox.com', participants=['email@example.com']) # Java Wavelet wave = robot.newWave("wavesandbox.com", Arrays.asList("firstname.lastname@example.org"));
If you want to find out the ID of the new wave immediately after creating it,
like to store it in a database, you can set the
wave = robot.new_wave(domain='wavesandbox.com', participants=['email@example.com'], submit=True)
To fetch a wave (given that you have access), you must specify the wave ID and wavelet ID. The wave ID is of the form 'domain.com!w+characters', and the wavelet ID is always 'domain.com!conv+root'. The following code snippets show how to fetch a wave in Python or Java:
wavelet = robot.fetch_wavelet('googlewave.com!w+DYz-iagTK', 'googlewave.com!conv+root') wavelet = fetchWavelet(new WaveId('googlewave.com", "w+DYz-iagTK'), new WaveletId(domain, "conv+root"))
You can use the API to modify the content of blips,
and these blip-level operations are a combination of selections
and actions. A
The following methods are
Each of these operations returns a
The following methods are
The following code illustrates how selectors and actions are typically used together:
#Insert text at position 4 blip.at(4).insert('text') #Insert gadget at position 4 blip.at(4).insert(elements.Gadget(http://tricky-bot.appspot.com/gadget.xml)) #Replace content at position 5 by 'hi': blip.at(5).replace('hi') #Replace content from position 3-7 with 'hi': blip.range(3,7).replace('hi') #Replace all instances of 'yo' by 'hi': blip.all('yo').replace('hi')
Note that these actions are performed on the server, as well as on the client; as a result, you can inspect these operations within your server logs.