Go Sample Code: Global Page Load Performance

Here is an example that will measure the performance of a page load (or API call) from a specified global server location (Tokyo, Paris, Mumbai, California, Sydney, London, Montreal, Buenos Aires, etc.)

Go code:

            
package main

import (
    "encoding/json"
    "fmt"
    "net/http"
)

type Payload struct {
	Origin string
	Seconds string
	PageResponseStatus string
	Contents string
	Code string
	Credits  int
}

func main() {
    // Create the struct variable to store the decoded JSON response
    thePayload := Payload{}

    // Call the API
    // Can error check here too replacing underscore with 'err'
    response, _ := http.Get("https://api.interzoid.com/globalpageload?license=
                YOURAPILICENSEKEY&origin=singapore&url=www.ebay.com")

    if response.StatusCode != 200 {
        // Report any HTTP Errors
        fmt.Println("Error: ", response.Status)

    } else {
        // Decode the JSON and print a comma-delimited response,
        // one of many ways to format the response
        _ = json.NewDecoder(response.Body).Decode(&thePayload)

        fmt.Println(
        thePayload.Origin + "," +
        thePayload.Seconds + "," +
        thePayload.PageResponseStatus + "," +
        thePayload.Contents)
    }
}

            

To execute from the command line:

            
> go run YOURFILENAME.go
            

Results:

            
Singapore,0.86,200 OK,HTML...
            

If you do not have an API License Key, you can obtain one by registering here.

Return to Global Page Load Performance API page

Free API Credits
Register for an Interzoid API account and receive free trial credits
Company Name Matching API
Generate similarity keys to identify duplicate and inconsistent company name data
More Info...
Other Matching APIs
Generate similarity keys for other data types
More Info...
International Phone Demographics API
Test page load and other Web asset performance time with a simple API call
More Info...
Email Information API
Get email address validation and enhancement data
More Info...