Google Page Speed for .NET

This little piece of software sends a request to the Google page speed API, then parses the JSON response and presents them in a nice class.

I use this class on this webpage to show the page speed score at the bottom right corner of the site.

  • Using .NET variables for things like language (CultureInfo) or ResponseCode (HttpStatusCode)
  • Predefined enumerations for ArgumentType, Strategy, SupportedLanguages etc.
  • Uses the 3.5 Framework DataContractJsonSerializer class for deserialization.
  • Automatic combination of the format strings with the arguments.

Here's a sample code how to use it (There is an online demo at


// Create the object with your google api key
PageSpeedpageSpeed = newPageSpeed("your-pagespeed-api-key");

// Set properties where necessairy, only the url is mandatory.
pageSpeed.Locale = SupportedLanguages.English;
pageSpeed.PrettyPrint = true;
pageSpeed.Strategy = Strategy.Desktop;
pageSpeed.Url = "";

// If you dont want to send a server side call to the google pagespeed api, you can
// use this property to go to the google pagespeed webpage
// and start a test for your url.
stringdirectGoogleUrl = pageSpeed.DirectGoogleUrl;

// Get the page speed data for the url from the google pagespeed api
PageSpeedDatadata = pageSpeed.GetPageSpeedData();

Last edited Apr 23, 2012 at 7:58 AM by Darky28, version 2


No comments yet.