Skip to content

Welcome to ServiceNow SDK for Go

GoDoc GitHub Go version GitHub release

The ServiceNow SDK for Go is a powerful, type-safe, and intuitive client library for interacting with ServiceNow REST APIs. Built on the modern Microsoft Kiota framework, it provides a fluent development experience tailored specifically for Go developers.

Why use this SDK?

Building integrations with ServiceNow can be complex. This SDK simplifies that process by providing:

  • Fluent API: Write readable and discoverable code that matches the API hierarchy.
  • Strong typing: Leverage Go generics (in V2 modules) for compile-time checks and improved IDE support.
  • Resilience: Benefit from automatic retries and modular middleware for logging and error handling.
  • Extensibility: Integrate custom authentication methods or specialized table models.

Quick start

Get up and running with just a few lines of code:

import (
    "context"
    "fmt"
    "log"

    servicenowsdkgo "github.com/michaeldcanady/servicenow-sdk-go"
    tableapi "github.com/michaeldcanady/servicenow-sdk-go/table-api"
)

func main() {

    cred := credentials.NewBasicProvider("{username}", "{password}")


    client, err := servicenowsdkgo.NewServiceNowServiceClient(
        servicenowsdkgo.WithAuthenticationProvider(cred),
        servicenowsdkgo.WithURL("https://{instance}.service-now.com"),
    )
    if err != nil {
        log.Fatal(err)
    }

    ctx := context.Background()

    // Get records from the 'incident' table
    listGuideResponse, err := client.Now2().TableV2("{TableName}").Get(ctx, nil)
    if err != nil {
        log.Fatalf("Error: %v", err)
    }

    results, err := listGuideResponse.GetResult()
    if err != nil {
        log.Fatal(err)
    }

    for _, record := range results {
        num, err := record.Get("number")
        if err != nil {
            log.Fatal(err)
        }

        val, err := num.GetValue()
        if err != nil {
            log.Fatal(err)
        }
        strVal, err := val.GetStringValue()
        if err != nil {
            log.Fatal(err)
        }

        fmt.Printf("Incident: %s\n", *strVal)
    }

}

Explore the documentation

  • Getting Started: Follow the quick start guide to install the SDK and make your first call.
  • User Guide: Deep dive into core features like authentication, table operations, and file attachments.
  • API Reference: Browse detailed technical documentation for every supported ServiceNow API module.
  • Contributor Guide: Learn how to help improve the SDK and become part of the community.

This project is community-driven and isn't an official ServiceNow product.