Prerequisites

Prerequisites

This section describes certain shell tools and environment variables required to use the GO API
with the examples in this Guide. At the end of this section, you should have your environment set
properly and have verified that you can access the GO API with your account.

The curl Command

Many of the examples in this guide will make use of curl, an industry standard tool for making
HTTP requests from the command line: you can download curl at https://curl.haxx.se.

Our invocations of curl will use these options:

  • -s -S: suppresses the progress meter display but still shows any error messages (these two
    must be used together)
  • -X VERB: indicates which kind of HTTP operation to perform; VERB must be one of GET,
    PUT, POST, or DELETE
  • -H "key: value": sets the HTTP header to the given key and value; "Content-Type: application/json" indicates that the returned data will be in JSON format
  • --body @FILE: specifies that the body content for an HTTP POST or PUT operation is to
    be taken from the file named FILE

While this guide uses curl, other mechanisms for making HTTP requests can of course also be
used, such as with the command line tool wget or with the HTTP support provided by your
favorite programming language.

Environment Variables for the GO API Servers

You must set an environment variable to point to the GO API server. For the commercial release of
GO, it can be set like this from your shell:

export GO_API_URL=https://go-services.orbitalinsight.com/api/v2/go

If you are not using the commercial release of GO, contact Orbital Insight Client Success Team
([email protected]) for the correct URL to use.

You should verify the web service URLs are correct with this command:

curl -s -S \
    -H "Content-Type: application/json" \
    -X GET \
    $GO_API_URL/ping

That command should return a JSON response similar to this:

{
  "data": {
    "hello": "world"
  },
  "status": 200
}

The status of 200 indicates the command succeeded.

Setting the User Token Environment Variable

Each API request must contain a valid token authorizing you to use the Go API. Set this token using
this command:

export GO_API_TOKEN=...

If you do not know your 40-character API token but do know your username and password, you can
retrieve your token with the following Python script (be sure and replace the strings USERNAME
and PASSWORD):

#!/usr/bin/env python3

import os
import requests
from requests.auth import HTTPBasicAuth

server = os.getenv('GO_API_URL')
username = 'USERNAME'
password = 'PASSWORD'
url = '{0}/users/{1}/token'.format(server, username)

response = requests.get(url, auth=HTTPBasicAuth(username, password))
token = response.json()['data']['oi_token']
print(token)

If you do not know your username or password, please contact the Orbital Insight Client Success
Team ([email protected]).

Once you have your token, you should verify your access token is correct for performing both GO
operations. Retrieve information about your own GO API account by executing
this command:

curl -s -S \
    -H "Content-Type: application/json" \
    -H "X-Orbitalinsight-Auth-Token: $GO_API_TOKEN" \
    -X GET \
    $GO_API_URL/users

That should return a JSON response similar to the following:

{
  "data": [
    {
      "customer_id": "Dodgson and Associates",
      "email": "[email protected]",
      "licenses": [
        "gocreate",
        "goexplore"
      ],
      "name": "Alice Liddell",
      "oi_token": "...",
      "user_id": "alice"
    }
  ],
  "list_attributes": {
    "limit": 100,
    "offset": 0,
    "total": 1
  },
  "status": 200
}

(Some fields have been omitted for clarity.)

The field data.licenses should contain the strings "gocreate" and "goexplore". If it
does not, please contact the Orbital Insight Client Success Team ([email protected]).