You send following json to server if you need data to work on:
{"method":"getwork","params":[],"id":"json"}
Sever responds with:
{ "id":"json", "error":null,
"result":{
"midstate":"0e8a0e8d83ae508c1a0859c3a298d86676904b83803ac67323ed2c51d8e2d7f3",
"target":"ffffffffffffffffffffffffffffffffffffffffffffffffffffffff00000000",
"data":"00000001cddc2362bc4b15ef5ebf6fef9dd58bcb24ca1f05596bcd9e0000078400000000f5354d24f29a46e2c1ecf861795ffe4f26ee7cc0755098b2421dc823b42b16264e0b78c41a0c2a1200000000000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000",
"hash1":"00000000000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000010000"
}
}
Is block data just the header?
It's header in big-endian hexademical format with additional bytes for SHA256 (see wiki on SHA256 for details).
When a miner hits the target, how does it send the nonce back?
Same getwork reqeuest as first one in this post, except
params isn't empty and has work-data with valid nonce. In hexademical big-endian ofcourse.
See source code of any miner for more details.