Devin Price has a helpful snippet…

Devin Price has a helpful snippet for accessing an external API through the server, so that the data can be used with with client-side JavaScript. His sample shows how to get shipping rates from an external service, for use in a custom WordPress JSON endpoint.