All integrations
Go + ParseAPI

Go. Make your first call.

Install the official Go client and bring ParseAPI into your code.

Official Go SDK

Go install
go get github.com/parseapi/go

Your language. The same ParseAPI.

Get connected

One country. Your first request.

Look up the United States and print its name.

01

Install the library.

Run the install command inside a Go module.

Terminal
go get github.com/parseapi/go
02

Add your secret key.

Create a secret key in Keys. Set it in the terminal that will run the example. Keep it on your server.

Terminal environment
export PARSEAPI_KEY='YOUR_API_KEY'
03

Make a request.

Save this as main.go, then run it. This lookup uses your plan's request allowance.

main.go
package main

import (
    "context"
    "fmt"
    "log"

    parseapi "github.com/parseapi/go"
)

func main() {
    parse, err := parseapi.New("") // Reads PARSEAPI_KEY.
    if err != nil { log.Fatal(err) }
    country, err := parse.Country(context.Background(), "US")
    if err != nil { log.Fatal(err) }
    fmt.Println(country.Name)
}
Run
go run .
Expected outputUnited States
Handle API errors

Read the error code and request ID when an API request fails. Branch on the code, such as not_found, rather than the message. A response with valid: false is a successful lookup. Transport failures still propagate.

main.go with error handling
package main

import (
    "context"
    "errors"
    "fmt"
    "log"

    parseapi "github.com/parseapi/go"
)

func main() {
    parse, err := parseapi.New("") // Reads PARSEAPI_KEY.
    if err != nil {
        log.Fatal(err)
    }
    country, err := parse.Country(context.Background(), "US")
    if err != nil {
        var apiError *parseapi.Error
        if errors.As(err, &apiError) {
            log.Print(apiError.Code, " ", apiError.Status, " ", apiError.RequestID)
        }
        log.Fatal(err)
    }
    fmt.Println(country.Name)
}
Requests and retries

SDK methods follow the API routes. Unknown response values stay unknown, rather than becoming empty strings or guesses.

Ordinary lookups retry temporary failures. Separately metered checks make one attempt by default. You can configure the retry count. See the retry policy.

Build with a working example